Skip to content

Commit 7cb4af2

Browse files
ClearlyClairehiyuki2578
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 bb4e695 commit 7cb4af2

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
@@ -258,7 +258,7 @@ def decrement_count!(key)
258258
before_validation :set_conversation
259259
before_validation :set_local
260260

261-
before_save :set_poll_id
261+
after_create :set_poll_id
262262

263263
class << self
264264
def selectable_visibilities
@@ -449,7 +449,7 @@ def set_reblog
449449
end
450450

451451
def set_poll_id
452-
self.poll_id = owned_poll.id unless owned_poll.nil?
452+
update_column(:poll_id, owned_poll.id) unless owned_poll.nil?
453453
end
454454

455455
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)