Fixed tag removal issue.

This commit is contained in:
Asaf Gartner 2022-01-31 10:22:25 +02:00
parent 378d6eb836
commit 92d6a31aa9
3 changed files with 39 additions and 38 deletions

View File

@ -798,7 +798,6 @@ func HandleSnippetForInternedMessage(ctx context.Context, dbConn db.ConnOrTx, in
var desiredTags []int var desiredTags []int
var allTags []int var allTags []int
if len(messageTags) > 0 {
// Fetch projects so we know what tags the user can apply to their snippet. // Fetch projects so we know what tags the user can apply to their snippet.
projects, err := hmndata.FetchProjects(ctx, tx, interned.HMNUser, hmndata.ProjectsQuery{ projects, err := hmndata.FetchProjects(ctx, tx, interned.HMNUser, hmndata.ProjectsQuery{
OwnerIDs: []int{interned.HMNUser.ID}, OwnerIDs: []int{interned.HMNUser.ID},
@ -832,14 +831,13 @@ func HandleSnippetForInternedMessage(ctx context.Context, dbConn db.ConnOrTx, in
for _, itag := range iUserTags { for _, itag := range iUserTags {
tag := itag.(*tagsRow).Tag tag := itag.(*tagsRow).Tag
for _, messageTag := range messageTags {
allTags = append(allTags, tag.ID) allTags = append(allTags, tag.ID)
for _, messageTag := range messageTags {
if strings.EqualFold(tag.Text, messageTag) { if strings.EqualFold(tag.Text, messageTag) {
desiredTags = append(desiredTags, tag.ID) desiredTags = append(desiredTags, tag.ID)
} }
} }
} }
}
_, err = tx.Exec(ctx, _, err = tx.Exec(ctx,
` `

View File

@ -463,7 +463,7 @@ func SetProjectTag(
IncludeHidden: true, IncludeHidden: true,
}) })
if err != nil { if err != nil {
return nil, err return nil, oops.New(err, "Failed to fetch project")
} }
var resultTag *models.Tag var resultTag *models.Tag

View File

@ -760,7 +760,10 @@ func updateProject(ctx context.Context, tx pgx.Tx, user *models.User, payload *P
return oops.New(err, "Failed to update project") return oops.New(err, "Failed to update project")
} }
hmndata.SetProjectTag(ctx, tx, payload.ProjectID, payload.Tag) _, err = hmndata.SetProjectTag(ctx, tx, payload.ProjectID, payload.Tag)
if err != nil {
return err
}
if user.IsStaff { if user.IsStaff {
_, err = tx.Exec(ctx, _, err = tx.Exec(ctx,