Store remote votes URI (#10158)
* Store remote votes URI * Add spec for accepting remote votes * Make poll vote id generation work the same way as follows
This commit is contained in:
@ -241,7 +241,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||
|
||||
def poll_vote?
|
||||
return false if replied_to_status.nil? || replied_to_status.poll.nil? || !replied_to_status.local? || !replied_to_status.poll.options.include?(@object['name'])
|
||||
replied_to_status.poll.votes.create!(account: @account, choice: replied_to_status.poll.options.index(@object['name']))
|
||||
replied_to_status.poll.votes.create!(account: @account, choice: replied_to_status.poll.options.index(@object['name']), uri: @object['id'])
|
||||
end
|
||||
|
||||
def resolve_thread(status)
|
||||
|
@ -9,6 +9,7 @@
|
||||
# choice :integer default(0), not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# uri :string
|
||||
#
|
||||
|
||||
class PollVote < ApplicationRecord
|
||||
@ -20,6 +21,8 @@ class PollVote < ApplicationRecord
|
||||
|
||||
after_create_commit :increment_counter_cache
|
||||
|
||||
delegate :local?, to: :account
|
||||
|
||||
private
|
||||
|
||||
def increment_counter_cache
|
||||
|
@ -6,7 +6,7 @@ class ActivityPub::VoteSerializer < ActiveModel::Serializer
|
||||
:in_reply_to, :to
|
||||
|
||||
def id
|
||||
[ActivityPub::TagManager.instance.uri_for(object.account), '#votes/', object.id].join
|
||||
ActivityPub::TagManager.instance.uri_for(object) || [ActivityPub::TagManager.instance.uri_for(object.account), '#votes/', object.id].join
|
||||
end
|
||||
|
||||
def type
|
||||
|
Reference in New Issue
Block a user