Skip to content

Commit

Permalink
Update comment url for notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasgwatson committed Nov 30, 2022
1 parent 69f0a0c commit 4f8abaf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion api/models/Notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ module.exports = bookshelf.Model.extend({
post_label: postLabel,
post_title: title,
comment_url: Frontend.Route.tokenLogin(reader, token,
Frontend.Route.post(post, group) + '?ctt=comment_email&cti=' + reader.id + `#comment-${comment.id}`),
Frontend.Route.comment({ comment, groupSlug: group.get('slug'), post })),
unfollow_url: Frontend.Route.tokenLogin(reader, token,
Frontend.Route.unfollow(post, group)),
tracking_pixel_url: Analytics.pixelUrl('Comment', {userId: reader.id})
Expand Down
2 changes: 1 addition & 1 deletion api/models/comment/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const sendDigests = async () => {
count: commentData.length,
post_title: TextHelpers.truncateText(post.get('name'), 140),
post_creator_avatar_url: post.relations.user.get('avatar_url'),
thread_url: Frontend.Route.post(post),
thread_url: Frontend.Route.comment({ comment: commentData[0], post }),
comments: commentData,
subject_prefix: some(hasMention, commentData)
? 'You were mentioned in'
Expand Down
8 changes: 3 additions & 5 deletions api/services/Frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,13 @@ module.exports = {

root: () => url('/app'),

comment: function (comment, group) {
// TODO: update to use comment specific url when implemented in frontend
let groupSlug = getSlug(group)
comment: function ({ comment, groupSlug, post }) {

let groupUrl = isEmpty(groupSlug) ? '/all' : `/groups/${groupSlug}`

const postId = comment.relations.post.id
const postId = comment?.relations?.post?.id || post.id

return url(`${groupUrl}/post/${postId}`)
return url(`${groupUrl}/post/${postId}/comments/${comment.id}`)
},

group: function (group) {
Expand Down

0 comments on commit 4f8abaf

Please sign in to comment.