Browse Source

Fix empty poll options not being filtered on remote poll update (#12484)

If a poll contains empty options (which is apparently possible on Pleroma),
it is created without them. However, the poll update code doesn't filter
empty options, and thus:
1. Clear known votes, as it assumes the set of options has changed
2. Errors out because it tries adding empty options, which fails validation

This commit fixes that by filtering them out the same way they are filtered
out at poll creation time.
closed-social-v3
ThibG 5 years ago
committed by Eugen Rochko
parent
commit
00c219aa45
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      app/services/activitypub/process_poll_service.rb

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

@ -30,7 +30,7 @@ class ActivityPub::ProcessPollService < BaseService
voters_count = @json['votersCount'] voters_count = @json['votersCount']
latest_options = items.map { |item| item['name'].presence || item['content'] }
latest_options = items.map { |item| item['name'].presence || item['content'] }.compact
# If for some reasons the options were changed, it invalidates all previous # If for some reasons the options were changed, it invalidates all previous
# votes, so we need to remove them # votes, so we need to remove them

Loading…
Cancel
Save