aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2020-02-09 16:32:18 -0800
committerzotlabs <mike@macgirvin.com>2020-02-09 16:32:18 -0800
commitbbcb237f5b996e94af37611152105b2e965ea493 (patch)
tree042ea69cfc8eb90f0588b9c71edb8e4ef164390b /Zotlabs/Lib
parentfc9e6d289acf30f89da0051a90cbf16f0bc006fb (diff)
downloadvolse-hubzilla-bbcb237f5b996e94af37611152105b2e965ea493.tar.gz
volse-hubzilla-bbcb237f5b996e94af37611152105b2e965ea493.tar.bz2
volse-hubzilla-bbcb237f5b996e94af37611152105b2e965ea493.zip
poll updates
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/Activity.php44
-rw-r--r--Zotlabs/Lib/Libzot.php12
2 files changed, 36 insertions, 20 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index edc65d8e9..06aa3b931 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -325,6 +325,22 @@ class Activity {
$ret['type'] = $objtype;
+ if ($objtype === 'Question') {
+ if ($i['obj']) {
+ if (is_array($i['obj'])) {
+ $ret = $i['obj'];
+ }
+ else {
+ $ret = json_decode($i['obj'],true);
+ }
+
+ if(array_path_exists('actor/id',$ret)) {
+ $ret['actor'] = $ret['actor']['id'];
+ }
+ }
+ }
+
+
$ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/item/' . urlencode($i['mid']));
if($i['title'])
@@ -813,10 +829,6 @@ class Activity {
static function activity_mapper($verb) {
- if ($verb === 'Answer') {
- return 'Note';
- }
-
if(strpos($verb,'/') === false) {
return $verb;
}
@@ -916,7 +928,6 @@ class Activity {
'http://purl.org/zot/activity/file' => 'zot:File',
'http://purl.org/zot/activity/mood' => 'zot:Mood',
'Invite' => 'Invite',
-
];
call_hooks('activity_obj_decode_mapper',$objs);
@@ -1720,14 +1731,6 @@ class Activity {
$s['expires'] = datetime_convert('UTC','UTC',$act->obj['expires']);
}
- if ($act->type === 'Note' && $act->obj['type'] === 'Question' && $act->data['name']) {
- $s['mid'] = $act->id;
- $s['parent_mid'] = $act->obj['id'];
- $s['replyto'] = $act->replyto;
- $s['verb'] = 'Answer';
- $content['content'] = EMPTY_STR;
- }
-
if(in_array($act->type, [ 'Like', 'Dislike', 'Flag', 'Block', 'Announce', 'Accept', 'Reject', 'TentativeAccept', 'emojiReaction' ])) {
$response_activity = true;
@@ -1794,11 +1797,6 @@ class Activity {
$s['verb'] = self::activity_decode_mapper($act->type);
- if ($act->type === 'Note' && $act->obj['type'] === 'Question' && $act->data['name'] && ! $content['content']) {
- $s['verb'] = 'Answer';
- $s['title'] = purify_html($act->data['name']);
- }
-
// Mastodon does not provide update timestamps when updating poll tallies which means race conditions may occur here.
if ($act->type === 'Update' && $act->obj['type'] === 'Question' && $s['edited'] === $s['created']) {
$s['edited'] = datetime_convert();
@@ -2190,7 +2188,7 @@ class Activity {
set_iconfig($item,'activitypub','recips',$act->raw_recips);
if(! $is_parent) {
- $p = q("select parent_mid from item where mid = '%s' and uid = %d limit 1",
+ $p = q("select parent_mid, id, obj_type from item where mid = '%s' and uid = %d limit 1",
dbesc($item['parent_mid']),
intval($item['uid'])
);
@@ -2220,6 +2218,14 @@ class Activity {
// $s['thr_parent'] = $s['mid'];
}
}
+
+ if ($p[0]['obj_type'] === 'Question') {
+ if ($item['obj_type'] === ACTIVITY_OBJ_NOTE && $item['title'] && (! $item['content'])) {
+ $item['obj_type'] = 'Answer';
+ }
+ }
+
+
if($p[0]['parent_mid'] !== $item['parent_mid']) {
$item['thr_parent'] = $item['parent_mid'];
}
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index bb70dfbf2..2776a681e 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -1613,7 +1613,7 @@ class Libzot {
// As a side effect we will also do a preliminary check that we have the top-level-post, otherwise
// processing it is pointless.
- $r = q("select route, id, owner_xchan, item_private from item where mid = '%s' and uid = %d limit 1",
+ $r = q("select route, id, parent_mid, mid, owner_xchan, item_private, obj_type from item where mid = '%s' and uid = %d limit 1",
dbesc($arr['parent_mid']),
intval($channel['channel_id'])
);
@@ -1639,6 +1639,16 @@ class Libzot {
continue;
}
+ if ($r[0]['obj_type'] === 'Question') {
+ // route checking doesn't work correctly here because we've changed the privacy
+ $r[0]['route'] = EMPTY_STR;
+ // If this is a poll response, convert the obj_type to our (internal-only) "Answer" type
+ if ($arr['obj_type'] === ACTIVITY_OBJ_NOTE && $arr['title'] && (! $arr['content'])) {
+ $arr['obj_type'] = 'Answer';
+ }
+ }
+
+
if($relay || $friendofriend || (intval($r[0]['item_private']) === 0 && intval($arr['item_private']) === 0)) {
// reset the route in case it travelled a great distance upstream
// use our parent's route so when we go back downstream we'll match