Browse Source

Make sure the poll is created before storing its id (#10142)

* Make sure the poll is created before storing its id

* Fix updating poll results

* Support fetching Question activities from the search bar
pull/4/head
ThibG 5 years ago
committed by Eugen Rochko
parent
commit
e13d3792f3
3 changed files with 4 additions and 4 deletions
  1. +2
    -2
      app/models/status.rb
  2. +1
    -1
      app/services/activitypub/fetch_remote_poll_service.rb
  3. +1
    -1
      app/services/resolve_url_service.rb

+ 2
- 2
app/models/status.rb View File

@ -255,7 +255,7 @@ class Status < ApplicationRecord
before_validation :set_conversation before_validation :set_conversation
before_validation :set_local before_validation :set_local
before_save :set_poll_id
after_create :set_poll_id
class << self class << self
def selectable_visibilities def selectable_visibilities
@ -446,7 +446,7 @@ class Status < ApplicationRecord
end end
def set_poll_id def set_poll_id
self.poll_id = owned_poll.id unless owned_poll.nil?
update_column(:poll_id, owned_poll.id) unless owned_poll.nil?
end end
def set_visibility def set_visibility

+ 1
- 1
app/services/activitypub/fetch_remote_poll_service.rb View File

@ -46,6 +46,6 @@ class ActivityPub::FetchRemotePollService < BaseService
end end
def expected_type? def expected_type?
equals_or_includes_any?(@json['type'], 'Question')
equals_or_includes_any?(@json['type'], %w(Question))
end end
end end

+ 1
- 1
app/services/resolve_url_service.rb View File

@ -20,7 +20,7 @@ class ResolveURLService < BaseService
def process_url def process_url
if equals_or_includes_any?(type, %w(Application Group Organization Person Service)) if equals_or_includes_any?(type, %w(Application Group Organization Person Service))
FetchRemoteAccountService.new.call(atom_url, body, protocol) FetchRemoteAccountService.new.call(atom_url, body, protocol)
elsif equals_or_includes_any?(type, %w(Note Article Image Video Page))
elsif equals_or_includes_any?(type, %w(Note Article Image Video Page Question))
FetchRemoteStatusService.new.call(atom_url, body, protocol) FetchRemoteStatusService.new.call(atom_url, body, protocol)
end end
end end

Loading…
Cancel
Save