Skip to content

Commit

Permalink
Make sure the poll is created before storing its id (mastodon#10142)
Browse files Browse the repository at this point in the history
* Make sure the poll is created before storing its id

* Fix updating poll results

* Support fetching Question activities from the search bar
  • Loading branch information
ClearlyClaire authored and Gargron committed Mar 3, 2019
1 parent f51dbe5 commit fe050b9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/models/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def decrement_count!(key)
before_validation :set_conversation
before_validation :set_local

before_save :set_poll_id
after_create :set_poll_id

class << self
def selectable_visibilities
Expand Down Expand Up @@ -446,7 +446,7 @@ def set_reblog
end

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

def set_visibility
Expand Down
2 changes: 1 addition & 1 deletion app/services/activitypub/fetch_remote_poll_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ def supported_context?
end

def expected_type?
equals_or_includes_any?(@json['type'], 'Question')
equals_or_includes_any?(@json['type'], %w(Question))
end
end
2 changes: 1 addition & 1 deletion app/services/resolve_url_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def call(url, on_behalf_of: nil)
def process_url
if equals_or_includes_any?(type, %w(Application Group Organization Person Service))
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)
end
end
Expand Down

0 comments on commit fe050b9

Please sign in to comment.