From 7cb6869fcb0d032917494868df0cf7379a11b2e3 Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Sat, 11 Dec 2021 10:11:44 -0600 Subject: [PATCH] Fix conflict error when tagging from Discord --- src/discord/rest.go | 1 - src/discord/showcase.go | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/discord/rest.go b/src/discord/rest.go index 61e9762..cc9c36f 100644 --- a/src/discord/rest.go +++ b/src/discord/rest.go @@ -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) }) diff --git a/src/discord/showcase.go b/src/discord/showcase.go index 85d0fc1..bf2f390 100644 --- a/src/discord/showcase.go +++ b/src/discord/showcase.go @@ -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") }