about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-11-26 22:46:31 +0100
committerEugen Rochko <eugen@zeonfederated.com>2019-11-26 22:46:31 +0100
commit00c219aa4536206a3f5f8e0e46f1c132c4282b65 (patch)
treecd8508c9cc2b5d31e1dca53c62e1cb34cacebaf3 /app
parente7a7f88df7a763be6dad3a982829ef5a1b1dea09 (diff)
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.
Diffstat (limited to 'app')
-rw-r--r--app/services/activitypub/process_poll_service.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/services/activitypub/process_poll_service.rb b/app/services/activitypub/process_poll_service.rb
index cb4a0d460..903b6a78a 100644
--- a/app/services/activitypub/process_poll_service.rb
+++ b/app/services/activitypub/process_poll_service.rb
@@ -30,7 +30,7 @@ class ActivityPub::ProcessPollService < BaseService
 
     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
     # votes, so we need to remove them