-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Your Name
committed
Jun 13, 2024
1 parent
16b9306
commit 2405828
Showing
6 changed files
with
75 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package validators | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
"popplio/state" | ||
|
||
"github.com/jackc/pgx/v5" | ||
) | ||
|
||
// Returns the system for which this word is blacklisted | ||
func GetWordBlacklistSystems(ctx context.Context, word string) ([]string, error) { | ||
var systems []string | ||
|
||
err := state.Pool.QueryRow(ctx, "SELECT systems FROM blacklisted_words WHERE word = $1", word).Scan(&systems) | ||
|
||
if errors.Is(err, pgx.ErrNoRows) { | ||
return nil, nil | ||
} | ||
|
||
if err != nil { | ||
return nil, fmt.Errorf("failed to get blacklisted word: %w", err) | ||
} | ||
|
||
return systems, nil | ||
} |