about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-03-28 13:01:33 +0100
committerThibaut Girka <thib@sitedethib.com>2019-03-28 13:01:33 +0100
commit050efbc12650feaac3e833c4dd740bf090e3dae1 (patch)
tree260458c7ff43dd82fc02cc7e5ef0920dd8d2a25b /app/models
parent0418bdd71f59b4d7e9f3498f2990c8b044f310e1 (diff)
parent24d5b6f9e39d2ac62a9657c7d19bc8c437b0735b (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- app/workers/activitypub/distribute_poll_update_worker.rb
- config/locales/pl.yml
Diffstat (limited to 'app/models')
-rw-r--r--app/models/notification.rb2
-rw-r--r--app/models/status.rb19
2 files changed, 11 insertions, 10 deletions
diff --git a/app/models/notification.rb b/app/models/notification.rb
index 982136c05..300269e24 100644
--- a/app/models/notification.rb
+++ b/app/models/notification.rb
@@ -25,7 +25,7 @@ class Notification < ApplicationRecord
     poll:           'Poll',
   }.freeze
 
-  STATUS_INCLUDES = [:account, :application, :media_attachments, :tags, active_mentions: :account, reblog: [:account, :application, :media_attachments, :tags, active_mentions: :account]].freeze
+  STATUS_INCLUDES = [:account, :application, :preloadable_poll, :media_attachments, :tags, active_mentions: :account, reblog: [:account, :application, :preloadable_poll, :media_attachments, :tags, active_mentions: :account]].freeze
 
   belongs_to :account, optional: true
   belongs_to :from_account, class_name: 'Account', optional: true
diff --git a/app/models/status.rb b/app/models/status.rb
index c049401e8..e7fa0220b 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -47,7 +47,7 @@ class Status < ApplicationRecord
   belongs_to :account, inverse_of: :statuses
   belongs_to :in_reply_to_account, foreign_key: 'in_reply_to_account_id', class_name: 'Account', optional: true
   belongs_to :conversation, optional: true
-  belongs_to :poll, optional: true
+  belongs_to :preloadable_poll, class_name: 'Poll', foreign_key: 'poll_id', optional: true
 
   belongs_to :thread, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :replies, optional: true
   belongs_to :reblog, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblogs, optional: true
@@ -66,7 +66,7 @@ class Status < ApplicationRecord
   has_one :notification, as: :activity, dependent: :destroy
   has_one :stream_entry, as: :activity, inverse_of: :status
   has_one :status_stat, inverse_of: :status
-  has_one :owned_poll, class_name: 'Poll', inverse_of: :status, dependent: :destroy
+  has_one :poll, inverse_of: :status, dependent: :destroy
 
   validates :uri, uniqueness: true, presence: true, unless: :local?
   validates :text, presence: true, unless: -> { with_media? || reblog? }
@@ -75,7 +75,7 @@ class Status < ApplicationRecord
   validates :reblog, uniqueness: { scope: :account }, if: :reblog?
   validates :visibility, exclusion: { in: %w(direct limited) }, if: :reblog?
 
-  accepts_nested_attributes_for :owned_poll
+  accepts_nested_attributes_for :poll
 
   default_scope { recent }
 
@@ -112,7 +112,7 @@ class Status < ApplicationRecord
                    :tags,
                    :preview_cards,
                    :stream_entry,
-                   :poll,
+                   :preloadable_poll,
                    account: :account_stat,
                    active_mentions: { account: :account_stat },
                    reblog: [
@@ -123,7 +123,7 @@ class Status < ApplicationRecord
                      :media_attachments,
                      :conversation,
                      :status_stat,
-                     :poll,
+                     :preloadable_poll,
                      account: :account_stat,
                      active_mentions: { account: :account_stat },
                    ],
@@ -219,10 +219,11 @@ class Status < ApplicationRecord
 
   def emojis
     return @emojis if defined?(@emojis)
-    fields = [spoiler_text, text]
-    fields += owned_poll.options unless owned_poll.nil?
+
+    fields  = [spoiler_text, text]
+    fields += preloadable_poll.options unless preloadable_poll.nil?
+
     @emojis = CustomEmoji.from_text(fields.join(' '), account.domain)
-    @emojis
   end
 
   def mark_for_mass_destruction!
@@ -473,7 +474,7 @@ class Status < ApplicationRecord
   end
 
   def set_poll_id
-    update_column(:poll_id, owned_poll.id) unless owned_poll.nil?
+    update_column(:poll_id, poll.id) unless poll.nil?
   end
 
   def set_visibility