Skip to content
Snippets Groups Projects
Commit 2902abf3 authored by Israel Barreto Sant'Anna's avatar Israel Barreto Sant'Anna
Browse files

Fixed activities recipient

parent a4ea0e6a
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ class V1::ActivitiesController < ApplicationController ...@@ -8,7 +8,7 @@ class V1::ActivitiesController < ApplicationController
# Render all activities that logged user can see # Render all activities that logged user can see
def index def index
authorize :activity, :index? authorize :activity, :index?
activities = paginate ::ActivityPolicy::Scope.new(current_user, ::PublicActivity::Activity).resolve activities = paginate current_user.activities
render json: activities render json: activities
end end
......
...@@ -21,8 +21,6 @@ class Bookmark < ApplicationRecord ...@@ -21,8 +21,6 @@ class Bookmark < ApplicationRecord
validates_presence_of :user, :bookmarkable validates_presence_of :user, :bookmarkable
validates :user_id, uniqueness: { scope: [:bookmarkable_id, :bookmarkable_type] } validates :user_id, uniqueness: { scope: [:bookmarkable_id, :bookmarkable_type] }
private
def recipient def recipient
bookmarkable bookmarkable
end end
......
...@@ -21,8 +21,6 @@ class CollectionItem < ApplicationRecord ...@@ -21,8 +21,6 @@ class CollectionItem < ApplicationRecord
validates :collection, :collectionable, presence: true validates :collection, :collectionable, presence: true
validates :order, uniqueness: true, allow_blank: true validates :order, uniqueness: true, allow_blank: true
private
def recipient def recipient
collection collection
end end
......
...@@ -30,8 +30,6 @@ class Complaint < ApplicationRecord ...@@ -30,8 +30,6 @@ class Complaint < ApplicationRecord
complaint_reason.reason complaint_reason.reason
end end
private
def recipient def recipient
complainable complainable
end end
......
...@@ -19,8 +19,6 @@ class Download < ApplicationRecord ...@@ -19,8 +19,6 @@ class Download < ApplicationRecord
validates_presence_of :user, :downloadable validates_presence_of :user, :downloadable
private
def recipient def recipient
downloadable downloadable
end end
......
...@@ -20,8 +20,6 @@ class Follow < ApplicationRecord ...@@ -20,8 +20,6 @@ class Follow < ApplicationRecord
validates_presence_of :user, :followable validates_presence_of :user, :followable
validates :user_id, uniqueness: { scope: [:followable_id, :followable_type] } validates :user_id, uniqueness: { scope: [:followable_id, :followable_type] }
private
def recipient def recipient
followable followable
end end
......
...@@ -21,8 +21,6 @@ class Like < ApplicationRecord ...@@ -21,8 +21,6 @@ class Like < ApplicationRecord
validates_presence_of :user, :likeable validates_presence_of :user, :likeable
validates :user_id, uniqueness: { scope: [:likeable_id, :likeable_type] } validates :user_id, uniqueness: { scope: [:likeable_id, :likeable_type] }
private
def recipient def recipient
likeable likeable
end end
......
...@@ -20,13 +20,14 @@ class Rate < ApplicationRecord ...@@ -20,13 +20,14 @@ class Rate < ApplicationRecord
validates_uniqueness_of :user, scope: :review validates_uniqueness_of :user, scope: :review
validate :cannot_rate_your_own, on: :create validate :cannot_rate_your_own, on: :create
def recipient
review
end
private private
def cannot_rate_your_own def cannot_rate_your_own
errors.add(:user_id, "cannot rate your own review") if review.user == user errors.add(:user_id, "cannot rate your own review") if review.user == user
end end
def recipient
review
end
end end
...@@ -61,8 +61,6 @@ class Review < ApplicationRecord ...@@ -61,8 +61,6 @@ class Review < ApplicationRecord
nil nil
end end
private
def recipient def recipient
reviewable reviewable
end end
......
...@@ -18,9 +18,7 @@ class Share < ApplicationRecord ...@@ -18,9 +18,7 @@ class Share < ApplicationRecord
belongs_to :user belongs_to :user
validates_presence_of :user, :shareable validates_presence_of :user, :shareable
private
def recipient def recipient
shareable shareable
end end
......
...@@ -8,8 +8,6 @@ class Tagging < ApplicationRecord ...@@ -8,8 +8,6 @@ class Tagging < ApplicationRecord
validates_presence_of :tagger, :tag, :taggable validates_presence_of :tagger, :tag, :taggable
private
def recipient def recipient
taggable taggable
end end
......
...@@ -23,6 +23,10 @@ class View < ApplicationRecord ...@@ -23,6 +23,10 @@ class View < ApplicationRecord
scope :created_last, ->(user) { where(user: user).order('created_at DESC').limit(1) } scope :created_last, ->(user) { where(user: user).order('created_at DESC').limit(1) }
def recipient
viewable
end
private private
def current_time_greater_than_last def current_time_greater_than_last
...@@ -35,7 +39,4 @@ class View < ApplicationRecord ...@@ -35,7 +39,4 @@ class View < ApplicationRecord
true true
end end
def recipient
viewable
end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment