-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add notifications for likes on comments
- Loading branch information
1 parent
3e1407d
commit b0c196a
Showing
22 changed files
with
218 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
module NotificationMailers | ||
class LikedComment < NotificationMailers::Base | ||
attr_accessor :like | ||
|
||
delegate :target, to: :like, prefix: true | ||
|
||
def set_headers(like_id) # rubocop:disable Naming/AccessorMethodName | ||
@like = Like.find(like_id) | ||
|
||
@headers[:subject] = I18n.t("notifier.liked_comment.liked", name: @sender.name) | ||
@headers[:in_reply_to] = @headers[:references] = "<#{@like.parent.commentable.guid}@#{AppConfig.pod_uri.host}>" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
module Notifications | ||
class LikedComment < Notification | ||
def mail_job | ||
Workers::Mail::LikedComment | ||
end | ||
|
||
def popup_translation_key | ||
"notifications.liked_comment" | ||
end | ||
|
||
def deleted_translation_key | ||
"notifications.liked_comment_deleted" | ||
end | ||
|
||
def self.notify(like, _recipient_user_ids) | ||
actor = like.author | ||
target_author = like.target.author | ||
|
||
return unless like.target_type == "Comment" && target_author.local? && actor != target_author | ||
|
||
concatenate_or_create(target_author.owner, like.target, actor).email_the_user(like, actor) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
- if @notification.like_target.public? | ||
%p | ||
#{t('.liked', name: @notification.sender_name)}: | ||
#{t(".liked", name: @notification.sender_name)}: | ||
= post_message(@notification.like_target, html: true) | ||
- else | ||
%p | ||
#{t('notifier.liked.limited_post', name: @notification.sender_name)}. | ||
#{t(".limited_post", name: @notification.sender_name)}. | ||
|
||
%p | ||
= link_to t(".view_post"), post_url(@notification.like_target) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
- if @notification.like_target.public? | ||
%p | ||
#{t(".liked", name: @notification.sender_name)}: | ||
= post_message(@notification.like_target, html: true) | ||
- else | ||
%p | ||
#{t(".limited_post", name: @notification.sender_name)}. | ||
|
||
%p | ||
= link_to t(".view_comment"), post_url(@notification.like_target.root, anchor: @notification.like_target.guid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<% if @notification.like_target.public? %> | ||
<%= "#{t(".liked", name: @notification.sender_name)}:" %> | ||
<%= post_message(@notification.like_target) %> | ||
<% else %> | ||
<%= "#{t(".limited_post", name: @notification.sender_name)}." %> | ||
<% end %> | ||
<%= t(".view_comment") %> | ||
<%= post_url(@notification.like_target.root, anchor: @notification.like_target.guid) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,3 @@ def perform(*args) | |
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
module Workers | ||
module Mail | ||
class LikedComment < Liked | ||
end | ||
end | ||
end |
Oops, something went wrong.