Skip to content

Commit

Permalink
Working on activity notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Roendal committed May 10, 2011
1 parent 541a137 commit d97b741
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
17 changes: 7 additions & 10 deletions app/models/activity.rb
Expand Up @@ -151,34 +151,31 @@ def title view
def notificable?
is_root? or ['post','update'].include?(root.verb)
end

def notify
return nil if !notificable?
#Avaible verbs: follow, like, make-friend, post, update

actionview = ActivitiesController.new.view_context

case verb
when 'like'
if direct_object.present?
#Like an OBJECT
if _tie.sender!=_tie.receiver
notification_subject = I18n.t("activity.verb.like.Object.notification.subject", :activity => self)
notification_body = capture do
render :partial => 'activities/notifications/like_object', :locales => {:activity => self}
end
notification_body = actionview.render 'activities/notifications/like_object', :locals => {:activity => self}
end
else
#Like a SUBJECT
notification_subject = I18n.t("activity.verb.like." + _tie.receiver_subject.class.to_s + ".notification.subject", :activity => self)
body = capture do
render :partial => 'activities/notifications/like_subject', :locales => {:activity => self}
end
notification_body = actionview.render 'activities/notifications/like_subject', :locals => {:activity => self}
end
when 'follow','make_friend','post','update'
#Follow or Make friend with a SUBJECT or Post or udapte an OBJECT
if _tie.sender!=_tie.receiver
notification_subject = I18n.t("activity.verb." + verb + "." + _tie.receiver_subject.class.to_s + ".notification.subject", :activity => self)
notification_body = capture do
render :partial => 'activities/notifications/' + verb, :locales => {:activity => self}
end
notification_body = actionview.render 'activities/notifications/' + verb, :locals => {:activity => self}
end
end
receipts = _tie.receiver.notify(notification_subject,notification_body)
Expand Down
33 changes: 13 additions & 20 deletions config/locales/en.yml
Expand Up @@ -22,58 +22,51 @@ en:
title: "%{subject} added %{contact} as contact."
message: "%{name} added you as contact."
notification:
subject: "%{name} added you as contact."
body: "%{name} added you as contact."
subject: "%{activity._tie.sender.name} added you as contact."
Group:
title: "%{subject} added %{contact} as contact."
message: "%{name} added you as contact."
notification:
subject: "%{name} added you as contact."
body: "%{name} added you as contact."
subject: "%{activity._tie.sender.name} added you as contact."
like:
User:
title: "%{subject} is a fan of %{contact}."
message: "%{name} is now your fan."
notification:
subject: "%{name} is now your fan."
body: "%{name} is now your fan."
subject: "%{activity._tie.sender.name} is now your fan."
Group:
title: "%{subject} is a fan of %{contact}."
message: "%{name} is now your fan."
notification:
subject: "%{name} is now your fan."
body: "%{name} is now your fan."
subject: "%{activity._tie.sender.name} is now your fan."
Object:
notification:
subject: "%{activity._tie.sender.name} likes %{activity.direct_object}."
make-friend:
User:
title: "%{subject} and %{contact} are now connected."
message: "%{name} also added you as contact."
notification:
subject: "%{name} also added you as contact."
body: "%{name} also added you as contact."
subject: "%{activity._tie.sender.name} also added you as contact."
Group:
title: "%{subject} added %{contact} as contact."
message: "%{name} added you as contact."
notification:
subject: "%{name} added you as contact."
body: "%{name} added you as contact."
subject: "%{activity._tie.sender.name} added you as contact."
post:
User:
notification:
subject: "%{name} has posted something(%{direct_object}) in your wall"
body: "%{name} has posted something(%{direct_object}) in your wall"
subject: "%{activity._tie.sender.name} has posted %{activity.direct_object.to_s} in your wall"
Group:
notification:
subject: "%{name} has posted %{direct_object} in your wall"
body: "%{name} has posted something(%{direct_object}) in your wall"
subject: "%{activity._tie.sender.name} has posted %{activity.direct_object.to_s} in your wall"
update:
User:
notification:
subject: "%{name} has updated %{direct_object} in your wall"
body: "%{name} has updated something(%{direct_object}) in your wall"
subject: "%{activity._tie.sender.name} has updated %{activity.direct_object.to_s} in your wall"
Group:
notification:
subject: "%{name} has updated %{direct_object} in your wall"
body: "%{name} has updated something(%{direct_object}) in your wall"
subject: "%{activity._tie.sender.name} has updated %{activity.direct_object.to_s} in your wall"

avatar:
crop_image: "Crop the uploaded image"
Expand Down

0 comments on commit d97b741

Please sign in to comment.