Skip to content

Commit

Permalink
Fixes for 0.6 (#880)
Browse files Browse the repository at this point in the history
* Fix SVG image loading

* Fix notification copy

* Fix edit comment notifications
  • Loading branch information
InfiniteStash authored Jan 3, 2025
1 parent b8b10f8 commit 820b6e5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion frontend/src/pages/notifications/Notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const NotificationHeader = ({
<span>
<em>{notification.data.comment.user?.name}</em> commented on an{" "}
{editLink}
{"you've commented on."}
{" you've commented on."}
</span>
);
if (notification.data.__typename === "CommentOwnEdit")
Expand Down
6 changes: 5 additions & 1 deletion pkg/api/routes_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (rs imageRoutes) image(w http.ResponseWriter, r *http.Request) {
imageRepo := getRepo(r.Context()).Image()

databaseImage, err := imageRepo.Find(uuid)
if err != nil {
if err != nil || databaseImage == nil {
http.Error(w, err.Error(), http.StatusNotFound)
return
}
Expand All @@ -45,6 +45,10 @@ func (rs imageRoutes) image(w http.ResponseWriter, r *http.Request) {
return
}

if databaseImage.Width == -1 {
w.Header().Add("Content-Type", "image/svg+xml")
}

w.Header().Add("Cache-Control", "max-age=604800000")

maxSize := 0
Expand Down
39 changes: 22 additions & 17 deletions pkg/sqlx/querybuilder_notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,28 @@ func (qb *notificationsQueryBuilder) TriggerEditCommentNotifications(commentID u
args = append(args, commentID)
query := `
INSERT INTO notifications
SELECT N.user_id, N.type, $1
FROM edit_comments EC
JOIN edits E ON EC.edit_id = E.id
JOIN user_notifications N ON E.user_id = N.user_id AND N.type = 'COMMENT_OWN_EDIT'
WHERE EC.id = $1
UNION
SELECT N.user_id, N.type, $1
FROM edit_comments EC
JOIN edits E ON EC.edit_id = E.id JOIN edit_comments EO ON EO.edit_id = E.id
JOIN user_notifications N ON EO.user_id = N.user_id AND N.type = 'COMMENT_COMMENTED_EDIT'
WHERE EO.user_id != E.user_id AND EO.user_id != EC.user_id AND EC.id = $1
UNION
SELECT N.user_id, N.type, $1
FROM edit_comments EC
JOIN edits E ON EC.edit_id = E.id JOIN edit_votes EV ON EV.edit_id = E.id
JOIN user_notifications N ON EV.user_id = N.user_id AND N.type = 'COMMENT_VOTED_EDIT'
WHERE EV.vote != 'ABSTAIN' AND EV.user_id != E.user_id AND EV.user_id != EC.user_id AND EC.id = $1
SELECT DISTINCT ON (user_id) user_id, type, $1 FROM (
SELECT N.user_id, N.type, 1 as ordering
FROM edit_comments EC
JOIN edits E ON EC.edit_id = E.id
JOIN user_notifications N ON E.user_id = N.user_id AND N.type = 'COMMENT_OWN_EDIT'
WHERE EC.id = $1
UNION
SELECT N.user_id, N.type, 2 as ordering
FROM edit_comments EC
JOIN edits E ON EC.edit_id = E.id
JOIN edit_comments EO ON EO.edit_id = E.id
JOIN user_notifications N ON EO.user_id = N.user_id AND N.type = 'COMMENT_COMMENTED_EDIT'
WHERE EO.user_id != E.user_id AND EO.user_id != EC.user_id AND EC.id = $1
UNION
SELECT N.user_id, N.type, 3 as ordering
FROM edit_comments EC
JOIN edits E ON EC.edit_id = E.id
JOIN edit_votes EV ON EV.edit_id = E.id
JOIN user_notifications N ON EV.user_id = N.user_id AND N.type = 'COMMENT_VOTED_EDIT'
WHERE EV.vote != 'ABSTAIN' AND EV.user_id != E.user_id AND EV.user_id != EC.user_id AND EC.id = $1
) notifications
ORDER BY user_id, ordering ASC
`
err := qb.dbi.RawExec(query, args)
return err
Expand Down

0 comments on commit 820b6e5

Please sign in to comment.