Fix conflict error when tagging from Discord

This commit is contained in:
Ben Visness 2021-12-11 10:11:44 -06:00
parent 4d63d02533
commit 7cb6869fcb
2 changed files with 9 additions and 2 deletions

View File

@ -400,7 +400,6 @@ func RemoveGuildMemberRole(ctx context.Context, userID, roleID string) error {
const name = "Remove Guild Member Role"
path := fmt.Sprintf("/guilds/%s/members/%s/roles/%s", config.Config.Discord.GuildID, userID, roleID)
logging.ExtractLogger(ctx).Warn().Str("path", path).Msg("I dunno")
res, err := doWithRateLimiting(ctx, name, func(ctx context.Context) *http.Request {
return makeRequest(ctx, http.MethodDelete, path, nil)
})

View File

@ -742,7 +742,15 @@ func updateSnippetTags(ctx context.Context, dbConn db.ConnOrTx, userID string, s
}
for _, tagID := range tagIDs {
_, err = tx.Exec(ctx, `INSERT INTO snippet_tags (snippet_id, tag_id) VALUES ($1, $2)`, snippet.ID, tagID)
_, err = tx.Exec(ctx,
`
INSERT INTO snippet_tags (snippet_id, tag_id)
VALUES ($1, $2)
ON CONFLICT DO NOTHING
`,
snippet.ID,
tagID,
)
if err != nil {
return oops.New(err, "failed to add tag to snippet")
}