Add notifications for likes on comments
This commit is contained in:
parent
3e1407d242
commit
b0c196aea0
22 changed files with 218 additions and 73 deletions
|
|
@ -73,6 +73,11 @@ Layout/HashAlignment:
|
||||||
EnforcedHashRocketStyle: table
|
EnforcedHashRocketStyle: table
|
||||||
EnforcedColonStyle: table
|
EnforcedColonStyle: table
|
||||||
|
|
||||||
|
# This rule makes haml files less readable, as there is no 'end' there.
|
||||||
|
Layout/CaseIndentation:
|
||||||
|
Exclude:
|
||||||
|
- "app/views/**/*"
|
||||||
|
|
||||||
# Mixing the styles looks just silly.
|
# Mixing the styles looks just silly.
|
||||||
Style/HashSyntax:
|
Style/HashSyntax:
|
||||||
EnforcedStyle: ruby19_no_mixed_keys
|
EnforcedStyle: ruby19_no_mixed_keys
|
||||||
|
|
|
||||||
|
|
@ -7,24 +7,9 @@
|
||||||
class NotificationsController < ApplicationController
|
class NotificationsController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
|
|
||||||
def update
|
|
||||||
note = Notification.where(:recipient_id => current_user.id, :id => params[:id]).first
|
|
||||||
if note
|
|
||||||
note.set_read_state(params[:set_unread] != "true" )
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
format.json { render :json => { :guid => note.id, :unread => note.unread } }
|
|
||||||
end
|
|
||||||
|
|
||||||
else
|
|
||||||
respond_to do |format|
|
|
||||||
format.json { render :json => {}.to_json }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
conditions = {:recipient_id => current_user.id}
|
conditions = {recipient_id: current_user.id}
|
||||||
|
types = NotificationService::NOTIFICATIONS_JSON_TYPES
|
||||||
if params[:type] && types.has_key?(params[:type])
|
if params[:type] && types.has_key?(params[:type])
|
||||||
conditions[:type] = types[params[:type]]
|
conditions[:type] = types[params[:type]]
|
||||||
end
|
end
|
||||||
|
|
@ -33,7 +18,7 @@ class NotificationsController < ApplicationController
|
||||||
per_page = params[:per_page] || 25
|
per_page = params[:per_page] || 25
|
||||||
@notifications = WillPaginate::Collection.create(page, per_page, Notification.where(conditions).count ) do |pager|
|
@notifications = WillPaginate::Collection.create(page, per_page, Notification.where(conditions).count ) do |pager|
|
||||||
result = Notification.where(conditions)
|
result = Notification.where(conditions)
|
||||||
.includes(:target, :actors => :profile)
|
.includes(:target, actors: :profile)
|
||||||
.order("updated_at desc")
|
.order("updated_at desc")
|
||||||
.limit(pager.per_page)
|
.limit(pager.per_page)
|
||||||
.offset(pager.offset)
|
.offset(pager.offset)
|
||||||
|
|
@ -52,13 +37,28 @@ class NotificationsController < ApplicationController
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.xml { render :xml => @notifications.to_xml }
|
format.xml { render xml: @notifications.to_xml }
|
||||||
format.json {
|
format.json {
|
||||||
render json: render_as_json(@unread_notification_count, @grouped_unread_notification_counts, @notifications)
|
render json: render_as_json(@unread_notification_count, @grouped_unread_notification_counts, @notifications)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
note = Notification.where(recipient_id: current_user.id, id: params[:id]).first
|
||||||
|
if note
|
||||||
|
note.set_read_state(params[:set_unread] != "true")
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.json { render json: {guid: note.id, unread: note.unread} }
|
||||||
|
end
|
||||||
|
else
|
||||||
|
respond_to do |format|
|
||||||
|
format.json { render json: {}.to_json }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def default_serializer_options
|
def default_serializer_options
|
||||||
{
|
{
|
||||||
context: self,
|
context: self,
|
||||||
|
|
@ -67,7 +67,7 @@ class NotificationsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def read_all
|
def read_all
|
||||||
current_type = types[params[:type]]
|
current_type = NotificationService::NOTIFICATIONS_JSON_TYPES[params[:type]]
|
||||||
notifications = Notification.where(recipient_id: current_user.id, unread: true)
|
notifications = Notification.where(recipient_id: current_user.id, unread: true)
|
||||||
notifications = notifications.where(type: current_type) if params[:type]
|
notifications = notifications.where(type: current_type) if params[:type]
|
||||||
notifications.update_all(unread: false)
|
notifications.update_all(unread: false)
|
||||||
|
|
@ -79,8 +79,8 @@ class NotificationsController < ApplicationController
|
||||||
format.html { redirect_to stream_path }
|
format.html { redirect_to stream_path }
|
||||||
format.mobile { redirect_to stream_path }
|
format.mobile { redirect_to stream_path }
|
||||||
end
|
end
|
||||||
format.xml { render :xml => {}.to_xml }
|
format.xml { render xml: {}.to_xml }
|
||||||
format.json { render :json => {}.to_json }
|
format.json { render json: {}.to_json }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -95,18 +95,4 @@ class NotificationsController < ApplicationController
|
||||||
}
|
}
|
||||||
}.as_json
|
}.as_json
|
||||||
end
|
end
|
||||||
|
|
||||||
def types
|
|
||||||
{
|
|
||||||
"also_commented" => "Notifications::AlsoCommented",
|
|
||||||
"comment_on_post" => "Notifications::CommentOnPost",
|
|
||||||
"liked" => "Notifications::Liked",
|
|
||||||
"mentioned" => "Notifications::MentionedInPost",
|
|
||||||
"mentioned_in_comment" => "Notifications::MentionedInComment",
|
|
||||||
"reshared" => "Notifications::Reshared",
|
|
||||||
"started_sharing" => "Notifications::StartedSharing",
|
|
||||||
"contacts_birthday" => "Notifications::ContactsBirthday"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
helper_method :types
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ module NotificationsHelper
|
||||||
elsif %w(Notifications::CommentOnPost Notifications::AlsoCommented Notifications::Reshared Notifications::Liked)
|
elsif %w(Notifications::CommentOnPost Notifications::AlsoCommented Notifications::Reshared Notifications::Liked)
|
||||||
.include?(note.type)
|
.include?(note.type)
|
||||||
opts.merge!(opts_for_post(note.linked_object))
|
opts.merge!(opts_for_post(note.linked_object))
|
||||||
|
elsif note.is_a?(Notifications::LikedComment)
|
||||||
|
opts.merge!(opts_for_comment(note.linked_object))
|
||||||
elsif note.is_a?(Notifications::ContactsBirthday)
|
elsif note.is_a?(Notifications::ContactsBirthday)
|
||||||
opts.merge!(opts_for_birthday(note))
|
opts.merge!(opts_for_birthday(note))
|
||||||
end
|
end
|
||||||
|
|
@ -33,7 +35,16 @@ module NotificationsHelper
|
||||||
post_link: link_to(post_page_title(post),
|
post_link: link_to(post_page_title(post),
|
||||||
post_path(post),
|
post_path(post),
|
||||||
data: {ref: post.id},
|
data: {ref: post.id},
|
||||||
class: "hard_object_link").html_safe
|
class: "hard_object_link")
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def opts_for_comment(comment)
|
||||||
|
{
|
||||||
|
comment_link: link_to(comment.message.title,
|
||||||
|
post_path(comment.post, anchor: comment.guid),
|
||||||
|
data: {ref: comment.id},
|
||||||
|
class: "hard_object_link")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
16
app/mailers/notification_mailers/liked_comment.rb
Normal file
16
app/mailers/notification_mailers/liked_comment.rb
Normal file
|
|
@ -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
|
||||||
26
app/models/notifications/liked_comment.rb
Normal file
26
app/models/notifications/liked_comment.rb
Normal file
|
|
@ -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
|
||||||
|
|
@ -6,16 +6,19 @@ class UserPreference < ApplicationRecord
|
||||||
validate :must_be_valid_email_type
|
validate :must_be_valid_email_type
|
||||||
|
|
||||||
VALID_EMAIL_TYPES =
|
VALID_EMAIL_TYPES =
|
||||||
["someone_reported",
|
%w[
|
||||||
"mentioned",
|
someone_reported
|
||||||
"mentioned_in_comment",
|
mentioned
|
||||||
"comment_on_post",
|
mentioned_in_comment
|
||||||
"private_message",
|
comment_on_post
|
||||||
"started_sharing",
|
private_message
|
||||||
"also_commented",
|
started_sharing
|
||||||
"liked",
|
also_commented
|
||||||
"reshared",
|
liked
|
||||||
"contacts_birthday"]
|
liked_comment
|
||||||
|
reshared
|
||||||
|
contacts_birthday
|
||||||
|
].freeze
|
||||||
|
|
||||||
def must_be_valid_email_type
|
def must_be_valid_email_type
|
||||||
unless VALID_EMAIL_TYPES.include?(self.email_type)
|
unless VALID_EMAIL_TYPES.include?(self.email_type)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
class NotificationService
|
class NotificationService
|
||||||
NOTIFICATION_TYPES = {
|
NOTIFICATION_TYPES = {
|
||||||
Comment => [Notifications::MentionedInComment, Notifications::CommentOnPost, Notifications::AlsoCommented],
|
Comment => [Notifications::MentionedInComment, Notifications::CommentOnPost, Notifications::AlsoCommented],
|
||||||
Like => [Notifications::Liked],
|
Like => [Notifications::Liked, Notifications::LikedComment],
|
||||||
StatusMessage => [Notifications::MentionedInPost],
|
StatusMessage => [Notifications::MentionedInPost],
|
||||||
Conversation => [Notifications::PrivateMessage],
|
Conversation => [Notifications::PrivateMessage],
|
||||||
Message => [Notifications::PrivateMessage],
|
Message => [Notifications::PrivateMessage],
|
||||||
|
|
@ -15,6 +15,7 @@ class NotificationService
|
||||||
"also_commented" => "Notifications::AlsoCommented",
|
"also_commented" => "Notifications::AlsoCommented",
|
||||||
"comment_on_post" => "Notifications::CommentOnPost",
|
"comment_on_post" => "Notifications::CommentOnPost",
|
||||||
"liked" => "Notifications::Liked",
|
"liked" => "Notifications::Liked",
|
||||||
|
"liked_comment" => "Notifications::LikedComment",
|
||||||
"mentioned" => "Notifications::MentionedInPost",
|
"mentioned" => "Notifications::MentionedInPost",
|
||||||
"mentioned_in_comment" => "Notifications::MentionedInComment",
|
"mentioned_in_comment" => "Notifications::MentionedInComment",
|
||||||
"reshared" => "Notifications::Reshared",
|
"reshared" => "Notifications::Reshared",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
.media.stream-element{data: {guid: note.id, type: (types.key(note.type) || "")},
|
.media.stream-element{data: {
|
||||||
class: (note.unread ? "unread" : "read")}
|
guid: note.id,
|
||||||
|
type: (NotificationService::NOTIFICATIONS_JSON_TYPES.key(note.type) || "")
|
||||||
|
},
|
||||||
|
class: (note.unread ? "unread" : "read")}
|
||||||
.unread-toggle.pull-right
|
.unread-toggle.pull-right
|
||||||
%i.entypo-eye{title: (note.unread ? t("notifications.index.mark_read") : t("notifications.index.mark_unread"))}
|
%i.entypo-eye{title: (note.unread ? t("notifications.index.mark_read") : t("notifications.index.mark_unread"))}
|
||||||
- if note.type == "Notifications::StartedSharing" && (!defined?(no_aspect_dropdown) || !no_aspect_dropdown)
|
- if note.type == "Notifications::StartedSharing" && (!defined?(no_aspect_dropdown) || !no_aspect_dropdown)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
.notification_element{data: {guid: note.id, type: (types.key(note.type) || "")},
|
.notification_element{data: {
|
||||||
class: (note.unread ? "unread" : "read")}
|
guid: note.id,
|
||||||
|
type: (NotificationService::NOTIFICATIONS_JSON_TYPES.key(note.type) || "")
|
||||||
|
},
|
||||||
|
class: (note.unread ? "unread" : "read")}
|
||||||
.pull-right.unread-toggle
|
.pull-right.unread-toggle
|
||||||
%i.entypo-eye{title: (note.unread ? t("notifications.index.mark_read") : t("notifications.index.mark_unread"))}
|
%i.entypo-eye{title: (note.unread ? t("notifications.index.mark_read") : t("notifications.index.mark_unread"))}
|
||||||
= person_image_tag note.actors.first, :thumb_small
|
= person_image_tag note.actors.first, :thumb_small
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
- case key
|
- case key
|
||||||
- when "also_commented", "comment_on_post"
|
- when "also_commented", "comment_on_post"
|
||||||
%i.entypo-comment
|
%i.entypo-comment
|
||||||
- when "liked"
|
- when "liked", "liked_comment"
|
||||||
%i.entypo-heart
|
%i.entypo-heart
|
||||||
- when "mentioned", "mentioned_in_comment"
|
- when "mentioned", "mentioned_in_comment"
|
||||||
%span.mentionIcon
|
%span.mentionIcon
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
- if @notification.like_target.public?
|
- if @notification.like_target.public?
|
||||||
%p
|
%p
|
||||||
#{t('.liked', name: @notification.sender_name)}:
|
#{t(".liked", name: @notification.sender_name)}:
|
||||||
= post_message(@notification.like_target, html: true)
|
= post_message(@notification.like_target, html: true)
|
||||||
- else
|
- else
|
||||||
%p
|
%p
|
||||||
#{t('notifier.liked.limited_post', name: @notification.sender_name)}.
|
#{t(".limited_post", name: @notification.sender_name)}.
|
||||||
|
|
||||||
%p
|
%p
|
||||||
= link_to t(".view_post"), post_url(@notification.like_target)
|
= link_to t(".view_post"), post_url(@notification.like_target)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
<%= post_message(@notification.like_target) %>
|
<%= post_message(@notification.like_target) %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= "#{t("notifier.liked.limited_post", name: @notification.sender_name)}." %>
|
<%= "#{t(".limited_post", name: @notification.sender_name)}." %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= t(".view_post") %>
|
<%= t(".view_post") %>
|
||||||
|
|
|
||||||
10
app/views/notifier/liked_comment.html.haml
Normal file
10
app/views/notifier/liked_comment.html.haml
Normal file
|
|
@ -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)
|
||||||
10
app/views/notifier/liked_comment.text.erb
Normal file
10
app/views/notifier/liked_comment.text.erb
Normal file
|
|
@ -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) %>
|
||||||
|
|
@ -153,6 +153,11 @@
|
||||||
= t(".liked")
|
= t(".liked")
|
||||||
.small-horizontal-spacer
|
.small-horizontal-spacer
|
||||||
|
|
||||||
|
= type.label :liked_comment, class: "checkbox-inline" do
|
||||||
|
= type.check_box :liked_comment, {checked: email_prefs["liked_comment"]}, false, true
|
||||||
|
= t(".liked_comment")
|
||||||
|
.small-horizontal-spacer
|
||||||
|
|
||||||
= type.label :reshared, class: "checkbox-inline" do
|
= type.label :reshared, class: "checkbox-inline" do
|
||||||
= type.check_box :reshared, {checked: email_prefs["reshared"]}, false, true
|
= type.check_box :reshared, {checked: email_prefs["reshared"]}, false, true
|
||||||
= t(".reshared")
|
= t(".reshared")
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,3 @@ module Workers
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
8
app/workers/mail/liked_comment.rb
Normal file
8
app/workers/mail/liked_comment.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Workers
|
||||||
|
module Mail
|
||||||
|
class LikedComment < Liked
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -632,22 +632,8 @@ en:
|
||||||
likes:
|
likes:
|
||||||
create:
|
create:
|
||||||
error: "Failed to like."
|
error: "Failed to like."
|
||||||
fail: "Like creation has failed"
|
|
||||||
destroy:
|
destroy:
|
||||||
error: "Failed to unlike."
|
error: "Failed to unlike."
|
||||||
people_like_this:
|
|
||||||
zero: "No likes"
|
|
||||||
one: "%{count} like"
|
|
||||||
other: "%{count} likes"
|
|
||||||
people_like_this_comment:
|
|
||||||
zero: "No likes"
|
|
||||||
one: "%{count} like"
|
|
||||||
other: "%{count} likes"
|
|
||||||
people_dislike_this:
|
|
||||||
zero: "No dislikes"
|
|
||||||
one: "%{count} dislike"
|
|
||||||
other: "%{count} dislikes"
|
|
||||||
not_found: "Post or like not found"
|
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
started_sharing:
|
started_sharing:
|
||||||
|
|
@ -676,6 +662,10 @@ en:
|
||||||
zero: "%{actors} have liked your post %{post_link}."
|
zero: "%{actors} have liked your post %{post_link}."
|
||||||
one: "%{actors} has liked your post %{post_link}."
|
one: "%{actors} has liked your post %{post_link}."
|
||||||
other: "%{actors} have liked your post %{post_link}."
|
other: "%{actors} have liked your post %{post_link}."
|
||||||
|
liked_comment:
|
||||||
|
zero: "%{actors} have liked your comment %{comment_link}."
|
||||||
|
one: "%{actors} has liked your comment %{comment_link}."
|
||||||
|
other: "%{actors} have liked your comment %{comment_link}."
|
||||||
reshared:
|
reshared:
|
||||||
zero: "%{actors} have reshared your post %{post_link}."
|
zero: "%{actors} have reshared your post %{post_link}."
|
||||||
one: "%{actors} has reshared your post %{post_link}."
|
one: "%{actors} has reshared your post %{post_link}."
|
||||||
|
|
@ -688,6 +678,10 @@ en:
|
||||||
zero: "%{actors} commented on a deleted post."
|
zero: "%{actors} commented on a deleted post."
|
||||||
one: "%{actors} commented on a deleted post."
|
one: "%{actors} commented on a deleted post."
|
||||||
other: "%{actors} commented on a deleted post."
|
other: "%{actors} commented on a deleted post."
|
||||||
|
liked_comment_deleted:
|
||||||
|
zero: "%{actors} liked your deleted comment."
|
||||||
|
one: "%{actors} liked your deleted comment."
|
||||||
|
other: "%{actors} liked your deleted comment."
|
||||||
liked_post_deleted:
|
liked_post_deleted:
|
||||||
zero: "%{actors} liked your deleted post."
|
zero: "%{actors} liked your deleted post."
|
||||||
one: "%{actors} liked your deleted post."
|
one: "%{actors} liked your deleted post."
|
||||||
|
|
@ -713,7 +707,8 @@ en:
|
||||||
all_notifications: "All notifications"
|
all_notifications: "All notifications"
|
||||||
also_commented: "Also commented"
|
also_commented: "Also commented"
|
||||||
comment_on_post: "Comment on post"
|
comment_on_post: "Comment on post"
|
||||||
liked: "Liked"
|
liked: "Liked post"
|
||||||
|
liked_comment: "Liked comment"
|
||||||
mentioned: "Mentioned in post"
|
mentioned: "Mentioned in post"
|
||||||
mentioned_in_comment: "Mentioned in comment"
|
mentioned_in_comment: "Mentioned in comment"
|
||||||
reshared: "Reshared"
|
reshared: "Reshared"
|
||||||
|
|
@ -760,6 +755,10 @@ en:
|
||||||
liked: "%{name} liked your post"
|
liked: "%{name} liked your post"
|
||||||
limited_post: "%{name} liked your limited post"
|
limited_post: "%{name} liked your limited post"
|
||||||
view_post: "View post >"
|
view_post: "View post >"
|
||||||
|
liked_comment:
|
||||||
|
liked: "%{name} liked your comment"
|
||||||
|
limited_post: "%{name} liked your comment on a limited post"
|
||||||
|
view_comment: "View comment >"
|
||||||
reshared:
|
reshared:
|
||||||
reshared: "%{name} reshared your post"
|
reshared: "%{name} reshared your post"
|
||||||
view_post: "View post >"
|
view_post: "View post >"
|
||||||
|
|
@ -1298,6 +1297,7 @@ en:
|
||||||
mentioned: "you are mentioned in a post"
|
mentioned: "you are mentioned in a post"
|
||||||
mentioned_in_comment: "you are mentioned in a comment"
|
mentioned_in_comment: "you are mentioned in a comment"
|
||||||
liked: "someone likes your post"
|
liked: "someone likes your post"
|
||||||
|
liked_comment: "someone likes your comment"
|
||||||
reshared: "someone reshares your post"
|
reshared: "someone reshares your post"
|
||||||
comment_on_post: "someone comments on your post"
|
comment_on_post: "someone comments on your post"
|
||||||
also_commented: "someone comments on a post you’ve commented on"
|
also_commented: "someone comments on a post you’ve commented on"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
When "I filter notifications by likes" do
|
When "I filter notifications by likes" do
|
||||||
step %(I follow "Liked" within "#notifications_container .list-group")
|
step %(I follow "Liked post" within "#notifications_container .list-group")
|
||||||
end
|
end
|
||||||
|
|
||||||
When "I filter notifications by mentions" do
|
When "I filter notifications by mentions" do
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,7 @@
|
||||||
"also_commented",
|
"also_commented",
|
||||||
"comment_on_post",
|
"comment_on_post",
|
||||||
"liked",
|
"liked",
|
||||||
|
"liked_comment",
|
||||||
"mentioned",
|
"mentioned",
|
||||||
"mentioned_in_comment",
|
"mentioned_in_comment",
|
||||||
"reshared",
|
"reshared",
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,7 @@ describe NotificationsController, type: :controller do
|
||||||
"comment_on_post" => 0,
|
"comment_on_post" => 0,
|
||||||
"contacts_birthday" => 0,
|
"contacts_birthday" => 0,
|
||||||
"liked" => 0,
|
"liked" => 0,
|
||||||
|
"liked_comment" => 0,
|
||||||
"mentioned" => 0,
|
"mentioned" => 0,
|
||||||
"mentioned_in_comment" => 0,
|
"mentioned_in_comment" => 0,
|
||||||
"reshared" => 0,
|
"reshared" => 0,
|
||||||
|
|
|
||||||
|
|
@ -212,6 +212,27 @@ describe Notifier, type: :mailer do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe ".liked_comment" do
|
||||||
|
before do
|
||||||
|
@post = FactoryBot.create(:status_message, author: alice.person, public: true)
|
||||||
|
@comment = FactoryBot.create(:comment, author: alice.person, post: @post)
|
||||||
|
@like = @comment.likes.create!(author: bob.person)
|
||||||
|
@mail = Notifier.send_notification("liked_comment", alice.id, @like.author.id, @like.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "TO: goes to the right person" do
|
||||||
|
expect(@mail.to).to eq([alice.email])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "BODY: contains the original comment" do
|
||||||
|
expect(@mail.body.encoded).to include(@comment.message.plain_text)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "BODY: contains the name of person liking" do
|
||||||
|
expect(@mail.body.encoded).to include(@like.author.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe ".reshared" do
|
describe ".reshared" do
|
||||||
before do
|
before do
|
||||||
@post = FactoryBot.create(:status_message, author: alice.person, public: true)
|
@post = FactoryBot.create(:status_message, author: alice.person, public: true)
|
||||||
|
|
@ -489,6 +510,42 @@ describe Notifier, type: :mailer do
|
||||||
expect(mail.body.encoded).to include(bob.name)
|
expect(mail.body.encoded).to include(bob.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe ".liked_comment" do
|
||||||
|
let(:comment) { alice.comment!(limited_post, "Totally is") }
|
||||||
|
let(:like) { bob.like_comment!(comment) }
|
||||||
|
let(:mail) { Notifier.send_notification("liked_comment", alice.id, bob.person.id, like.id) }
|
||||||
|
|
||||||
|
it "TO: goes to the right person" do
|
||||||
|
expect(mail.to).to eq([alice.email])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "FROM: contains the sender's name" do
|
||||||
|
expect(mail["From"].to_s).to eq("\"#{pod_name} (#{bob.name})\" <#{AppConfig.mail.sender_address}>")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "FROM: removes emojis from sender's name" do
|
||||||
|
bob.person.profile.update!(first_name: "1️⃣2️3️⃣ Numbers 123", last_name: "👍✅👍🏻Emojis😀😇❄️")
|
||||||
|
expect(mail["From"].to_s).to eq("\"#{pod_name} (Numbers 123 Emojis)\" <#{AppConfig.mail.sender_address}>")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "SUBJECT: does not show the limited comment" do
|
||||||
|
expect(mail.subject).not_to include("Totally is")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "IN-REPLY-TO and REFERENCES: references the liked post" do
|
||||||
|
expect(mail.in_reply_to).to eq("#{limited_post.guid}@#{AppConfig.pod_uri.host}")
|
||||||
|
expect(mail.references).to eq("#{limited_post.guid}@#{AppConfig.pod_uri.host}")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "BODY: does not show the limited post" do
|
||||||
|
expect(mail.body.encoded).not_to include("Totally is")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "BODY: contains the name of person liking" do
|
||||||
|
expect(mail.body.encoded).to include(bob.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".confirm_email" do
|
describe ".confirm_email" do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue