social_stream 0.26.2 → 0.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/base/app/assets/images/btn/public.png +0 -0
  2. data/base/app/assets/images/btn/restricted.png +0 -0
  3. data/base/app/assets/javascripts/social_stream.timeline.js +2 -0
  4. data/base/app/assets/javascripts/social_stream.wall.js.erb +10 -1
  5. data/base/app/assets/stylesheets/activities.css.scss.erb +13 -2
  6. data/base/app/assets/stylesheets/base.css.scss +1 -1
  7. data/base/app/controllers/audience_controller.rb +16 -0
  8. data/base/app/models/activity.rb +111 -39
  9. data/base/app/models/activity_object.rb +1 -9
  10. data/base/app/models/actor.rb +42 -53
  11. data/base/app/models/contact.rb +0 -21
  12. data/base/app/models/tie.rb +1 -1
  13. data/base/app/views/activities/_new.html.erb +2 -2
  14. data/base/app/views/activities/_options.html.erb +7 -1
  15. data/base/app/views/audience/_list.html.erb +8 -0
  16. data/base/app/views/audience/index.js.erb +1 -0
  17. data/base/config/locales/en.yml +1 -0
  18. data/base/config/locales/es.yml +1 -0
  19. data/base/config/routes.rb +2 -0
  20. data/base/db/migrate/20120526171311_remove_activity_channels.rb +35 -0
  21. data/base/lib/social_stream-base.rb +0 -1
  22. data/base/lib/social_stream/ability/base.rb +3 -1
  23. data/base/lib/social_stream/base/engine.rb +0 -1
  24. data/base/lib/social_stream/base/version.rb +1 -1
  25. data/base/lib/tasks/db/populate.rake +6 -4
  26. data/base/spec/controllers/audience_controller_spec.rb +40 -0
  27. data/base/spec/controllers/comments_controller_spec.rb +3 -3
  28. data/base/spec/factories/activity.rb +12 -6
  29. data/base/spec/models/tie_spec.rb +7 -4
  30. data/documents/lib/social_stream/documents/version.rb +1 -1
  31. data/documents/social_stream-documents.gemspec +1 -1
  32. data/events/app/assets/stylesheets/events.css.scss +3 -8
  33. data/events/app/views/events/_event.html.erb +5 -2
  34. data/events/config/locales/en.yml +1 -0
  35. data/events/config/locales/es.yml +1 -0
  36. data/events/lib/social_stream/events/version.rb +1 -1
  37. data/events/social_stream-events.gemspec +1 -1
  38. data/lib/social_stream/version.rb +1 -1
  39. data/linkser/lib/social_stream/linkser/version.rb +1 -1
  40. data/linkser/social_stream-linkser.gemspec +1 -1
  41. data/presence/lib/social_stream/presence/version.rb +1 -1
  42. data/presence/social_stream-presence.gemspec +1 -1
  43. data/social_stream.gemspec +5 -5
  44. metadata +19 -15
  45. data/base/app/assets/images/btn/btn_security.png +0 -0
  46. data/base/app/models/channel.rb +0 -64
  47. data/base/lib/social_stream/models/channeled.rb +0 -56
@@ -31,6 +31,8 @@ SocialStream.Timeline = (function(SS, $, undefined){
31
31
  $(fullId).hide();
32
32
  $(summaryId).tipsy({
33
33
  html: true,
34
+ hoverable: true,
35
+ opacity: 0.95,
34
36
  title: function(){
35
37
  return $(this).siblings('.activity_audience').html();
36
38
  }
@@ -38,6 +38,12 @@ SocialStream.Wall = (function(SS, $, undefined){
38
38
  });
39
39
  }
40
40
 
41
+ var changeSecurityImage = function(type) {
42
+ $('#security_chzn .chzn-choices').
43
+ css('background-image', 'url(<%= asset_path('btn/') %>' + type + '.png)');
44
+ }
45
+
46
+
41
47
  var initSecuritySelect = function(){
42
48
  var default_security_width = '100px';
43
49
 
@@ -63,6 +69,9 @@ SocialStream.Wall = (function(SS, $, undefined){
63
69
  chosen.results_update_field();
64
70
  }
65
71
  }
72
+ changeSecurityImage('public');
73
+ } else {
74
+ changeSecurityImage('restricted');
66
75
  }
67
76
  });
68
77
 
@@ -145,6 +154,6 @@ SocialStream.Wall = (function(SS, $, undefined){
145
154
  addInitCallback: addInitCallback,
146
155
  init: init,
147
156
  activateAntiRebounds: activateAntiRebounds,
148
- unblockForms: unblockForms
157
+ unblockForms: unblockForms
149
158
  };
150
159
  }) (SocialStream, jQuery)
