Fix conflict error when tagging from Discord
This commit is contained in:
parent
4d63d02533
commit
7cb6869fcb
|
@ -400,7 +400,6 @@ func RemoveGuildMemberRole(ctx context.Context, userID, roleID string) error {
|
||||||
const name = "Remove Guild Member Role"
|
const name = "Remove Guild Member Role"
|
||||||
|
|
||||||
path := fmt.Sprintf("/guilds/%s/members/%s/roles/%s", config.Config.Discord.GuildID, userID, roleID)
|
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 {
|
res, err := doWithRateLimiting(ctx, name, func(ctx context.Context) *http.Request {
|
||||||
return makeRequest(ctx, http.MethodDelete, path, nil)
|
return makeRequest(ctx, http.MethodDelete, path, nil)
|
||||||
})
|
})
|
||||||
|
|
|
@ -742,7 +742,15 @@ func updateSnippetTags(ctx context.Context, dbConn db.ConnOrTx, userID string, s
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tagID := range tagIDs {
|
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 {
|
if err != nil {
|
||||||
return oops.New(err, "failed to add tag to snippet")
|
return oops.New(err, "failed to add tag to snippet")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue