public
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
Got feed activity working for new Connection activities
Michael Hartl (author)
Wed Apr 23 11:52:25 -0700 2008
commit  1b2e36bb4610601a743b11342472289daf565a4e
tree    1be69f0f3361a5ad8eb4872ef7b1ce8637eec314
parent  6b3a197538f400d407569593c0e07daf2a13e66c
...
13
14
15
 
16
17
18
...
67
68
69
 
70
71
72
...
100
101
102
103
104
105
106
107
108
109
 
 
 
 
 
 
 
 
 
 
 
 
 
110
111
...
13
14
15
16
17
18
19
...
68
69
70
71
72
73
74
...
102
103
104
 
 
 
 
 
 
 
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
0
@@ -13,6 +13,7 @@
0
 #
0
 
0
 class Connection < ActiveRecord::Base
0
+ extend ActivityLogger
0
   extend PreferencesHelper
0
   
0
   belongs_to :person
0
@@ -67,6 +68,7 @@ class Connection < ActiveRecord::Base
0
         accept_one_side(person, contact, accepted_at)
0
         accept_one_side(contact, person, accepted_at)
0
       end
0
+ log_activity(conn(person, contact))
0
     end
0
     
0
     def connect(person, contact, mail = global_prefs.email_notifications)
0
@@ -100,12 +102,18 @@ class Connection < ActiveRecord::Base
0
   
0
   private
0
   
0
- # Update the db with one side of an accepted connection request.
0
- def self.accept_one_side(person, contact, accepted_at)
0
- # Sometimes person is just an ID, which fails for the Activity creation.
0
- person = Person.find(person) unless person.is_a?(Person)
0
- conn = conn(person, contact)
0
- conn.update_attributes!(:status => ACCEPTED, :accepted_at => accepted_at)
0
- Activity.create!(:item => conn, :person => person)
0
+ class << self
0
+ # Update the db with one side of an accepted connection request.
0
+ def accept_one_side(person, contact, accepted_at)
0
+ conn = conn(person, contact)
0
+ conn.update_attributes!(:status => ACCEPTED,
0
+ :accepted_at => accepted_at)
0
+ end
0
+
0
+ def log_activity(conn)
0
+ activity = Activity.create!(:item => conn, :person => conn.person)
0
+ add_activities(:activity => activity, :person => conn.person)
0
+ add_activities(:activity => activity, :person => conn.contact)
0
+ end
0
   end
0
 end
...
64
65
66
67
 
68
69
70
...
117
118
119
120
121
122
123
...
64
65
66
 
67
68
69
70
...
117
118
119
 
120
121
122
0
@@ -64,7 +64,7 @@ class Person < ActiveRecord::Base
0
   has_many :feeds
0
   has_many :activities, :through => :feeds, :order => 'created_at DESC',
0
                                             :limit => FEED_SIZE,
0
- :group => 'activities.id'
0
+ :uniq => true
0
 
0
   validates_presence_of :email, :name
0
   validates_presence_of :password, :if => :password_required?
0
@@ -117,7 +117,6 @@ class Person < ActiveRecord::Base
0
   # converts params[:id] into an int, and in Ruby
0
   # '1-michael-hartl'.to_i == 1
0
   def to_param
0
- "#{id}-#{name.downcase.split.join('-')}"
0
     "#{id}-#{name.to_safe_uri}"
0
   end
0
 

Comments

    No one has commented yet.