@@ -27,7 +27,7 @@
27
27
 
28
28
  #security_chzn .chzn-choices {
29
29
  padding-left: 20px;
30
- background: url('btn/btn_security.png') no-repeat 10px center;
30
+ background: url('btn/restricted.png') no-repeat 10px center;
31
31
  }
32
32
  /******************* WALL - ACTIVITY ***************/
33
33
  .super_activity{width: 95%;}
@@ -55,7 +55,6 @@
55
55
 
56
56
  .security, .post_time_ago, .verb_comment, .verb_like, .verb_comment, .verb_delete{ display: inline-block;}
57
57
 
58
-
59
58
  /************* ACTIVITY - FOOTER *********/
60
59
  .space_comments { padding-top: 1px; padding-bottom: 1px;}
61
60
  .space_activities { text-align:center; padding: 0px 0px 0px 1px; width:100%;}
@@ -88,3 +87,15 @@
88
87
  .input_new_comments_container{min-height: 30px; position: relative; }
89
88
 
90
89
  .activity_likes{ margin-bottom: 2px; }
90
+
91
+ .timeline-130 {
92
+ width: 130px;
93
+ margin: 10px;
94
+ float: left;
95
+ }
96
+
97
+ .audience_logo {
98
+ padding: 2px;
99
+ display: inline-block;
100
+ }
101
+
@@ -137,7 +137,7 @@ div.chzn-container ul.chzn-choices li.search-field input{ cursor:pointer;}
137
137
 
138
138
  /*************MENU ICON SECTION**********/
139
139
  .menu_header{ border-bottom: thin solid $separation-color; width:14.5em; padding-left:3px; padding-right:3px;}
