Skip to content

Commit fe050b9

Browse files
ClearlyClaireGargron
authored andcommitted
Make sure the poll is created before storing its id (mastodon#10142)
* Make sure the poll is created before storing its id * Fix updating poll results * Support fetching Question activities from the search bar
1 parent f51dbe5 commit fe050b9

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

app/models/status.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def decrement_count!(key)
255255
before_validation :set_conversation
256256
before_validation :set_local
257257

258-
before_save :set_poll_id
258+
after_create :set_poll_id
259259

260260
class << self
261261
def selectable_visibilities
@@ -446,7 +446,7 @@ def set_reblog
446446
end
447447

448448
def set_poll_id
449-
self.poll_id = owned_poll.id unless owned_poll.nil?
449+
update_column(:poll_id, owned_poll.id) unless owned_poll.nil?
450450
end
451451

452452
def set_visibility

app/services/activitypub/fetch_remote_poll_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ def supported_context?
4646
end
4747

4848
def expected_type?
49-
equals_or_includes_any?(@json['type'], 'Question')
49+
equals_or_includes_any?(@json['type'], %w(Question))
5050
end
5151
end

app/services/resolve_url_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def call(url, on_behalf_of: nil)
2020
def process_url
2121
if equals_or_includes_any?(type, %w(Application Group Organization Person Service))
2222
FetchRemoteAccountService.new.call(atom_url, body, protocol)
23-
elsif equals_or_includes_any?(type, %w(Note Article Image Video Page))
23+
elsif equals_or_includes_any?(type, %w(Note Article Image Video Page Question))
2424
FetchRemoteStatusService.new.call(atom_url, body, protocol)
2525
end
2626
end

0 commit comments

Comments
 (0)