diff --git a/app/models/activity_streams/photo.rb b/app/models/activity_streams/photo.rb index b153cc68d..d6641ddc1 100644 --- a/app/models/activity_streams/photo.rb +++ b/app/models/activity_streams/photo.rb @@ -12,11 +12,13 @@ class ActivityStreams::Photo < Post xml_attr :object_url xml_attr :provider_display_name xml_attr :actor_url + xml_attr :objectId validates_presence_of :image_url, :object_url, :provider_display_name, - :actor_url + :actor_url, + :objectId def socket_to_user(user_or_id, opts={}) #adds aspect_ids to opts if they are not there unless opts[:aspect_ids] @@ -35,6 +37,7 @@ class ActivityStreams::Photo < Post :image_height => json["object"]["image"]["height"], :image_width => json["object"]["image"]["width"], :object_url => json["object"]["url"], + :objectId => json["object"]["id"], :provider_display_name => json["provider"]["displayName"], :actor_url => json["actor"]["url"] diff --git a/db/migrate/20110524184202_add_object_id_to_post.rb b/db/migrate/20110524184202_add_object_id_to_post.rb new file mode 100644 index 000000000..77a707c79 --- /dev/null +++ b/db/migrate/20110524184202_add_object_id_to_post.rb @@ -0,0 +1,10 @@ +class AddObjectIdToPost < ActiveRecord::Migration + def self.up + add_column(:posts, :objectId, :integer) + execute("UPDATE posts SET objectId = object_url") + end + + def self.down + add_column(:posts, :objectId, :integer) + end +end diff --git a/db/schema.rb b/db/schema.rb index 4237ec91d..ce8183c91 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20110518222303) do +ActiveRecord::Schema.define(:version => 20110524184202) do create_table "aspect_memberships", :force => true do |t| t.integer "aspect_id", :null => false @@ -248,6 +248,7 @@ ActiveRecord::Schema.define(:version => 20110518222303) do t.integer "image_width" t.string "provider_display_name" t.string "actor_url" + t.integer "objectId" end add_index "posts", ["author_id"], :name => "index_posts_on_person_id" diff --git a/spec/factories.rb b/spec/factories.rb index b7f7aac31..63216ab6c 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -109,7 +109,8 @@ Factory.define(:activity_streams_photo, :class => ActivityStreams::Photo) do |p| p.image_url "http://example.com/awesome.png" p.image_height 9001 p.image_width 4 - p.object_url "http://example.com/awesome_things.html" + p.object_url "http://example.com/awesome_things.gif" + p.objectId "http://example.com/awesome_things.gif" p.actor_url "http://notcubbi.es/cubber" p.provider_display_name "not cubbies" end diff --git a/spec/models/activity_streams/photo_spec.rb b/spec/models/activity_streams/photo_spec.rb index b48b17ed6..4b856c85c 100644 --- a/spec/models/activity_streams/photo_spec.rb +++ b/spec/models/activity_streams/photo_spec.rb @@ -19,6 +19,7 @@ JSON photo.image_height.should == @json["object"]["image"]["height"] photo.image_width.should == @json["object"]["image"]["width"] photo.object_url.should == @json["object"]["url"] + photo.objectId.should == @json["object"]["id"] photo.provider_display_name.should == @json["provider"]["displayName"] photo.actor_url.should == @json["actor"]["url"]