From a39d436f9f46138db623ee3c9ddef2c501ea8bd2 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 10 Feb 2020 20:37:35 +0000 Subject: poll fixes --- Zotlabs/Lib/Activity.php | 7 ++++++- Zotlabs/Lib/Libzot.php | 2 +- Zotlabs/Module/Vote.php | 5 +++-- include/text.php | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 06aa3b931..5a406beb7 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -928,6 +928,7 @@ class Activity { 'http://purl.org/zot/activity/file' => 'zot:File', 'http://purl.org/zot/activity/mood' => 'zot:Mood', 'Invite' => 'Invite', + 'Question' => 'Question' ]; call_hooks('activity_obj_decode_mapper',$objs); @@ -962,7 +963,8 @@ class Activity { 'http://purl.org/zot/activity/thing' => 'Object', 'http://purl.org/zot/activity/file' => 'zot:File', 'http://purl.org/zot/activity/mood' => 'zot:Mood', - 'Invite' => 'Invite', + 'Invite' => 'Invite', + 'Question' => 'Question' ]; call_hooks('activity_obj_mapper',$objs); @@ -1806,6 +1808,8 @@ class Activity { $s['item_deleted'] = 1; } + + $s['obj_type'] = self::activity_obj_decode_mapper($act->obj['type']); if($s['obj_type'] === ACTIVITY_OBJ_NOTE && $s['mid'] !== $s['parent_mid']) { $s['obj_type'] = ACTIVITY_OBJ_COMMENT; @@ -2219,6 +2223,7 @@ class Activity { } } + if ($p[0]['obj_type'] === 'Question') { if ($item['obj_type'] === ACTIVITY_OBJ_NOTE && $item['title'] && (! $item['content'])) { $item['obj_type'] = 'Answer'; diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 2776a681e..d64421926 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1643,7 +1643,7 @@ class Libzot { // 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'])) { + if ($arr['obj_type'] === ACTIVITY_OBJ_COMMENT && $arr['title'] && (! $arr['body'])) { $arr['obj_type'] = 'Answer'; } } diff --git a/Zotlabs/Module/Vote.php b/Zotlabs/Module/Vote.php index 2c31d84dc..e1932da23 100644 --- a/Zotlabs/Module/Vote.php +++ b/Zotlabs/Module/Vote.php @@ -86,6 +86,7 @@ class Vote extends Controller { $item['item_origin'] = true; $item['parent'] = $fetch[0]['id']; $item['parent_mid'] = $fetch[0]['mid']; + $item['thr_parent'] = $fetch[0]['mid']; $item['uuid'] = new_uuid(); $item['mid'] = z_root() . '/item/' . $item['uuid']; $item['verb'] = 'Create'; @@ -96,10 +97,11 @@ class Vote extends Controller { $item['obj_type'] = 'Note'; $item['author'] = channelx_by_n($channel['channel_id']); - $item['obj'] = Activity::encode_item($item,true); + $item['obj'] = Activity::encode_item($item); // now reset the placeholders + $item['verb'] = ACTIVITY_POST; $item['obj_type'] = 'Answer'; unset($item['author']); @@ -107,7 +109,6 @@ class Vote extends Controller { $x = item_store($item); - retain_item($fetch[0]['id']); if($x['success']) { diff --git a/include/text.php b/include/text.php index 992b455c8..3dd0755a3 100644 --- a/include/text.php +++ b/include/text.php @@ -1731,7 +1731,7 @@ function prepare_body(&$item,$attach = false,$opts = false) { } } - $poll = (($item['obj_type'] === 'Question' && in_array($item['verb'],[ 'Create','Update' ])) ? format_poll($item, $s, $opts) : false); + $poll = (($item['obj_type'] === 'Question' && in_array($item['verb'],[ ACTIVITY_POST, ACTIVITY_UPDATE ])) ? format_poll($item, $s, $opts) : false); if ($poll) { $s = $poll; } -- cgit v1.2.3