about summary refs log tree commit diff
path: root/app/serializers/activitypub
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-03-28 04:44:59 +0100
committerGitHub <noreply@github.com>2019-03-28 04:44:59 +0100
commitf1bc90ab508cbdebc646324f87db48a9e80036f4 (patch)
treec9e6fff16d8e69ed99e7010cabd4d83d595e5493 /app/serializers/activitypub
parentf46f67d984e4e2deb4bf98cd5c5de813caf66eca (diff)
Rename :poll to :preloadable_poll and :owned_poll to :poll on Status (#10401)
Also, fix some n+1 queries

Resolve #10365
Diffstat (limited to 'app/serializers/activitypub')
-rw-r--r--app/serializers/activitypub/note_serializer.rb14
-rw-r--r--app/serializers/activitypub/update_poll_serializer.rb2
2 files changed, 8 insertions, 8 deletions
diff --git a/app/serializers/activitypub/note_serializer.rb b/app/serializers/activitypub/note_serializer.rb
index 0666bea5a..d11cfa59a 100644
--- a/app/serializers/activitypub/note_serializer.rb
+++ b/app/serializers/activitypub/note_serializer.rb
@@ -29,7 +29,7 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
   end
 
   def type
-    object.poll ? 'Question' : 'Note'
+    object.preloadable_poll ? 'Question' : 'Note'
   end
 
   def summary
@@ -125,29 +125,29 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
   end
 
   def poll_options
-    object.poll.loaded_options
+    object.preloadable_poll.loaded_options
   end
 
   def poll_and_multiple?
-    object.poll&.multiple?
+    object.preloadable_poll&.multiple?
   end
 
   def poll_and_not_multiple?
-    object.poll && !object.poll.multiple?
+    object.preloadable_poll && !object.preloadable_poll.multiple?
   end
 
   def closed
-    object.poll.expires_at.iso8601
+    object.preloadable_poll.expires_at.iso8601
   end
 
   alias end_time closed
 
   def poll_and_expires?
-    object.poll&.expires_at&.present?
+    object.preloadable_poll&.expires_at&.present?
   end
 
   def poll_and_expired?
-    object.poll&.expired?
+    object.preloadable_poll&.expired?
   end
 
   class MediaAttachmentSerializer < ActivityPub::Serializer
diff --git a/app/serializers/activitypub/update_poll_serializer.rb b/app/serializers/activitypub/update_poll_serializer.rb
index a9a09747f..b894f309f 100644
--- a/app/serializers/activitypub/update_poll_serializer.rb
+++ b/app/serializers/activitypub/update_poll_serializer.rb
@@ -6,7 +6,7 @@ class ActivityPub::UpdatePollSerializer < ActivityPub::Serializer
   has_one :object, serializer: ActivityPub::NoteSerializer
 
   def id
-    [ActivityPub::TagManager.instance.uri_for(object), '#updates/', object.poll.updated_at.to_i].join
+    [ActivityPub::TagManager.instance.uri_for(object), '#updates/', object.preloadable_poll.updated_at.to_i].join
   end
 
   def type