Skip to content
Extraits de code Groupes Projets
Valider 2e5b5e1e rédigé par danielgrippi's avatar danielgrippi
Parcourir les fichiers

request notification emails -> started sharing notification emails

parent 847f4fd2
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 43 ajouts et 113 suppressions
...@@ -15,7 +15,7 @@ class AspectMembershipsController < ApplicationController ...@@ -15,7 +15,7 @@ class AspectMembershipsController < ApplicationController
@contact = current_user.contact_for(Person.where(:id => @person_id).first) @contact = current_user.contact_for(Person.where(:id => @person_id).first)
membership = @contact ? @contact.aspect_memberships.where(:aspect_id => @aspect_id).first : nil membership = @contact ? @contact.aspect_memberships.where(:aspect_id => @aspect_id).first : nil
if membership && membership.destroy if membership && membership.destroy
flash.now[:notice] = I18n.t 'aspect_memberships.destroy.success' flash.now[:notice] = I18n.t 'aspect_memberships.destroy.success'
respond_to do |format| respond_to do |format|
......
...@@ -78,7 +78,7 @@ class PeopleController < ApplicationController ...@@ -78,7 +78,7 @@ class PeopleController < ApplicationController
@contacts_of_contact = [] @contacts_of_contact = []
end end
if (@person != current_user.person) && (!@contact || @contact.mutual) if (@person != current_user.person) && !@contact
@commenting_disabled = true @commenting_disabled = true
else else
@commenting_disabled = false @commenting_disabled = false
......
...@@ -7,12 +7,13 @@ class PostVisibilitiesController < ApplicationController ...@@ -7,12 +7,13 @@ class PostVisibilitiesController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
def update def update
#note :id is garbage #note :id references a postvisibility
@post = Post.where(:id => params[:post_id]).select("id, author_id").first @post = Post.where(:id => params[:post_id]).select("id, author_id").first
@contact = current_user.contact_for( @post.author) @contact = current_user.contact_for(@post.author)
if @vis = PostVisibility.unscoped.where(:contact_id => @contact.id,
:post_id => params[:post_id]).first if @vis = PostVisibility.where(:contact_id => @contact.id,
:post_id => params[:post_id]).first
@vis.hidden = !@vis.hidden @vis.hidden = !@vis.hidden
if @vis.save if @vis.save
render 'update' render 'update'
......
...@@ -8,9 +8,7 @@ module NotificationsHelper ...@@ -8,9 +8,7 @@ module NotificationsHelper
else else
"#{translation(target_type)} #{t('notifications.deleted')} #{t('notifications.post')}" "#{translation(target_type)} #{t('notifications.deleted')} #{t('notifications.post')}"
end end
elsif note.instance_of?(Notifications::RequestAccepted) elsif note.instance_of?(Notifications::StartedSharing)
translation(target_type)
elsif note.instance_of?(Notifications::NewRequest)
translation(target_type) translation(target_type)
elsif note.instance_of?(Notifications::CommentOnPost) elsif note.instance_of?(Notifications::CommentOnPost)
post = Post.where(:id => note.target_id).first post = Post.where(:id => note.target_id).first
......
...@@ -21,31 +21,17 @@ class Notifier < ActionMailer::Base ...@@ -21,31 +21,17 @@ class Notifier < ActionMailer::Base
:subject => I18n.t('notifier.single_admin.subject'), :host => AppConfig[:pod_uri].host) :subject => I18n.t('notifier.single_admin.subject'), :host => AppConfig[:pod_uri].host)
end end
def new_request(recipient_id, sender_id) def started_sharing(recipient_id, sender_id)
@receiver = User.find_by_id(recipient_id) @receiver = User.find_by_id(recipient_id)
@sender = Person.find_by_id(sender_id) @sender = Person.find_by_id(sender_id)
log_mail(recipient_id, sender_id, 'new_request') log_mail(recipient_id, sender_id, 'started_sharing')
attachments.inline['logo_caps.png'] = ATTACHMENT attachments.inline['logo_caps.png'] = ATTACHMENT
I18n.with_locale(@receiver.language) do I18n.with_locale(@receiver.language) do
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>", mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
:subject => I18n.t('notifier.new_request.subject', :from => @sender.name), :host => AppConfig[:pod_uri].host) :subject => I18n.t('notifier.started_sharing.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host)
end
end
def request_accepted(recipient_id, sender_id)
@receiver = User.find_by_id(recipient_id)
@sender = Person.find_by_id(sender_id)
log_mail(recipient_id, sender_id, 'request_accepted')
attachments.inline['logo_caps.png'] = ATTACHMENT
I18n.with_locale(@receiver.language) do
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
:subject => I18n.t('notifier.request_accepted.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host)
end end
end end
......
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
module Job
class MailRequestAcceptance < Base
@queue = :mail
def self.perform_delegate(recipient_id, sender_id, target_id)
Notifier.request_accepted(recipient_id, sender_id).deliver
end
end
end
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
module Job module Job
class MailRequestReceived < Base class MailStartedSharing < Base
@queue = :mail @queue = :mail
def self.perform_delegate(recipient_id, sender_id, target_id) def self.perform_delegate(recipient_id, sender_id, target_id)
Notifier.new_request(recipient_id, sender_id).deliver Notifier.started_sharing(recipient_id, sender_id).deliver
end end
end end
end end
......
class Notifications::NewRequest < Notification class Notifications::StartedSharing < Notification
def mail_job def mail_job
Job::MailRequestReceived Job::MailStartedSharing
end end
def translation_key def translation_key
'new_request' 'started_sharing'
end end
end end
...@@ -53,11 +53,7 @@ class Request < ActiveRecord::Base ...@@ -53,11 +53,7 @@ class Request < ActiveRecord::Base
end end
def notification_type(user, person) def notification_type(user, person)
if Contact.unscoped.where(:user_id => user.id, :person_id => person.id).first Notifications::StartedSharing
Notifications::RequestAccepted
else
Notifications::NewRequest
end
end end
def subscribers(user) def subscribers(user)
......
...@@ -2,14 +2,12 @@ class UserPreference < ActiveRecord::Base ...@@ -2,14 +2,12 @@ class UserPreference < ActiveRecord::Base
belongs_to :user belongs_to :user
validate :must_be_valid_email_type validate :must_be_valid_email_type
VALID_EMAIL_TYPES = VALID_EMAIL_TYPES =
["mentioned", ["mentioned",
"comment_on_post", "comment_on_post",
"private_message", "private_message",
"request_acceptance", "started_sharing",
"request_received",
"also_commented"] "also_commented"]
def must_be_valid_email_type def must_be_valid_email_type
......
...@@ -48,5 +48,5 @@ ...@@ -48,5 +48,5 @@
= notification_people_link(note) = notification_people_link(note)
= object_link(note) = object_link(note)
%span.time= timeago(note.created_at) .time= timeago(note.created_at)
= will_paginate @notifications = will_paginate @notifications
%p
= t('notifier.hello', :name => @receiver.email)
%p
= "#{@sender.name} (#{@sender.diaspora_handle})"
= t('notifier.new_request.just_sent_you')
= t('.try_it_out')
%br
= link_to t('.sign_in'), new_user_session_url
%br
= t('notifier.love')
%br
= t('notifier.diaspora')
!= t('notifier.hello', :name => @receiver.profile.first_name)
!= "#{@sender.name} (#{@sender.diaspora_handle})"
!= t('notifier.new_request.just_sent_you')
!= t('notifier.new_request.try_it_out')
!= "#{t('notifier.new_request.sign_in')}: #{new_user_session_url}"
!= t('notifier.love')
!= t('notifier.diaspora')
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
= t('notifier.hello', :name => @receiver.profile.first_name) = t('notifier.hello', :name => @receiver.profile.first_name)
%p %p
= "#{@sender.name} (#{@sender.diaspora_handle})" = "#{@sender.name} (#{@sender.diaspora_handle})"
= t('.accepted') = t('.sharing')
%br %br
= link_to t('.sign_in'), new_user_session_url = link_to t('.sign_in'), new_user_session_url
......
!= t('notifier.hello', :name => @receiver.profile.first_name) != t('notifier.hello', :name => @receiver.profile.first_name)
!= "#{@sender.name} (#{@sender.diaspora_handle})" != "#{@sender.name} (#{@sender.diaspora_handle})"
!= t('notifier.request_accepted.accepted') != t('notifier.started_sharing.sharing')
!= t('.sign_in') != t('.sign_in')
!= new_user_session_url != new_user_session_url
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
.span-15.last .span-15.last
#author_info #author_info
- if user_signed_in? && !(@contact.persisted? || current_user.person == @person) - if user_signed_in? && !((@contact.persisted? && @contact.mutual) || current_user.person == @person)
.right .right
= link_to t('.start_sharing'), = link_to t('.start_sharing'),
{:controller => "contacts", {:controller => "contacts",
......
...@@ -90,11 +90,6 @@ ...@@ -90,11 +90,6 @@
= type.label t('.comment_on_post') = type.label t('.comment_on_post')
= type.check_box :comment_on_post, {:checked => @email_prefs['comment_on_post']}, false, true = type.check_box :comment_on_post, {:checked => @email_prefs['comment_on_post']}, false, true
%br
%p.checkbox_select
= type.label t('.request_received')
= type.check_box :request_received, {:checked => @email_prefs['request_received']}, false, true
%br %br
%p.checkbox_select %p.checkbox_select
= type.label t('.private_message') = type.label t('.private_message')
...@@ -102,8 +97,8 @@ ...@@ -102,8 +97,8 @@
%br %br
%p.checkbox_select %p.checkbox_select
= type.label t('.request_acceptence') = type.label t('.started_sharing')
= type.check_box :request_acceptance, {:checked => @email_prefs['request_acceptance']}, false, true = type.check_box :started_sharing, {:checked => @email_prefs['started_sharing']}, false, true
%br %br
= f.submit t('.change') = f.submit t('.change')
......
...@@ -282,7 +282,7 @@ en: ...@@ -282,7 +282,7 @@ en:
other: "%{count} people disliked this" other: "%{count} people disliked this"
notifications: notifications:
request_accepted: "accepted your share request." started_sharing: "started sharing with you."
new_request: "offered to share with you." new_request: "offered to share with you."
private_message: "sent you a message." private_message: "sent you a message."
comment_on_post: "commented on your" comment_on_post: "commented on your"
...@@ -313,14 +313,9 @@ en: ...@@ -313,14 +313,9 @@ en:
single_admin: single_admin:
subject: "A message about your Diaspora account:" subject: "A message about your Diaspora account:"
admin: "Your Diaspora administrator" admin: "Your Diaspora administrator"
new_request: started_sharing:
subject: "new Diaspora* contact request from %{from}" subject: "%{name} has started sharing with you on Diaspora*"
just_sent_you: "just sent you a contact request on Diaspora*" sharing: "has started sharing with you!"
try_it_out: "You should really think about checking it out."
sign_in: "Sign in here"
request_accepted:
subject: "%{name} has accepted your contact request on Diaspora*"
accepted: "has accepted your contact request!"
sign_in: "Sign in here" sign_in: "Sign in here"
comment_on_post: comment_on_post:
subject: "%{name} has commented on your post." subject: "%{name} has commented on your post."
...@@ -614,8 +609,7 @@ en: ...@@ -614,8 +609,7 @@ en:
also_commented: "...someone also comments on your contact's post?" also_commented: "...someone also comments on your contact's post?"
comment_on_post: "...someone comments on your post?" comment_on_post: "...someone comments on your post?"
mentioned: "...you are mentioned in a post?" mentioned: "...you are mentioned in a post?"
request_received: "...you receive a new share request?" started_sharing: "...someone starts sharing with you?"
request_acceptence: "...your share request is accepted?"
private_message: "...you receive a private message?" private_message: "...you receive a private message?"
change: "Change" change: "Change"
destroy: "Account successfully closed." destroy: "Account successfully closed."
......
...@@ -7,6 +7,13 @@ class ContactRemovePendingAddMutual < ActiveRecord::Migration ...@@ -7,6 +7,13 @@ class ContactRemovePendingAddMutual < ActiveRecord::Migration
SET contacts.mutual = true SET contacts.mutual = true
WHERE contacts.pending = false WHERE contacts.pending = false
SQL SQL
)
execute( <<SQL
DELETE user_preferences.* FROM user_preferences
WHERE user_preferences.email_type = 'request_acceptance'
OR user_preferences.email_type = 'request_received'
SQL
) )
remove_foreign_key "contacts", "people" remove_foreign_key "contacts", "people"
......
...@@ -28,20 +28,14 @@ Feature: disconnecting users ...@@ -28,20 +28,14 @@ Feature: disconnecting users
| confirm | no contacts | | confirm | no contacts |
| reject | 1 contact | | reject | 1 contact |
Scenario Outline: remove last contact from the contact show page Scenario Outline: remove the contact from the last aspect on the contact show page
When I am on "alice@alice.alice"'s page When I am on "alice@alice.alice"'s page
And I follow "edit aspect membership" And I follow "edit aspect membership"
And I preemptively <accept> the alert
And I press the first ".added" within "#facebox #aspects_list ul > li:first-child" And I press the first ".added" within "#facebox #aspects_list ul > li:first-child"
And I wait for the ajax to finish And I wait for the ajax to finish
And I am on the manage aspects page And I am on the manage aspects page
Then I should see <contacts> in "Besties" Then I should see no contacts in "Besties"
Examples:
| accept | contacts |
| confirm | no contacts |
| reject | 1 contact |
Scenario: remove contact from the aspect edit page Scenario: remove contact from the aspect edit page
When I go to the home page When I go to the home page
...@@ -55,15 +49,3 @@ Feature: disconnecting users ...@@ -55,15 +49,3 @@ Feature: disconnecting users
And I am on the manage aspects page And I am on the manage aspects page
Then I should see no contacts in "Besties" Then I should see no contacts in "Besties"
Scenario: cancel removing contact from the contact show page
When I go to the home page
And I press the first ".contact-count" within "#aspect_listings"
And I wait for the ajax to finish
And I preemptively reject the alert
And I press the first ".added" within "#facebox .contact_list ul > li:first-child"
And I wait for the ajax to finish
And I am on the manage aspects page
Then I should see 1 contact in "Besties"
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter