aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-02-29 10:25:22 +0000
committerMario <mario@mariovavti.com>2020-02-29 10:25:22 +0000
commit06f2979e04db2c5eb7e10bc4967d750209a4cc73 (patch)
treedad76e76e5b8c786d92c194d56d5a98dd7e06e92 /Zotlabs/Lib
parent1ff9d1afdde31a6c1e8b32713313cfffc8ac4130 (diff)
downloadvolse-hubzilla-06f2979e04db2c5eb7e10bc4967d750209a4cc73.tar.gz
volse-hubzilla-06f2979e04db2c5eb7e10bc4967d750209a4cc73.tar.bz2
volse-hubzilla-06f2979e04db2c5eb7e10bc4967d750209a4cc73.zip
prevent duplicate votes
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/Activity.php30
1 files changed, 29 insertions, 1 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 2f219af1f..02ec7614e 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -1673,8 +1673,11 @@ class Activity {
- static function update_poll($item,$mid,$content) {
+ static function update_poll($item,$post) {
$multi = false;
+ $mid = $post['mid'];
+ $content = $post['title'];
+
if (! $item) {
return false;
}
@@ -1683,6 +1686,31 @@ class Activity {
if ($o && array_key_exists('anyOf',$o)) {
$multi = true;
}
+
+ $r = q("select mid, title from item where parent_mid = '%s' and author_xchan = '%s'",
+ dbesc($item['mid']),
+ dbesc($post['author_xchan'])
+ );
+
+ // prevent any duplicate votes by same author for oneOf and duplicate votes with same author and same answer for anyOf
+
+ if ($r) {
+ if ($multi) {
+ foreach ($r as $rv) {
+ if ($rv['title'] === $content && $rv['mid'] !== $mid) {
+ return false;
+ }
+ }
+ }
+ else {
+ foreach ($r as $rv) {
+ if ($rv['mid'] !== $mid) {
+ return false;
+ }
+ }
+ }
+ }
+
$answer_found = false;
$found = false;
if ($multi) {