scope:includes_for_a_stream,includes(:o_embed_cache,{:author=>:profile},:mentions=>{:person=>:profile})#note should include root and photos, but i think those are both on status_message
defself.for_a_stream(max_time,order)
...
...
@@ -47,27 +35,6 @@ class Post < ActiveRecord::Base
# @param [User] user The user that is receiving this post.
# @param [Person] person The person who dispatched this post to the
# @return [void]
defreceive(user,person)
#exists locally, but you dont know about it
#does not exsist locally, and you dont know about it
#exists_locally?
#you know about it, and it is mutable
#you know about it, and it is not mutable
self.class.transactiondo
local_post=persisted_post
iflocal_post&&verify_persisted_post(local_post)
self.receive_persisted(user,person,local_post)
elsif!local_post
self.receive_non_persisted(user,person)
else
Rails.logger.info("event=receive payload_type=#{self.class} update=true status=abort sender=#{self.diaspora_handle} reason='update not from post owner' existing_post=#{self.id}")
execute"UPDATE aspect_visibilities AS av, photos SET av.shareable_type='Photo' WHERE av.shareable_id=photos.id"
execute"UPDATE share_visibilities AS sv, photos SET sv.shareable_type='Photo' WHERE sv.shareable_id=photos.id"
# all your base are belong to us!
execute"DELETE FROM posts WHERE type='Photo'"
end
defself.down
execute<<SQL
INSERT INTO posts
SELECT NULL AS id, author_id, public, diaspora_handle, guid, pending, 'Photo' AS type, text, remote_photo_path, remote_photo_name, random_string,
processed_image, NULL AS youtube_titles, created_at, updated_at, unprocessed_image, NULL AS object_url, NULL AS image_url, NULL AS image_height, NULL AS image_width, NULL AS provider_display_name,
NULL AS actor_url, NULL AS objectId, NULL AS root_guid, status_message_guid, 0 AS likes_count, comments_count, NULL AS o_embed_cache_id