140
- .menu_icon{ vertical-align: middle; padding-bottom: 3px; padding-right: 3px; padding-left: 3px;
140
+ .menu_icon{ vertical-align: middle; padding-bottom: 3px; padding-right: 2px; padding-left: 2px;
141
141
  display: inline-block;}
142
142
 
143
143
  /*************SPACES SECTION *************/
@@ -0,0 +1,16 @@
1
+ class AudienceController < ApplicationController
2
+ before_filter :read_activity
3
+
4
+ respond_to :js
5
+
6
+ def index
7
+ end
8
+
9
+ private
10
+
11
+ def read_activity
12
+ @activity = Activity.find params[:activity_id]
13
+
14
+ authorize! :read, @activity
15
+ end
16
+ end
@@ -1,21 +1,32 @@
1
1
  # Activities follow the {Activity Streams}[http://activitystrea.ms/] standard.
2
2
  #
3
- # == {Activity Activities}, {Channel Channels} and Audiences
4
- # Every activity is attached to a {Channel}, which defines the sender and the receiver of the {Activity}
3
+ # Every {Activity} has an {#author}, {#user_author} and {#owner}
5
4
  #
6
- # Besides, the activity is attached to one or more relations, which define the audience of the activity,
7
- # in other words, the {actors Actor} that can reach it and their {permissions Permission}
5
+ # author:: Is the {SocialStream::Models::Subject subject} that originated
6
+ # the activity. The entity that posted something, liked, etc..
8
7
  #
9
- # == Wall
10
- # The Activity.wall(args) scope provides all the activities appearing in a wall
8
+ # user_author:: The {User} logged in when the {Activity} was created.
9
+ # If the {User} has not changed the session to represent
10
+ # other entity (a {Group} for example), the user_author
11
+ # will be the same as the author.
11
12
  #
12
- # There are two types of wall, :home and :profile. Check {Actor#wall} for more information
13
+ # owner:: The {SocialStream::Models::Subject subject} whose wall was posted
14
+ # or comment was liked, etc..
15
+ #
16
+ # == {Audience Audiences} and visibility
17
+ # Each activity is attached to one or more {Relation relations}, which define
18
+ # the {SocialStream::Models::Subject subject} that can reach the activity
19
+ #
20
+ # In the case of a {Relation::Public public relation} everyone will be
21
+ # able to see the activity.
22
+ #
23
+ # In the case of {Relation::Custom custom relations}, only the subjects
24
+ # that have a {Tie} with that relation (in other words, the contacts that
25
+ # have been added as friends with that relation} will be able to reach the {Activity}
13
26
  #
14
- include NotificationsHelper
15
-
16
27
  class Activity < ActiveRecord::Base
17
- # See {SocialStream::Models::Channeled}
18
- channeled
28
+ # FIXME: this does not follow the Rails way
29
+ include NotificationsHelper
19
30
 
20
31
  # This has to be declared before 'has_ancestry' to work around rails issue #670
21
32
  # See: https://github.com/rails/rails/issues/670
@@ -27,6 +38,13 @@ class Activity < ActiveRecord::Base
27
38
 
28
39
  belongs_to :activity_verb
29
40
 
41
+ belongs_to :author,
42
+ :class_name => "Actor"
43
+ belongs_to :owner,
44
+ :class_name => "Actor"
45
+ belongs_to :user_author,
46
+ :class_name => "Actor"
47
+
30
48
  has_many :audiences, :dependent => :destroy
31
49
  has_many :relations, :through => :audiences
32
50
 
@@ -35,10 +53,26 @@ class Activity < ActiveRecord::Base
35
53
  has_many :activity_objects,
36
54
  :through => :activity_object_activities
37
55
 
56
+ scope :authored_by, lambda { |subject|
57
+ where(:author_id => Actor.normalize_id(subject))
58
+ }
59
+ scope :owned_by, lambda { |subject|
60
+ where(:owner_id => Actor.normalize_id(subject))
61
+ }
62
+ scope :authored_or_owned_by, lambda { |subjects|
63
+ ids = Actor.normalize_id(subjects)
64
+
65
+ where(arel_table[:author_id].in(ids).or(arel_table[:owner_id].in(ids)))
66
+ }
67
+
68
+ scope :shared_with, lambda { |subject|
69
+ joins(:audiences).
70
+ merge(Audience.where(:relation_id => Relation.ids_shared_with(subject)))
71
+ }
72
+
38
73
  scope :wall, lambda { |args|
39
74
  q =
40
75
  select("DISTINCT activities.*").
41
- joins(:channel).
42
76
  joins(:audiences).
43
77
  joins(:relations).
44
78
  roots
@@ -48,14 +82,13 @@ class Activity < ActiveRecord::Base
48
82
  where('activity_objects.object_type' => args[:object_type])
49
83
  end
50
84
 
51
- channels = Channel.arel_table
52
85
  audiences = Audience.arel_table
53
86
  relations = Relation.arel_table
54
87
 
55
88
  owner_conditions =
56
- channels[:author_id].eq(Actor.normalize_id(args[:owner])).
57
- or(channels[:user_author_id].eq(Actor.normalize_id(args[:owner]))).
58
- or(channels[:owner_id].eq(Actor.normalize_id(args[:owner])))
89
+ arel_table[:author_id].eq(Actor.normalize_id(args[:owner])).
90
+ or(arel_table[:user_author_id].eq(Actor.normalize_id(args[:owner]))).
91
+ or(arel_table[:owner_id].eq(Actor.normalize_id(args[:owner])))
59
92
 
60
93
  audience_conditions =
61
94
  audiences[:relation_id].in(args[:relation_ids]).
@@ -65,16 +98,16 @@ class Activity < ActiveRecord::Base
65
98
  case args[:type]
66
99
  when :home
67
100
  followed_conditions =
68
- channels[:author_id].in(args[:followed]).
69
- or(channels[:owner_id].in(args[:followed]))
101
+ arel_table[:author_id].in(args[:followed]).
102
+ or(arel_table[:owner_id].in(args[:followed]))
70
103
 
71
104
  owner_conditions.
72
105
  or(followed_conditions.and(audience_conditions))
73
106
  when :profile
74
107
  if args[:for].present?
75
108
  visitor_conditions =
76
- channels[:author_id].eq(Actor.normalize_id(args[:for])).
77
- or(channels[:owner_id].eq(Actor.normalize_id(args[:for])))
109
+ arel_table[:author_id].eq(Actor.normalize_id(args[:for])).
110
+ or(arel_table[:owner_id].eq(Actor.normalize_id(args[:for])))
78
111
 
79
112
  owner_conditions.
80
113
  and(visitor_conditions.or(audience_conditions))
@@ -93,7 +126,7 @@ class Activity < ActiveRecord::Base
93
126
  after_create :increment_like_count
94
127
  after_destroy :decrement_like_count, :delete_notifications
95
128
 
96
- validates_presence_of :relations
129
+ validates_presence_of :author_id, :user_author_id, :owner_id, :relations
97
130
 
98
131
  #For now, it should be the last one
99
132
  #FIXME
@@ -109,12 +142,37 @@ class Activity < ActiveRecord::Base
109
142
  self.activity_verb = ActivityVerb[name]
110
143
  end
111
144
 
145
+ # The {SocialStream::Models::Subject subject} author
146
+ def author_subject
147
+ author.subject
148
+ end
149
+
150
+ # The {SocialStream::Models::Subject subject} owner
151
+ def owner_subject
152
+ owner.subject
153
+ end
154
+
155
+ # The {SocialStream::Models::Subject subject} user actor
156
+ def user_author_subject
157
+ user_author.subject
158
+ end
159
+
160
+ # Does this {Activity} have the same sender and receiver?
161
+ def reflexive?
162
+ author_id == owner_id
163
+ end
164
+
165
+ # Is the author represented in this {Activity}?
166
+ def represented_author?
167
+ author_id != user_author_id
168
+ end
169
+
112
170
  # The {Actor} author of this activity
113
171
  #
114
172
  # This method provides the {Actor}. Use {#sender_subject} for the {SocialStream::Models::Subject Subject}
115
173
  # ({User}, {Group}, etc..)
116
174
  def sender
117
- channel.author
175
+ author
118
176
  end
119
177
 
120
178
  # The {SocialStream::Models::Subject Subject} author of this activity
@@ -122,7 +180,7 @@ class Activity < ActiveRecord::Base
122
180
  # This method provides the {SocialStream::Models::Subject Subject} ({User}, {Group}, etc...).
123
181
  # Use {#sender} for the {Actor}.
124
182
  def sender_subject
125
- channel.author_subject
183
+ author_subject
126
184
  end
127
185
 
128
186
  # The wall where the activity is shown belongs to receiver
@@ -130,7 +188,7 @@ class Activity < ActiveRecord::Base
130
188
  # This method provides the {Actor}. Use {#receiver_subject} for the {SocialStream::Models::Subject Subject}
131
189
  # ({User}, {Group}, etc..)
132
190
  def receiver
133
- channel.owner
191
+ owner
134
192
  end
135
193
 
136
194
  # The wall where the activity is shown belongs to the receiver
@@ -138,7 +196,7 @@ class Activity < ActiveRecord::Base
138
196
  # This method provides the {SocialStream::Models::Subject Subject} ({User}, {Group}, etc...).
139
197
  # Use {#receiver} for the {Actor}.
140
198
  def receiver_subject
141
- channel.owner_subject
199
+ owner_subject
142
200
  end
143
201
 
144
202
  # The comments about this activity
@@ -152,7 +210,7 @@ class Activity < ActiveRecord::Base
152
210
  end
153
211
 
154
212
  def liked_by(user) #:nodoc:
155
- likes.joins(:channel).merge(Channel.subject_authored_by(user))
213
+ likes.authored_by(user)
156
214
  end
157
215
 
158
216
  # Does user like this activity?
@@ -162,12 +220,11 @@ class Activity < ActiveRecord::Base
162
220
 
163
221
  # Build a new children activity where subject like this
164
222
  def new_like(subject, user)
165
- channel = Channel.new :author => Actor.normalize(subject),
166
- :user_author => Actor.normalize(user),
167
- :owner => owner
168
- a = children.new :verb => "like",
169
- :channel => channel,
170
- :relation_ids => self.relation_ids
223
+ a = children.new :verb => "like",
224
+ :author_id => Actor.normalize_id(subject),
225
+ :user_author_id => Actor.normalize_id(user),
226
+ :owner_id => owner_id,
227
+ :relation_ids => self.relation_ids
171
228
 
172
229
  if direct_activity_object.present?
173
230
  a.activity_objects << direct_activity_object
@@ -218,7 +275,7 @@ class Activity < ActiveRecord::Base
218
275
  participants.each do |p|
219
276
  p.notify(notification_subject, "Youre not supposed to see this", self) unless p == sender
220
277
  end
221
- elsif ['like','follow','make-friend','post','update'].include? verb and !channel.reflexive?
278
+ elsif ['like','follow','make-friend','post','update'].include? verb and !reflexive?
222
279
  receiver.notify(notification_subject, "Youre not supposed to see this", self)
223
280
  end
224
281
  true
@@ -241,15 +298,15 @@ class Activity < ActiveRecord::Base
241
298
 
242
299
  # Is subject allowed to perform action on this {Activity}?
243
300
  def allow?(subject, action)
244
- return false if channel.blank?
301
+ return false if author.blank?
245
302
 
246
303
  case action
247
304
  when 'create'
248
- return false if subject.blank? || channel.author_id != Actor.normalize_id(subject)
305
+ return false if subject.blank? || author_id != Actor.normalize_id(subject)
249
306
 
250
307
  rels = Relation.normalize(relation_ids)
251
308
 
252
- own_rels = rels.select{ |r| r.actor_id == channel.author_id }
309
+ own_rels = rels.select{ |r| r.actor_id == author_id }
253
310
  # Consider Relation::Single as own_relations
254
311
  own_rels += rels.select{ |r| r.is_a?(Relation::Single) }
255
312
 
@@ -268,12 +325,12 @@ class Activity < ActiveRecord::Base
268
325
 
269
326
  return false if subject.blank?
270
327
 
271
- return true if [channel.author_id, channel.owner_id].include?(Actor.normalize_id(subject))
328
+ return true if [author_id, owner_id].include?(Actor.normalize_id(subject))
272
329
  when 'update'
273
- return true if [channel.author_id, channel.owner_id].include?(Actor.normalize_id(subject))
330
+ return true if [author_id, owner_id].include?(Actor.normalize_id(subject))
274
331
  when 'destroy'
275
332
  # We only allow destroying to sender and receiver by now
276
- return [channel.author_id, channel.owner_id].include?(Actor.normalize_id(subject))
333
+ return [author_id, owner_id].include?(Actor.normalize_id(subject))
277
334
  end
278
335
 
279
336
  Relation.
@@ -298,6 +355,21 @@ class Activity < ActiveRecord::Base
298
355
  allow?(subject, 'update')
299
356
  end
300
357
 
358
+ # Is this activity public?
359
+ def public?
360
+ relation_ids.include? Relation::Public.instance.id
361
+ end
362
+
363
+ # The {Actor Actors} this activity is shared with
364
+ def audience
365
+ raise "Cannot get the audience of a public activity!" if public?
366
+
367
+ [ author, user_author, owner ].uniq |
368
+ Actor.
369
+ joins(:received_ties).
370
+ merge(Tie.where(:relation_id => relation_ids))
371
+ end
372
+
301
373
  # The {Relation} with which activity is shared
302
374
  def audience_in_words(subject, options = {})
303
375
  options[:details] ||= :full
@@ -217,15 +217,7 @@ class ActivityObject < ActiveRecord::Base
217
217
 
218
218
  @valid_relations = true
219
219
 
220
- self.relation_ids =
221
- if SocialStream.relation_model == :custom
222
- owner.
223
- relations.
224
- allowing('read', 'activity').
225
- map(&:id)
226
- else
227
- Array.wrap Relation::Public.instance.id
228
- end
220
+ self.relation_ids = owner.activity_relation_ids
229
221
  end
230
222
 
231
223
  # validate method
@@ -73,16 +73,6 @@ class Actor < ActiveRecord::Base
73
73
  has_many :relations,
74
74
  :dependent => :destroy
75
75
 
76
- has_many :authored_channels,
77
- :class_name => "Channel",
78
- :foreign_key => :author_id,
79
- :dependent => :destroy
80
-
81
- has_many :owned_channels,
82
- :class_name => "Channel",
83
- :foreign_key => :owner_id,
84
- :dependent => :destroy
85
-
86
76
  has_many :sent_actions,
87
77
  :class_name => "ActivityAction",
88
78
  :dependent => :destroy
@@ -328,11 +318,6 @@ class Actor < ActiveRecord::Base
328
318
  ties_to(subject).with_permissions(action, object).any?
329
319
  end
330
320
 
331
- # The {Channel} of this {Actor} to self (totally close!)
332
- def self_channel
333
- Channel.find_or_create_by_author_id_and_user_author_id_and_owner_id id, id, id
334
- end
335
-
336
321
  # Return the {ActivityAction} model to an {ActivityObject}
337
322
  def action_to(activity_object)
338
323
  sent_actions.received_by(activity_object).first
@@ -391,12 +376,26 @@ class Actor < ActiveRecord::Base
391
376
  any?
392
377
  end
393
378
 
394
- # An {Activity} can be shared with multiple {audicences Audience}, which corresponds to a {Relation}.
395
- #
396
- # This method returns all the {relations Relation} that this actor can use to broadcast an Activity
379
+ # The default {Relation Relations} for sharing an {Activity} owned
380
+ # by this {Actor}
381
+ def activity_relations
382
+ SocialStream.relation_model == :custom ?
383
+ relations.
384
+ allowing('read', 'activity') :
385
+ [ Relation::Public.instance ]
386
+ end
387
+
388
+ # The ids of the default {Relation Relations} for sharing an {Activity}
389
+ # owned by this {Actor}
390
+ def activity_relation_ids
391
+ activity_relations.map(&:id)
392
+ end
393
+
394
+ # This method returns all the {relations Relation} that subject can choose to broadcast an Activity in this {Actor}'s wall
397
395
  #
396
+ # See {Activity} on how they can be shared with multiple {audicences Audience}, which corresponds to a {Relation}.
398
397
  #
399
- def activity_relations(subject, options = {})
398
+ def activity_relations_for(subject, options = {})
400
399
  if Actor.normalize(subject) == self
401
400
  return relation_customs + Array.wrap(Relation::Public.instance)
402
401
  else
@@ -404,9 +403,9 @@ class Actor < ActiveRecord::Base
404
403
  end
405
404
  end
406
405
 
407
- # Are there any activity_relations present?
408
- def activity_relations?(*args)
409
- activity_relations(*args).any?
406
+ # Are {#activity_relations} available for subject?
407
+ def activity_relations_for?(subject, options = {})
408
+ activity_relations(subject, options).any?
410
409
  end
411
410
 
412
411
  # Is this {Actor} allowed to create a comment on activity?
@@ -459,37 +458,30 @@ class Actor < ActiveRecord::Base
459
458
  # the wall for members of the group.
460
459
  #
461
460
  def wall(type, options = {})
462
- args = {}
463
-
464
- args[:type] = type
465
- args[:owner] = self
466
- # Preserve this options
467
- [ :for, :object_type ].each do |opt|
468
- args[opt] = options[opt]
469
- end
461
+ options[:for] = self if type == :home
470
462
 
471
- if type == :home
472
- args[:followed] = Actor.followed_by(self).map(&:id)
473
- end
463
+ wall =
464
+ Activity.
465
+ select("DISTINCT activities.*").
466
+ roots.
467
+ includes(:author, :user_author, :owner, :activity_objects, :activity_verb, :relations)
474
468
 
475
- # TODO: this is not scalling for sure. We must use a fact table in the future
476
- args[:relation_ids] =
469
+ actor_ids =
477
470
  case type
478
471
  when :home
479
- # The relations from followings that can be read
480
- Relation.allow(self, 'read', 'activity').map(&:id)
472
+ following_actor_and_self_ids
481
473
  when :profile
482
- # FIXME: options[:relation]
483
- #
484
- # The relations that can be read by options[:for]
485
- options[:for].present? ?
486
- Relation.allow(options[:for], 'read', 'activity').map(&:id) :
487
- []
474
+ id
488
475
  else
489
476
  raise "Unknown type of wall: #{ type }"
490
477
  end
491
478
 
492
- Activity.wall args
479
+ wall = wall.authored_or_owned_by(actor_ids)
480
+
481
+ # Authentication
482
+ wall = wall.shared_with(options[:for])
483
+
484
+ wall = wall.order("created_at desc")
493
485
  end
494
486
 
495
487
  def logo
@@ -507,7 +499,7 @@ class Actor < ActiveRecord::Base
507
499
  end
508
500
 
509
501
  def liked_by(subject) #:nodoc:
510
- likes.joins(:channel).merge(Channel.subject_authored_by(subject))
502
+ likes.authored_by(subject)
511
503
  end
512
504
 
513
505
  # Does subject like this {Actor}?
@@ -517,14 +509,11 @@ class Actor < ActiveRecord::Base
517
509
 
518
510
  # Build a new activity where subject like this
519
511
  def new_like(subject, user)
520
- channel =
521
- Channel.
522
- find_or_create_by_author_id_and_user_author_id_and_owner_id Actor.normalize_id(subject),
523
- Actor.normalize_id(user),
524
- id
525
- a = Activity.new :verb => "like",
526
- :channel => channel,
527
- :relation_ids => Array(Relation::Public.instance.id)
512
+ a = Activity.new :verb => "like",
513
+ :author_id => Actor.normalize_id(subject),
514
+ :user_author_id => Actor.normalize_id(user),
515
+ :owner_id => id,
516
+ :relation_ids => Array(Relation::Public.instance.id)
528
517
 
529
518
  a.activity_objects << activity_object
530
519