mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 18:39:52 +01:00
"followed you"
This commit is contained in:
parent
c56177cd10
commit
c9b5947e6b
4 changed files with 25 additions and 19 deletions
2
app/models/notifications/started_following.rb
Normal file
2
app/models/notifications/started_following.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
class Notifications::StartedFollowing < Notification
|
||||
end
|
|
@ -3,4 +3,8 @@ class Relationship < ActiveRecord::Base
|
|||
belongs_to :target, class_name: 'User'
|
||||
validates :source_id, presence: true
|
||||
validates :target_id, presence: true
|
||||
|
||||
def notification_type(*_args)
|
||||
Notifications::StartedFollowing
|
||||
end
|
||||
end
|
||||
|
|
|
@ -56,7 +56,8 @@ class User < ActiveRecord::Base
|
|||
|
||||
# follows an user.
|
||||
def follow(target_user)
|
||||
active_relationships.create(target: target_user)
|
||||
relationship = active_relationships.create(target: target_user)
|
||||
Notification.notify target_user, relationship
|
||||
|
||||
# increment counts
|
||||
increment! :friend_count
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
- Notification.for(current_user).each do |notification|
|
||||
%li.list-group-item
|
||||
.media
|
||||
.pull-left
|
||||
%img.notification--img{src: gravatar_url(notification.target.user)}
|
||||
.media-body
|
||||
%h6.media-heading.notification--user
|
||||
= user_screen_name notification.target.user
|
||||
- case notification.target_type
|
||||
- when "Answer"
|
||||
- case notification.target_type
|
||||
- when "Answer"
|
||||
.pull-left
|
||||
%img.notification--img{src: gravatar_url(notification.target.user)}
|
||||
.media-body
|
||||
%h6.media-heading.notification--user
|
||||
= user_screen_name notification.target.user
|
||||
%p.notification--text
|
||||
answered
|
||||
%a{href: show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.id)}
|
||||
|
@ -20,17 +20,16 @@
|
|||
ago
|
||||
.notification--icon
|
||||
%i.fa.fa-exclamation
|
||||
%li.list-group-item
|
||||
.media
|
||||
.pull-left
|
||||
%img.notification--img
|
||||
.media-body
|
||||
%h6.media-heading.notification--user
|
||||
username
|
||||
%p.notification--text
|
||||
followed you!
|
||||
.notification--icon
|
||||
%i.fa.fa-users
|
||||
- when "Relationship"
|
||||
.pull-left
|
||||
%img.notification--img{src: gravatar_url(notification.target.source)}
|
||||
.media-body
|
||||
%h6.media-heading.notification--user
|
||||
= user_screen_name notification.target.source
|
||||
%p.notification--text
|
||||
followed you!
|
||||
.notification--icon
|
||||
%i.fa.fa-users
|
||||
%li.list-group-item
|
||||
.media
|
||||
.pull-left
|
||||
|
|
Loading…
Reference in a new issue