diff options
31 files changed, 215 insertions, 749 deletions
diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 0474a4a26..948aba80c 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -270,8 +270,7 @@ class Notifier { // Check for non published items, but allow an exclusion for transmitting hidden file activities if (intval($target_item['item_unpublished']) || intval($target_item['item_delayed']) || - intval($target_item['item_blocked']) || - (intval($target_item['item_hidden']) && ($target_item['obj_type'] !== ACTIVITY_OBJ_FILE))) { + intval($target_item['item_blocked']) || intval($target_item['item_hidden'])) { logger('notifier: target item not published, so not forwardable', LOGGER_DEBUG); return; } diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 9a76ccf2e..844dc5905 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -27,19 +27,23 @@ class Activity { return $x['asld']; } - if ($x['type'] === ACTIVITY_OBJ_PERSON) { + if (in_array($x['type'], ['Person', ACTIVITY_OBJ_PERSON])) { return self::fetch_person($x); } - if ($x['type'] === ACTIVITY_OBJ_PROFILE) { + + if (in_array($x['type'], ['Profile', ACTIVITY_OBJ_PROFILE])) { return self::fetch_profile($x); } - if (in_array($x['type'], [ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_ARTICLE])) { + + if (in_array($x['type'], ['Note', 'Article', ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_ARTICLE])) { return self::fetch_item($x); } + if ($x['type'] === ACTIVITY_OBJ_THING) { return self::fetch_thing($x); } - if ($x['type'] === ACTIVITY_OBJ_EVENT) { + + if (in_array($x['type'], ['Event', ACTIVITY_OBJ_EVENT])) { return self::fetch_event($x); } @@ -224,7 +228,7 @@ class Activity { if ($r) { xchan_query($r, true); $r = fetch_post_tags($r); - if (in_array($r[0]['verb'], ['Create', 'Invite']) && $r[0]['obj_type'] === ACTIVITY_OBJ_EVENT) { + if (in_array($r[0]['verb'], ['Create', 'Invite']) && in_array($r[0]['obj_type'], ['Event', ACTIVITY_OBJ_EVENT])) { $r[0]['verb'] = 'Invite'; return self::encode_activity($r[0]); } @@ -936,7 +940,7 @@ class Activity { if (!is_array($i['obj'])) { $i['obj'] = json_decode($i['obj'], true); } - if ($i['obj']['type'] === ACTIVITY_OBJ_PHOTO) { + if (in_array($i['obj']['type'], ['Image', ACTIVITY_OBJ_PHOTO])) { $i['obj']['id'] = $i['mid']; } @@ -1174,7 +1178,7 @@ class Activity { if (!is_array($item[$elm])) { $item[$elm] = json_decode($item[$elm], true); } - if ($item[$elm]['type'] === ACTIVITY_OBJ_PHOTO) { + if (in_array($item[$elm]['type'], ['Image', ACTIVITY_OBJ_PHOTO])) { $item[$elm]['id'] = $item['mid']; } @@ -1208,19 +1212,13 @@ class Activity { 'http://activitystrea.ms/schema/1.0/like' => 'Like', 'http://activitystrea.ms/schema/1.0/favorite' => 'Like', 'http://purl.org/zot/activity/dislike' => 'Dislike', - // 'http://activitystrea.ms/schema/1.0/tag' => 'Add', + //'http://activitystrea.ms/schema/1.0/tag' => 'Add', 'http://activitystrea.ms/schema/1.0/follow' => 'Follow', 'http://activitystrea.ms/schema/1.0/unfollow' => 'Unfollow', 'http://activitystrea.ms/schema/1.0/stop-following' => 'Unfollow', 'http://purl.org/zot/activity/attendyes' => 'Accept', 'http://purl.org/zot/activity/attendno' => 'Reject', 'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept', - 'Announce' => 'Announce', - 'Invite' => 'Invite', - 'Delete' => 'Delete', - 'Undo' => 'Undo', - 'Add' => 'Add', - 'Remove' => 'Remove' ]; call_hooks('activity_mapper', $acts); @@ -1232,7 +1230,7 @@ class Activity { // Reactions will just map to normal activities if (strpos($verb, ACTIVITY_REACT) !== false) - return 'emojiReaction'; + return 'Create'; if (strpos($verb, ACTIVITY_MOOD) !== false) return 'Create'; @@ -1341,13 +1339,7 @@ class Activity { 'http://purl.org/zot/activity/tagterm' => 'zot:Tag', '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', - 'Question' => 'Question', - 'Audio' => 'Audio', - 'Video' => 'Video', - 'Delete' => 'Delete', - 'Undo' => 'Undo' + 'http://purl.org/zot/activity/mood' => 'zot:Mood' ]; call_hooks('activity_obj_mapper', $objs); @@ -2256,7 +2248,7 @@ class Activity { $s['body'] .= $quote_bbcode; } - $s['verb'] = self::activity_decode_mapper($act->type); + $s['verb'] = self::activity_mapper($act->type); // Mastodon does not provide update timestamps when updating poll tallies which means race conditions may occur here. if ($act->type === 'Update' && $act->objprop('type') === 'Question' && $s['edited'] === $s['created']) { @@ -2267,63 +2259,16 @@ class Activity { $s['item_deleted'] = 1; } - if (isset($act->obj['type'])) { - $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; + if ($act->objprop('type')) { + $s['obj_type'] = self::activity_obj_mapper($act->obj['type']); } $s['obj'] = $act->obj; + if (array_path_exists('actor/id', $s['obj'])) { $s['obj']['actor'] = $s['obj']['actor']['id']; } -/* - $eventptr = null; - - if ($act->obj['type'] === 'Invite' && array_path_exists('object/type', $act->obj) && $act->obj['object']['type'] === 'Event') { - $eventptr = $act->obj['object']; - $s['mid'] = $s['parent_mid'] = $act->obj['id']; - } - - if ($act->obj['type'] === 'Event') { - if ($act->type === 'Invite') { - $s['mid'] = $s['parent_mid'] = $act->id; - } - $eventptr = $act->obj; - } - - if ($eventptr) { - - $s['obj'] = []; - $s['obj']['asld'] = $eventptr; - $s['obj']['type'] = ACTIVITY_OBJ_EVENT; - $s['obj']['id'] = $eventptr['id']; - $s['obj']['title'] = html2plain($eventptr['name']); - - if (strpos($act->obj['startTime'], 'Z')) - $s['obj']['adjust'] = true; - else - $s['obj']['adjust'] = true; - - $s['obj']['dtstart'] = datetime_convert('UTC', 'UTC', $eventptr['startTime']); - if ($act->obj['endTime']) - $s['obj']['dtend'] = datetime_convert('UTC', 'UTC', $eventptr['endTime']); - else - $s['obj']['nofinish'] = true; - $s['obj']['description'] = html2bbcode($eventptr['content']); - - if (array_path_exists('location/content', $eventptr)) - $s['obj']['location'] = $eventptr['location']['content']; - - } - else { - $s['obj'] = $act->obj; - } -*/ - $generator = $act->get_property_obj('generator'); if ((!$generator) && (!$response_activity)) { $generator = $act->get_property_obj('generator', $act->obj); @@ -2715,16 +2660,13 @@ class Activity { return; } - - // TODO: if we do not have a parent stop here and move the fetch to background? - - if ($parent && $parent[0]['obj_type'] === 'Question') { - if ($item['obj_type'] === ACTIVITY_OBJ_COMMENT && $item['title'] && (!$item['body'])) { + if ($parent[0]['obj_type'] === 'Question') { + if (in_array($item['obj_type'], ['Note', ACTIVITY_OBJ_COMMENT]) && $item['title'] && (!$item['body'])) { $item['obj_type'] = 'Answer'; } } - if ($parent && $parent[0]['item_wall']) { + if ($parent[0]['item_wall']) { // set the owner to the owner of the parent $item['owner_xchan'] = $parent[0]['owner_xchan']; @@ -3313,49 +3255,7 @@ class Activity { $event['nofinish'] = true; } } -/* - $eventptr = null; - - if ($act->obj['type'] === 'Invite' && array_path_exists('object/type', $act->obj) && $act->obj['object']['type'] === 'Event') { - $eventptr = $act->obj['object']; - $s['mid'] = $s['parent_mid'] = $act->obj['id']; - } - if ($act->obj['type'] === 'Event') { - if ($act->type === 'Invite') { - $s['mid'] = $s['parent_mid'] = $act->id; - } - $eventptr = $act->obj; - } - - if ($eventptr) { - - $s['obj'] = []; - $s['obj']['asld'] = $eventptr; - $s['obj']['type'] = ACTIVITY_OBJ_EVENT; - $s['obj']['id'] = $eventptr['id']; - $s['obj']['title'] = html2plain($eventptr['name']); - - if (strpos($act->obj['startTime'], 'Z')) - $s['obj']['adjust'] = true; - else - $s['obj']['adjust'] = true; - - $s['obj']['dtstart'] = datetime_convert('UTC', 'UTC', $eventptr['startTime']); - if ($act->obj['endTime']) - $s['obj']['dtend'] = datetime_convert('UTC', 'UTC', $eventptr['endTime']); - else - $s['obj']['nofinish'] = true; - $s['obj']['description'] = html2bbcode($eventptr['content']); - - if (array_path_exists('location/content', $eventptr)) - $s['obj']['location'] = $eventptr['location']['content']; - - } - else { - $s['obj'] = $act->obj; - } -*/ foreach (['name', 'summary', 'content'] as $a) { if (($x = self::get_textfield($act, $a)) !== false) { $content[$a] = $x; diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 8a980519d..48a255e95 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -149,7 +149,7 @@ class Enotify { if(array_key_exists('item',$params)) { - if(in_array($params['item']['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_SHARE])) { + if(in_array($params['item']['verb'], ['Like', 'Dislike', ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_SHARE])) { if(! $always_show_in_notices || !($vnotify & VNOTIFY_LIKE)) { logger('notification: not a visible activity. Ignoring.'); @@ -157,10 +157,10 @@ class Enotify { return; } - if(activity_match($params['verb'], ACTIVITY_LIKE)) + if(activity_match($params['verb'], ['Like', ACTIVITY_LIKE])) $action = (($moderated) ? t('requested to like') : t('liked')); - if(activity_match($params['verb'], ACTIVITY_DISLIKE)) + if(activity_match($params['verb'], ['Dislike', ACTIVITY_DISLIKE])) $action = (($moderated) ? t('requested to dislike') : t('disliked')); if(activity_match($params['verb'], ACTIVITY_SHARE)) @@ -262,7 +262,7 @@ class Enotify { $itemlink = $params['link']; - if (array_key_exists('item',$params) && (activity_match($params['item']['verb'], ACTIVITY_LIKE) || activity_match($params['item']['verb'], ACTIVITY_DISLIKE))) { + if (array_key_exists('item',$params) && (activity_match($params['item']['verb'], ['Like', 'Dislike', ACTIVITY_LIKE, ACTIVITY_DISLIKE]))) { if(! $always_show_in_notices || !($vnotify & VNOTIFY_LIKE) || !feature_enabled($recip['channel_id'], 'dislike')) { logger('notification: not a visible activity. Ignoring.'); pop_lang(); @@ -313,10 +313,10 @@ class Enotify { //$verb = ((activity_match($params['item']['verb'], ACTIVITY_DISLIKE)) ? t('disliked') : t('liked')); $moderated = (($params['item']['item_blocked'] == ITEM_MODERATED) ? true : false); - if(activity_match($params['item']['verb'], ACTIVITY_LIKE)) + if(activity_match($params['item']['verb'], ['Like', ACTIVITY_LIKE])) $verb = (($moderated) ? t('requested to like') : t('liked')); - if(activity_match($params['item']['verb'], ACTIVITY_DISLIKE)) + if(activity_match($params['item']['verb'], ['Dislike', ACTIVITY_DISLIKE])) $verb = (($moderated) ? t('requested to dislike') : t('disliked')); // "your post" diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index ba75d9fa9..a98ae8f20 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1699,7 +1699,7 @@ class Libzot { // route checking doesn't work correctly here because we've changed the privacy $parent[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_COMMENT && $arr['title'] && (!$arr['body'])) { + if (in_array($arr['obj_type'], ['Note', ACTIVITY_OBJ_COMMENT]) && $arr['title'] && (!$arr['body'])) { $arr['obj_type'] = 'Answer'; } } diff --git a/Zotlabs/Lib/Share.php b/Zotlabs/Lib/Share.php index 81f378d0d..8abbfda80 100644 --- a/Zotlabs/Lib/Share.php +++ b/Zotlabs/Lib/Share.php @@ -112,7 +112,7 @@ class Share { if(! $this->item) return $bb; - $is_photo = (($this->item['obj_type'] === ACTIVITY_OBJ_PHOTO) ? true : false); + $is_photo = ((in_array($this->item['obj_type'], ['Image', ACTIVITY_OBJ_PHOTO])) ? true : false); if($is_photo) { $object = json_decode($this->item['obj'],true); $photo_bb = $object['body']; diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 6b07e32e9..42d76bf17 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -643,7 +643,7 @@ class ThreadItem { * Only add what will be displayed */ - if(activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) { + if(activity_match($item->get_data_value('verb'), ['Like', 'Dislike', ACTIVITY_LIKE, ACTIVITY_DISLIKE])) { return false; } diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php index 72d2bd2f8..fb3b6dd9b 100644 --- a/Zotlabs/Lib/ThreadStream.php +++ b/Zotlabs/Lib/ThreadStream.php @@ -171,7 +171,7 @@ class ThreadStream { */ - if(($item->get_data_value('id') != $item->get_data_value('parent')) && (activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE))) { + if($item->get_data_value('id') != $item->get_data_value('parent') && activity_match($item->get_data_value('verb'), ['Like', 'Dislike', ACTIVITY_LIKE, ACTIVITY_DISLIKE])) { return false; } diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 574dffc69..7d71edc99 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -298,7 +298,6 @@ class Item extends Controller { function post() { - // This will change. Figure out who the observer is and whether or not // they have permission to post here. Else ignore the post. @@ -405,7 +404,7 @@ class Item extends Controller { $pagetitle = ((x($_REQUEST, 'pagetitle')) ? escape_tags($_REQUEST['pagetitle']) : ''); $layout_mid = ((x($_REQUEST, 'layout_mid')) ? escape_tags($_REQUEST['layout_mid']) : ''); $plink = ((x($_REQUEST, 'permalink')) ? escape_tags($_REQUEST['permalink']) : ''); - $obj_type = ((x($_REQUEST, 'obj_type')) ? escape_tags($_REQUEST['obj_type']) : ACTIVITY_OBJ_NOTE); + $obj_type = ((x($_REQUEST, 'obj_type')) ? escape_tags($_REQUEST['obj_type']) : 'Note'); // allow API to bulk load a bunch of imported items with sending out a bunch of posts. $nopush = ((x($_REQUEST, 'nopush')) ? intval($_REQUEST['nopush']) : 0); @@ -444,9 +443,6 @@ class Item extends Controller { if (!x($_REQUEST, 'type')) $_REQUEST['type'] = 'net-comment'; - if ($obj_type == ACTIVITY_OBJ_NOTE) - $obj_type = ACTIVITY_OBJ_COMMENT; - if ($parent) { $r = q("SELECT * FROM item WHERE id = %d LIMIT 1", intval($parent) @@ -1008,7 +1004,7 @@ class Item extends Controller { if (!strlen($verb)) - $verb = ACTIVITY_POST; + $verb = 'Create'; $notify_type = (($parent) ? 'comment-new' : 'wall-new'); @@ -1219,18 +1215,6 @@ class Item extends Controller { $this->add_listeners($datarray); } - // We only need edit activities for other federated protocols - // which do not support edits natively. While this does federate - // edits, it presents a number of issues locally - such as #757 and #758. - // The SQL check for an edit activity would not perform that well so to fix these issues - // requires an additional item flag (perhaps 'item_edit_activity') that we can add to the - // query for searches and notifications. - - // For now we'll just forget about trying to make edits work on network protocols that - // don't support them. - - // item_create_edit_activity($x); - if (!$parent) { $r = q("select * from item where id = %d", intval($post_id) @@ -1285,7 +1269,7 @@ class Item extends Controller { 'to_xchan' => $datarray['owner_xchan'], 'item' => $datarray, 'link' => z_root() . '/display/' . $datarray['uuid'], - 'verb' => ACTIVITY_POST, + 'verb' => 'Create', 'otype' => 'item', 'parent' => $parent, 'parent_mid' => $parent_item['mid'] @@ -1303,7 +1287,7 @@ class Item extends Controller { 'to_xchan' => $datarray['owner_xchan'], 'item' => $datarray, 'link' => z_root() . '/display/' . $datarray['uuid'], - 'verb' => ACTIVITY_POST, + 'verb' => 'Create', 'otype' => 'item' ]); } diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index 68234eb93..e19a74a23 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -19,15 +19,15 @@ class Like extends Controller { private function reaction_to_activity($reaction) { $acts = [ - 'like' => ACTIVITY_LIKE, - 'dislike' => ACTIVITY_DISLIKE, + 'like' => 'Like', + 'dislike' => 'Dislike', 'announce' => ACTIVITY_SHARE, 'agree' => ACTIVITY_AGREE, 'disagree' => ACTIVITY_DISAGREE, 'abstain' => ACTIVITY_ABSTAIN, - 'attendyes' => ACTIVITY_ATTEND, - 'attendno' => ACTIVITY_ATTENDNO, - 'attendmaybe' => ACTIVITY_ATTENDMAYBE + 'attendyes' => 'Accept', + 'attendno' => 'Reject', + 'attendmaybe' => 'TentativeAccept' ]; // unlike (etc.) reactions are an undo of positive reactions, rather than a negative action. @@ -72,11 +72,11 @@ class Like extends Controller { $activities = q("SELECT item.*, item.id AS item_id FROM item WHERE uid = %d $item_normal AND thr_parent = '%s' - AND verb IN ('%s', '%s', '%s', '%s', '%s', '%s')", + AND verb IN ('%s', '%s', '%s', '%s', '%s', '%s', 'Accept', 'Reject', 'TentativeAccept')", intval($arr['item']['uid']), dbesc($arr['item']['mid']), - dbesc(ACTIVITY_LIKE), - dbesc(ACTIVITY_DISLIKE), + dbesc('Like'), + dbesc('Dislike'), dbesc(ACTIVITY_SHARE), dbesc(ACTIVITY_ATTEND), dbesc(ACTIVITY_ATTENDNO), @@ -135,7 +135,7 @@ class Like extends Controller { } $is_rsvp = false; - if (in_array($activity, [ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE])) { + if (in_array($activity, ['Accept', 'Reject', 'TentativeAccept', ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE])) { $is_rsvp = true; } @@ -184,7 +184,7 @@ class Like extends Controller { } } $post_type = t('channel'); - $obj_type = ACTIVITY_OBJ_PROFILE; + $obj_type = 'Profile'; $profile = $r[0]; } @@ -213,7 +213,7 @@ class Like extends Controller { $public = false; $post_type = t('thing'); - $obj_type = ACTIVITY_OBJ_PROFILE; + $obj_type = 'Profile'; $tgttype = ACTIVITY_OBJ_THING; $links = array(); @@ -375,9 +375,9 @@ class Like extends Controller { // event participation and consensus items are essentially radio toggles. If you make a subsequent choice, // we need to eradicate your first choice. - if ($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) { - $verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' "; - $multi_undo = 1; + if (in_array($activity, ['Accept', 'Reject', 'TentativeAccept', ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE])) { + $verbs = "'Accept','Reject','TentativeAccept','" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' "; + $multi_undo = true; } if ($activity === ACTIVITY_AGREE || $activity === ACTIVITY_DISAGREE || $activity === ACTIVITY_ABSTAIN) { $verbs = " '" . dbesc(ACTIVITY_AGREE) . "','" . dbesc(ACTIVITY_DISAGREE) . "','" . dbesc(ACTIVITY_ABSTAIN) . "' "; @@ -452,14 +452,20 @@ class Like extends Controller { $arr['item_wall'] = 1; } else { - $post_type = (($item['resource_type'] === 'photo') ? t('photo') : t('status')); - if (in_array($item['obj_type'], ['Event', ACTIVITY_OBJ_EVENT])) - $post_type = t('event'); - - $obj_type = (($item['resource_type'] === 'photo') ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE); - - if ($obj_type === ACTIVITY_OBJ_NOTE && (!intval($item['item_thread_top']))) - $obj_type = ACTIVITY_OBJ_COMMENT; + switch ($item['resource_type']) { + case 'photo': + $obj_type = 'Image'; + $post_type = t('photo'); + break; + case 'event': + $obj_type = 'Invite'; + $post_type = t('event'); + break; + default: + $obj_type = 'Note'; + $post_type = t('status'); + break; + } $object = json_encode(Activity::fetch_item(['id' => $item['mid']])); diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 4f8e2f4e4..3ea813547 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -275,7 +275,7 @@ class Network extends \Zotlabs\Web\Controller { $vnotify = get_pconfig(local_channel(), 'system', 'vnotify'); if(! ($vnotify & VNOTIFY_LIKE)) - $likes_sql = " AND verb NOT IN ('" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; + $likes_sql = " AND verb NOT IN ('Like', 'Dislike', '" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; // This is for nouveau view public forum cid queries (if a forum notification is clicked) //$p = q("SELECT oid AS parent FROM term WHERE uid = %d AND ttype = %d AND term = '%s'", diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index 6c73c411e..0a490d1db 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -1152,8 +1152,9 @@ class Photos extends \Zotlabs\Web\Controller { $template = $tpl; $sparkle = ''; - if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) && ($item['id'] != $item['parent'])) + if(activity_match($item['verb'], ['Like', 'Dislike', ACTIVITY_LIKE, ACTIVITY_DISLIKE]) && $item['id'] != $item['parent']) { continue; + } $redirect_url = z_root() . '/redir/' . $item['cid'] ; diff --git a/Zotlabs/Module/Poke.php b/Zotlabs/Module/Poke.php index 30585bf3d..ee355f2a9 100644 --- a/Zotlabs/Module/Poke.php +++ b/Zotlabs/Module/Poke.php @@ -47,8 +47,6 @@ class Poke extends Controller { if(! array_key_exists($verb,$verbs)) return; - $activity = ACTIVITY_POKE . '#' . urlencode($verbs[$verb][0]); - $contact_id = intval($_REQUEST['cid']); $xchan = trim($_REQUEST['xchan']); @@ -116,9 +114,9 @@ class Poke extends Controller { $arr['allow_gid'] = $allow_gid; $arr['deny_cid'] = $deny_cid; $arr['deny_gid'] = $deny_gid; - $arr['verb'] = $activity; + $arr['verb'] = 'Create'; $arr['item_private'] = $item_private; - $arr['obj_type'] = ACTIVITY_OBJ_NOTE; + $arr['obj_type'] = 'Note'; $arr['body'] = '[zrl=' . $channel['xchan_url'] . ']' . $channel['xchan_name'] . '[/zrl]' . ' ' . t($verbs[$verb][0]) . ' ' . '[zrl=' . $target['xchan_url'] . ']' . $target['xchan_name'] . '[/zrl]'; $arr['item_origin'] = 1; $arr['item_unseen'] = 1; diff --git a/Zotlabs/Module/Sharedwithme.php b/Zotlabs/Module/Sharedwithme.php index c294079d4..6489959f0 100644 --- a/Zotlabs/Module/Sharedwithme.php +++ b/Zotlabs/Module/Sharedwithme.php @@ -40,7 +40,7 @@ class Sharedwithme extends Controller { //drop all files - localuser if((argc() > 1) && (argv(1) === 'dropall')) { - $r = q("SELECT id FROM item WHERE verb = '%s' AND obj_type IN ('Document', 'Video', 'Audio', 'Image') AND uid = %d AND owner_xchan != '%s' $item_normal", + $r = q("SELECT id FROM item WHERE (verb = 'Create' OR verb = '%s') AND obj_type IN ('Document', 'Video', 'Audio', 'Image') AND uid = %d AND owner_xchan != '%s' $item_normal", dbesc(ACTIVITY_POST), intval(local_channel()), dbesc($channel['channel_hash']) @@ -56,7 +56,7 @@ class Sharedwithme extends Controller { } //list files - $r = q("SELECT id, uid, obj, item_unseen FROM item WHERE verb = '%s' AND obj_type IN ('Document', 'Video', 'Audio', 'Image') AND uid = %d AND owner_xchan != '%s' $item_normal", + $r = q("SELECT id, uid, obj, item_unseen FROM item WHERE (verb = 'Create' OR verb = '%s') AND obj_type IN ('Document', 'Video', 'Audio', 'Image') AND uid = %d AND owner_xchan != '%s' $item_normal", dbesc(ACTIVITY_POST), intval(local_channel()), dbesc($channel['channel_hash']) diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index 1f56d8033..047b7e507 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -181,10 +181,10 @@ class Sse_bs extends Controller { $sql_extra = ''; if (!(self::$vnotify & VNOTIFY_LIKE)) { - $sql_extra = " AND verb NOT IN ('" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; + $sql_extra = " AND verb NOT IN ('Like', 'Dislike', '" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; } elseif (!feature_enabled(self::$uid, 'dislike')) { - $sql_extra = " AND verb NOT IN ('" . dbesc(ACTIVITY_DISLIKE) . "') "; + $sql_extra = " AND verb NOT IN ('Dislike', '" . dbesc(ACTIVITY_DISLIKE) . "') "; } $sql_extra2 = ''; @@ -193,8 +193,8 @@ class Sse_bs extends Controller { $item_normal = item_normal(); - // Filter FEP-5624 approvals for comments and internal follow activities - $item_normal .= " AND verb NOT IN ('" . dbesc(ACTIVITY_ATTEND) . "', 'Accept', '" . dbesc(ACTIVITY_ATTENDNO) . "', 'Reject', '" . dbesc(ACTIVITY_FOLLOW) . "') "; + // Filter internal follow activities + $item_normal .= " AND verb NOT IN ('" . dbesc(ACTIVITY_FOLLOW) . "') "; if ($notifications) { $items = q("SELECT * FROM item @@ -264,10 +264,10 @@ class Sse_bs extends Controller { $sql_extra = ''; if (!(self::$vnotify & VNOTIFY_LIKE)) { - $sql_extra = " AND verb NOT IN ('" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; + $sql_extra = " AND verb NOT IN ('Like', 'Dislike', '" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; } elseif (!feature_enabled(self::$uid, 'dislike')) { - $sql_extra = " AND verb NOT IN ('" . dbesc(ACTIVITY_DISLIKE) . "') "; + $sql_extra = " AND verb NOT IN ('Dislike', '" . dbesc(ACTIVITY_DISLIKE) . "') "; } $sql_extra2 = ''; @@ -276,8 +276,8 @@ class Sse_bs extends Controller { $item_normal = item_normal(); - // Filter FEP-5624 approvals for comments and internal follow activities - $item_normal .= " AND verb NOT IN ('" . dbesc(ACTIVITY_ATTEND) . "', 'Accept', '" . dbesc(ACTIVITY_ATTENDNO) . "', 'Reject', '" . dbesc(ACTIVITY_FOLLOW) . "') "; + // Filter internal follow activities + $item_normal .= " AND verb NOT IN ('" . dbesc(ACTIVITY_FOLLOW) . "') "; if ($notifications) { $items = q("SELECT * FROM item @@ -346,10 +346,10 @@ class Sse_bs extends Controller { $sql_extra = ''; if (!(self::$vnotify & VNOTIFY_LIKE)) { - $sql_extra = " AND verb NOT IN ('" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; + $sql_extra = " AND verb NOT IN ('Like', 'Dislike', '" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; } elseif (!feature_enabled(self::$uid, 'dislike')) { - $sql_extra = " AND verb NOT IN ('" . dbesc(ACTIVITY_DISLIKE) . "') "; + $sql_extra = " AND verb NOT IN ('Dislike', '" . dbesc(ACTIVITY_DISLIKE) . "') "; } $sql_extra2 = ''; @@ -359,8 +359,8 @@ class Sse_bs extends Controller { $item_normal = item_normal(); - // Filter FEP-5624 approvals for comments and internal follow activities - $item_normal .= " AND verb NOT IN ('" . dbesc(ACTIVITY_ATTEND) . "', 'Accept', '" . dbesc(ACTIVITY_ATTENDNO) . "', 'Reject', '" . dbesc(ACTIVITY_FOLLOW) . "') "; + // Filter internal follow activities + $item_normal .= " AND verb NOT IN ('" . dbesc(ACTIVITY_FOLLOW) . "') "; if ($notifications) { $items = q("SELECT * FROM item @@ -441,10 +441,10 @@ class Sse_bs extends Controller { $sys = get_sys_channel(); $sql_extra = ''; if (!(self::$vnotify & VNOTIFY_LIKE)) { - $sql_extra = " AND verb NOT IN ('" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; + $sql_extra = " AND verb NOT IN ('Like', 'Dislike', '" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; } elseif (!feature_enabled(self::$uid, 'dislike')) { - $sql_extra = " AND verb NOT IN ('" . dbesc(ACTIVITY_DISLIKE) . "') "; + $sql_extra = " AND verb NOT IN ('Dislike', '" . dbesc(ACTIVITY_DISLIKE) . "') "; } $sql_extra2 = ''; @@ -466,8 +466,8 @@ class Sse_bs extends Controller { $item_normal = item_normal(); - // Filter FEP-5624 approvals for comments and internal follow activities - $item_normal .= " AND verb NOT IN ('" . dbesc(ACTIVITY_ATTEND) . "', 'Accept', '" . dbesc(ACTIVITY_ATTENDNO) . "', 'Reject', '" . dbesc(ACTIVITY_FOLLOW) . "') "; + // Filter internal follow activities + $item_normal .= " AND verb NOT IN ('" . dbesc(ACTIVITY_FOLLOW) . "') "; if ($notifications) { $items = q("SELECT * FROM item @@ -592,7 +592,7 @@ class Sse_bs extends Controller { $sql_extra = ''; if(! (self::$vnotify & VNOTIFY_LIKE)) - $sql_extra = " AND verb NOT IN ('" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; + $sql_extra = " AND verb NOT IN ('Like', 'Dislike', '" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; $fcount = count($forums); $i = 0; @@ -662,12 +662,12 @@ class Sse_bs extends Controller { $item_normal = item_normal(); - // Filter FEP-5624 approvals for comments and internal follow activities - $item_normal .= " AND verb NOT IN ('" . dbesc(ACTIVITY_ATTEND) . "', 'Accept', '" . dbesc(ACTIVITY_ATTENDNO) . "', 'Reject', '" . dbesc(ACTIVITY_FOLLOW) . "') "; + // Filter internal follow activities + $item_normal .= " AND verb NOT IN ('" . dbesc(ACTIVITY_FOLLOW) . "') "; $r = q("SELECT * FROM item - WHERE verb = '%s' + WHERE (verb = 'Create' OR verb = '%s') AND obj_type IN ('Document', 'Video', 'Audio', 'Image') AND uid = %d AND author_xchan != '%s' diff --git a/Zotlabs/Module/Subthread.php b/Zotlabs/Module/Subthread.php index e8181dde3..5ddcaffc6 100644 --- a/Zotlabs/Module/Subthread.php +++ b/Zotlabs/Module/Subthread.php @@ -112,7 +112,7 @@ class Subthread extends \Zotlabs\Web\Controller { $post_type = (($item['resource_type'] === 'photo') ? t('photo') : t('status')); $links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $item['plink'])); - $objtype = (($item['resource_type'] === 'photo') ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE ); + $objtype = (($item['resource_type'] === 'photo') ? 'Image' : 'Note'); $body = $item['body']; diff --git a/Zotlabs/Module/Tagger.php b/Zotlabs/Module/Tagger.php index ebe28c444..b6067be5e 100644 --- a/Zotlabs/Module/Tagger.php +++ b/Zotlabs/Module/Tagger.php @@ -67,15 +67,15 @@ class Tagger extends \Zotlabs\Web\Controller { switch($item['resource_type']) { case 'photo': - $targettype = ACTIVITY_OBJ_PHOTO; + $targettype = 'Image'; $post_type = t('photo'); break; case 'event': - $targettype = ACTIVITY_OBJ_EVENT; + $targettype = 'Event'; $post_type = t('event'); break; default: - $targettype = ACTIVITY_OBJ_NOTE; + $targettype = 'Note'; $post_type = t('post'); if($item['mid'] != $item['parent_mid']) $post_type = t('comment'); diff --git a/Zotlabs/Module/Vote.php b/Zotlabs/Module/Vote.php index 870fd760c..06c47f91f 100644 --- a/Zotlabs/Module/Vote.php +++ b/Zotlabs/Module/Vote.php @@ -98,7 +98,7 @@ class Vote extends Controller { // now reset the placeholders - $item['verb'] = ACTIVITY_POST; + $item['verb'] = 'Create'; $item['obj_type'] = 'Answer'; unset($item['author']); diff --git a/Zotlabs/Widget/Messages.php b/Zotlabs/Widget/Messages.php index 6e452735a..157b3f535 100644 --- a/Zotlabs/Widget/Messages.php +++ b/Zotlabs/Widget/Messages.php @@ -75,16 +75,16 @@ class Messages { $vnotify_sql_i = ''; if (!($vnotify & VNOTIFY_LIKE)) { - $vnotify_sql_c = " AND c.verb NOT IN ('" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; - $vnotify_sql_i = " AND i.verb NOT IN ('" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; + $vnotify_sql_c = " AND c.verb NOT IN ('Like', 'Dislike', '" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; + $vnotify_sql_i = " AND i.verb NOT IN ('Like', 'Dislike', '" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; } elseif (!feature_enabled(local_channel(), 'dislike')) { - $vnotify_sql_c = " AND c.verb NOT IN ('" . dbesc(ACTIVITY_DISLIKE) . "') "; - $vnotify_sql_i = " AND i.verb NOT IN ('" . dbesc(ACTIVITY_DISLIKE) . "') "; + $vnotify_sql_c = " AND c.verb NOT IN ('Dislike', '" . dbesc(ACTIVITY_DISLIKE) . "') "; + $vnotify_sql_i = " AND i.verb NOT IN ('Dislike', '" . dbesc(ACTIVITY_DISLIKE) . "') "; } if($author) { - $author_sql = " AND i.owner_xchan = '" . protect_sprintf(dbesc($author)) . "' "; + $author_sql = " AND (i.owner_xchan = '" . protect_sprintf(dbesc($author)) . "' OR i.source_xchan = '" . protect_sprintf(dbesc($author)) . "') "; } switch($type) { @@ -101,11 +101,8 @@ class Messages { $type_sql = ' AND i.item_private IN (0, 1) '; } - // FEP-5624 filter approvals for comments - $approvals_c = " AND c.verb NOT IN ('" . dbesc(ACTIVITY_ATTEND) . "', 'Accept', '" . dbesc(ACTIVITY_ATTENDNO) . "', 'Reject') "; - $items = q("SELECT *, - (SELECT count(*) FROM item c WHERE c.uid = %d AND c.parent = i.parent AND c.item_unseen = 1 AND c.item_thread_top = 0 $item_normal_c $approvals_c $vnotify_sql_c) AS unseen_count + (SELECT count(*) FROM item c WHERE c.uid = %d AND c.parent = i.parent AND c.item_unseen = 1 AND c.item_thread_top = 0 $item_normal_c $vnotify_sql_c) AS unseen_count FROM item i WHERE i.uid = %d AND i.created <= '%s' $type_sql diff --git a/Zotlabs/Widget/Pinned.php b/Zotlabs/Widget/Pinned.php index 91a9f45b9..3c6484b36 100644 --- a/Zotlabs/Widget/Pinned.php +++ b/Zotlabs/Widget/Pinned.php @@ -225,39 +225,39 @@ class Pinned { private function activity($item, &$conv_responses) { foreach(array_keys($conv_responses) as $verb) { + $verb_sql = ''; switch($verb) { case 'like': - $v = ACTIVITY_LIKE; + $verb_sql = " AND verb IN ('Like', '" . ACTIVITY_LIKE . "') "; break; case 'dislike': - $v = ACTIVITY_DISLIKE; + $verb_sql = " AND verb IN ('Dislike', '" . ACTIVITY_DISLIKE . "') "; break; case 'agree': - $v = ACTIVITY_AGREE; + $verb_sql = " AND verb = '" . ACTIVITY_AGREE . "' "; break; case 'disagree': - $v = ACTIVITY_DISAGREE; + $verb_sql = " AND verb = '" . ACTIVITY_DISAGREE . "' "; break; case 'abstain': - $v = ACTIVITY_ABSTAIN; + $verb_sql = " AND verb = '" . ACTIVITY_ABSTAIN . "' "; break; case 'attendyes': - $v = ACTIVITY_ATTEND; + $verb_sql = " AND verb IN ('Accept', '" . ACTIVITY_ATTEND . "') "; break; case 'attendno': - $v = ACTIVITY_ATTENDNO; + $verb_sql = " AND verb IN ('Reject', '" . ACTIVITY_ATTENDNO . "') "; break; case 'attendmaybe': - $v = ACTIVITY_ATTENDMAYBE; + $verb_sql = " AND verb IN ('TentativeAccept', '" . ACTIVITY_ATTENDMAYBE . "') "; break; default: break; } - $r = q("SELECT * FROM item WHERE parent = %d AND id <> parent AND verb = '%s' AND item_deleted = 0", - intval($item['id']), - dbesc($v) + $r = q("SELECT * FROM item WHERE parent = %d AND id <> parent $verb_sql AND item_deleted = 0", + intval($item['id']) ); if(! $r) { unset($conv_responses[$verb]); @@ -495,59 +495,50 @@ define('ZOT_APSCHEMA_REV', '/apschema/v1.11'); define('ACTIVITY_PUBLIC_INBOX', 'https://www.w3.org/ns/activitystreams#Public'); define('ACTIVITY_REACT', NAMESPACE_ZOT . '/activity/react'); -define('ACTIVITY_LIKE', NAMESPACE_ACTIVITY_SCHEMA . 'like'); -define('ACTIVITY_DISLIKE', NAMESPACE_ZOT . '/activity/dislike'); -define('ACTIVITY_AGREE', NAMESPACE_ZOT . '/activity/agree'); -define('ACTIVITY_DISAGREE', NAMESPACE_ZOT . '/activity/disagree'); -define('ACTIVITY_ABSTAIN', NAMESPACE_ZOT . '/activity/abstain'); -define('ACTIVITY_ATTEND', NAMESPACE_ZOT . '/activity/attendyes'); -define('ACTIVITY_ATTENDNO', NAMESPACE_ZOT . '/activity/attendno'); -define('ACTIVITY_ATTENDMAYBE', NAMESPACE_ZOT . '/activity/attendmaybe'); -define('ACTIVITY_POLLRESPONSE', NAMESPACE_ZOT . '/activity/pollresponse'); - -define('ACTIVITY_OBJ_HEART', NAMESPACE_ZOT . '/activity/heart'); - -define('ACTIVITY_FRIEND', NAMESPACE_ACTIVITY_SCHEMA . 'make-friend'); -define('ACTIVITY_REQ_FRIEND', NAMESPACE_ACTIVITY_SCHEMA . 'request-friend'); -define('ACTIVITY_UNFRIEND', NAMESPACE_ACTIVITY_SCHEMA . 'remove-friend'); + +define('ACTIVITY_LIKE', NAMESPACE_ACTIVITY_SCHEMA . 'like'); // AS2 Like +define('ACTIVITY_DISLIKE', NAMESPACE_ZOT . '/activity/dislike'); // AS2 Dislike + +define('ACTIVITY_AGREE', NAMESPACE_ZOT . '/activity/agree'); // deprecated - remove from code? +define('ACTIVITY_DISAGREE', NAMESPACE_ZOT . '/activity/disagree'); // deprecated - remove from code? +define('ACTIVITY_ABSTAIN', NAMESPACE_ZOT . '/activity/abstain'); // deprecated - remove from code? + +define('ACTIVITY_ATTEND', NAMESPACE_ZOT . '/activity/attendyes'); // AS2 Accept +define('ACTIVITY_ATTENDNO', NAMESPACE_ZOT . '/activity/attendno'); // AS2 Reject +define('ACTIVITY_ATTENDMAYBE', NAMESPACE_ZOT . '/activity/attendmaybe'); // AS2 TentativeAccept + +define('ACTIVITY_FRIEND', NAMESPACE_ACTIVITY_SCHEMA . 'make-friend'); // deprecated - remove from code? + define('ACTIVITY_FOLLOW', NAMESPACE_ACTIVITY_SCHEMA . 'follow'); define('ACTIVITY_UNFOLLOW', NAMESPACE_ACTIVITY_SCHEMA . 'stop-following'); -define('ACTIVITY_JOIN', NAMESPACE_ACTIVITY_SCHEMA . 'join'); -define('ACTIVITY_POST', NAMESPACE_ACTIVITY_SCHEMA . 'post'); + +define('ACTIVITY_POST', NAMESPACE_ACTIVITY_SCHEMA . 'post'); // AS2 Create + define('ACTIVITY_UPDATE', NAMESPACE_ACTIVITY_SCHEMA . 'update'); -define('ACTIVITY_TAG', NAMESPACE_ACTIVITY_SCHEMA . 'tag'); + +define('ACTIVITY_TAG', NAMESPACE_ACTIVITY_SCHEMA . 'tag'); // unused + define('ACTIVITY_SHARE', 'Announce'); -//define('ACTIVITY_SHARE', NAMESPACE_ACTIVITY_SCHEMA . 'share'); -define('ACTIVITY_FAVORITE', NAMESPACE_ACTIVITY_SCHEMA . 'favorite'); -define('ACTIVITY_CREATE', NAMESPACE_ACTIVITY_SCHEMA . 'create'); -define('ACTIVITY_DELETE', NAMESPACE_ACTIVITY_SCHEMA . 'delete'); -define('ACTIVITY_WIN', NAMESPACE_ACTIVITY_SCHEMA . 'win'); -define('ACTIVITY_LOSE', NAMESPACE_ACTIVITY_SCHEMA . 'lose'); -define('ACTIVITY_TIE', NAMESPACE_ACTIVITY_SCHEMA . 'tie'); -define('ACTIVITY_COMPLETE', NAMESPACE_ACTIVITY_SCHEMA . 'complete'); + +define('ACTIVITY_CREATE', NAMESPACE_ACTIVITY_SCHEMA . 'create'); // unused + +define('ACTIVITY_DELETE', NAMESPACE_ACTIVITY_SCHEMA . 'delete'); // AS2 Delete define('ACTIVITY_POKE', NAMESPACE_ZOT . '/activity/poke'); define('ACTIVITY_MOOD', NAMESPACE_ZOT . '/activity/mood'); -define('ACTIVITY_OBJ_COMMENT', NAMESPACE_ACTIVITY_SCHEMA . 'comment'); -define('ACTIVITY_OBJ_ACTIVITY', NAMESPACE_ACTIVITY_SCHEMA . 'activity'); -define('ACTIVITY_OBJ_NOTE', NAMESPACE_ACTIVITY_SCHEMA . 'note'); -define('ACTIVITY_OBJ_ARTICLE', NAMESPACE_ACTIVITY_SCHEMA . 'article'); -define('ACTIVITY_OBJ_PERSON', NAMESPACE_ACTIVITY_SCHEMA . 'person'); -define('ACTIVITY_OBJ_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'photo'); -define('ACTIVITY_OBJ_P_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'profile-photo'); -define('ACTIVITY_OBJ_ALBUM', NAMESPACE_ACTIVITY_SCHEMA . 'photo-album'); -define('ACTIVITY_OBJ_EVENT', NAMESPACE_ACTIVITY_SCHEMA . 'event'); -define('ACTIVITY_OBJ_GROUP', NAMESPACE_ACTIVITY_SCHEMA . 'group'); -define('ACTIVITY_OBJ_GAME', NAMESPACE_ACTIVITY_SCHEMA . 'game'); -define('ACTIVITY_OBJ_WIKI', NAMESPACE_ACTIVITY_SCHEMA . 'wiki'); -define('ACTIVITY_OBJ_TAGTERM', NAMESPACE_ZOT . '/activity/tagterm'); -define('ACTIVITY_OBJ_PROFILE', NAMESPACE_ZOT . '/activity/profile'); -define('ACTIVITY_OBJ_THING', NAMESPACE_ZOT . '/activity/thing'); -define('ACTIVITY_OBJ_LOCATION', NAMESPACE_ZOT . '/activity/location'); -define('ACTIVITY_OBJ_FILE', NAMESPACE_ZOT . '/activity/file'); -define('ACTIVITY_OBJ_CARD', NAMESPACE_ZOT . '/activity/card'); +define('ACTIVITY_OBJ_COMMENT', NAMESPACE_ACTIVITY_SCHEMA . 'comment'); // AS2 Note +define('ACTIVITY_OBJ_NOTE', NAMESPACE_ACTIVITY_SCHEMA . 'note'); // AS2 Note +define('ACTIVITY_OBJ_ARTICLE', NAMESPACE_ACTIVITY_SCHEMA . 'article'); // AS2 Article +define('ACTIVITY_OBJ_PERSON', NAMESPACE_ACTIVITY_SCHEMA . 'person'); // AS2 Person +define('ACTIVITY_OBJ_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'photo'); // AS2 Image +define('ACTIVITY_OBJ_EVENT', NAMESPACE_ACTIVITY_SCHEMA . 'event'); // AS2 Event + +define('ACTIVITY_OBJ_TAGTERM', NAMESPACE_ZOT . '/activity/tagterm'); // unused +define('ACTIVITY_OBJ_PROFILE', NAMESPACE_ZOT . '/activity/profile'); // AS2 Profile (broken) +define('ACTIVITY_OBJ_THING', NAMESPACE_ZOT . '/activity/thing'); // AS2 Page??? (broken) + /** * Account Flags diff --git a/include/activities.php b/include/activities.php index 68c995338..f5f0e55da 100644 --- a/include/activities.php +++ b/include/activities.php @@ -2,6 +2,11 @@ function profile_activity($changed, $value) { + // TODO: we should probably send an Update/Profile or Person activity here. + // We could also just send a Note with some changed info? + // Profiles are currently a hubzilla specific thing. + return; + if(! local_channel() || ! is_array($changed) || ! count($changed)) return; @@ -26,10 +31,10 @@ function profile_activity($changed, $value) { $arr['item_origin'] = 1; $arr['item_thread_top'] = 1; $arr['verb'] = ACTIVITY_UPDATE; - $arr['obj_type'] = ACTIVITY_OBJ_PROFILE; + $arr['obj_type'] = 'Profile'; $arr['plink'] = z_root() . '/channel/' . $self['channel_address'] . '/?f=&mid=' . urlencode($arr['mid']); - + $A = '[url=' . z_root() . '/channel/' . $self['channel_address'] . ']' . $self['channel_name'] . '[/url]'; @@ -47,7 +52,7 @@ function profile_activity($changed, $value) { $changes .= $ch; } - $prof = '[url=' . z_root() . '/profile/' . $self['channel_address'] . ']' . t('public profile') . '[/url]'; + $prof = '[url=' . z_root() . '/profile/' . $self['channel_address'] . ']' . t('public profile') . '[/url]'; if($t == 1 && strlen($value)) { // if it's a url, the HTML quotes will mess it up, so link it and don't try and zidify it because we don't know what it points to. @@ -61,24 +66,24 @@ function profile_activity($changed, $value) { } else $message = sprintf( t('%1$s has an updated %2$s, changing %3$s.'), $A, $prof, $changes); - - $arr['body'] = $message; + + $arr['body'] = $message; $links = array(); - $links[] = array('rel' => 'alternate', 'type' => 'text/html', + $links[] = array('rel' => 'alternate', 'type' => 'text/html', 'href' => z_root() . '/profile/' . $self['channel_address']); - $links[] = array('rel' => 'photo', 'type' => $self['xchan_photo_mimetype'], - 'href' => $self['xchan_photo_l']); + $links[] = array('rel' => 'photo', 'type' => $self['xchan_photo_mimetype'], + 'href' => $self['xchan_photo_l']); $arr['object'] = json_encode(array( - 'type' => ACTIVITY_OBJ_PROFILE, + 'type' => 'Profile', 'title' => $self['channel_name'], 'id' => $self['xchan_url'] . '/' . $self['xchan_hash'], 'link' => $links )); - + $arr['allow_cid'] = $self['channel_allow_cid']; $arr['allow_gid'] = $self['channel_allow_gid']; $arr['deny_cid'] = $self['channel_deny_cid']; diff --git a/include/api_zot.php b/include/api_zot.php index 7a217854f..22692b962 100644 --- a/include/api_zot.php +++ b/include/api_zot.php @@ -561,7 +561,7 @@ $mod = new Zotlabs\Module\Wall_attach(); $media = $mod->post(); if($media) - $_REQUEST['body'] .= "\n\n" . $media; + $_REQUEST['body'] = $media . "\n\n" . $_REQUEST['body']; } $mod = new Zotlabs\Module\Item(); diff --git a/include/attach.php b/include/attach.php index 8bbd73dde..e5a2900b3 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1854,169 +1854,6 @@ function pipe_streams($in, $out, $bufsize = 16384) { return $size; } -/** - * @brief Activity for files. - * - * @param int $channel_id - * @param array $object - * @param string $allow_cid - * @param string $allow_gid - * @param string $deny_cid - * @param string $deny_gid - * @param string $verb - * @param boolean $notify - */ -/* -function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $verb, $notify) { - - require_once('include/items.php'); - - $poster = App::get_observer(); - - //if we got no object something went wrong - if(!$object) - return; - - //turn strings into arrays - $arr_allow_cid = expand_acl($allow_cid); - $arr_allow_gid = expand_acl($allow_gid); - $arr_deny_cid = expand_acl($deny_cid); - $arr_deny_gid = expand_acl($deny_gid); - - //filter out receivers which do not have permission to view filestorage - $arr_allow_cid = check_list_permissions($channel_id, $arr_allow_cid, 'view_storage'); - - $is_dir = (intval($object['is_dir']) ? true : false); - - //do not send activity for folders for now - if($is_dir) - return; - - //check for recursive perms if we are in a folder - if($object['folder']) { - - $folder_hash = $object['folder']; - - $r_perms = attach_recursive_perms($arr_allow_cid, $arr_allow_gid, $arr_deny_cid, $arr_deny_gid, $folder_hash); - - if($r_perms === false) //nobody has recursive perms - nobody must be notified - return; - - //split up returned perms - $arr_allow_cid = $r_perms['allow_cid']; - $arr_allow_gid = $r_perms['allow_gid']; - $arr_deny_cid = $r_perms['deny_cid']; - $arr_deny_gid = $r_perms['deny_gid']; - - //filter out receivers which do not have permission to view filestorage - $arr_allow_cid = check_list_permissions($channel_id, $arr_allow_cid, 'view_storage'); - } - - $uuid = item_message_id(); - $mid = z_root() . '/item/' . $uuid; - - $objtype = 'ACTIVITY_OBJ_FILE'; - - $arr = array(); - $arr['aid'] = get_account_id(); - $arr['uid'] = $channel_id; - $arr['uuid'] = $uuid; - $arr['item_wall'] = 1; - $arr['item_origin'] = 1; - $arr['item_unseen'] = 1; - $arr['author_xchan'] = $poster['xchan_hash']; - $arr['owner_xchan'] = $poster['xchan_hash']; - $arr['title'] = ''; - $arr['item_notshown'] = 1; - $arr['obj_type'] = $objtype; - $arr['resource_id'] = $object['hash']; - $arr['resource_type'] = 'attach'; - - $private = (($arr_allow_cid[0] || $arr_allow_gid[0] || $arr_deny_cid[0] || $arr_deny_gid[0]) ? 1 : 0); - - $jsonobject = json_encode($object); - - //check if item for this object exists - $y = q("SELECT mid FROM item WHERE verb = '%s' AND obj_type = '%s' AND resource_id = '%s' AND uid = %d LIMIT 1", - dbesc(ACTIVITY_POST), - dbesc($objtype), - dbesc($object['hash']), - intval(local_channel()) - ); - - if($y) { - $update = true; - $object['d_mid'] = $y[0]['mid']; //attach mid of the old object - $u_jsonobject = json_encode($object); - - //we have got the relevant info - delete the old item before we create the new one - q("DELETE FROM item WHERE obj_type = '%s' AND verb = '%s' AND mid = '%s'", - dbesc(ACTIVITY_OBJ_FILE), - dbesc(ACTIVITY_POST), - dbesc($y[0]['mid']) - ); - - } - - //send update activity and create a new one - if($update && $verb == 'post' ) { - //updates should be sent to everybody with recursive perms and all eventual former allowed members ($object['allow_cid'] etc.). - $u_arr_allow_cid = array_unique(array_merge($arr_allow_cid, expand_acl($object['allow_cid']))); - $u_arr_allow_gid = array_unique(array_merge($arr_allow_gid, expand_acl($object['allow_gid']))); - $u_arr_deny_cid = array_unique(array_merge($arr_deny_cid, expand_acl($object['deny_cid']))); - $u_arr_deny_gid = array_unique(array_merge($arr_deny_gid, expand_acl($object['deny_gid']))); - - $private = (($u_arr_allow_cid[0] || $u_arr_allow_gid[0] || $u_arr_deny_cid[0] || $u_arr_deny_gid[0]) ? 1 : 0); - - $uuid = item_message_id(); - $u_mid = z_root() . '/item/' . $uuid; - - $arr['uuid'] = $uuid; - $arr['mid'] = $u_mid; - $arr['parent_mid'] = $u_mid; - $arr['allow_cid'] = perms2str($u_arr_allow_cid); - $arr['allow_gid'] = perms2str($u_arr_allow_gid); - $arr['deny_cid'] = perms2str($u_arr_deny_cid); - $arr['deny_gid'] = perms2str($u_arr_deny_gid); - $arr['item_private'] = $private; - $arr['verb'] = ACTIVITY_UPDATE; - $arr['obj'] = $u_jsonobject; - $arr['body'] = ''; - - post_activity_item($arr); - - $update = false; - } - - //don't create new activity if notify was not enabled - if(! $notify) { - return; - } - - //don't create new activity if we have an update request but there is no item to update - //this can e.g. happen when deleting images - if(! $y && $verb == 'update') { - return; - } - - $arr['mid'] = $mid; - $arr['parent_mid'] = $mid; - $arr['allow_cid'] = perms2str($arr_allow_cid); - $arr['allow_gid'] = perms2str($arr_allow_gid); - $arr['deny_cid'] = perms2str($arr_deny_cid); - $arr['deny_gid'] = perms2str($arr_deny_gid); - $arr['item_private'] = $private; - $arr['verb'] = (($update) ? ACTIVITY_UPDATE : ACTIVITY_POST); - $arr['obj'] = (($update) ? $u_jsonobject : $jsonobject); - $arr['body'] = ''; - - post_activity_item($arr); - - return; -} -*/ - - function attach_store_item($channel, $observer, $file) { @@ -2127,7 +1964,7 @@ function attach_store_item($channel, $observer, $file) { $arr['item_origin'] = 1; $arr['item_thread_top'] = 1; $arr['item_private'] = (($file['allow_cid'] || $file['allow_gid'] || $file['deny_cid'] || $file['deny_gid']) ? 1 : 0); - $arr['verb'] = ACTIVITY_CREATE; + $arr['verb'] = 'Create'; $arr['obj_type'] = $type; $arr['title'] = $file['filename']; diff --git a/include/channel.php b/include/channel.php index 8045ea333..b8affa3ca 100644 --- a/include/channel.php +++ b/include/channel.php @@ -1777,11 +1777,12 @@ function advanced_profile() { $profile['profile_guid'] = App::$profile['profile_guid']; } - $likers = q("select liker, xchan.* from likes left join xchan on liker = xchan_hash where channel_id = %d and target_type = '%s' and verb = '%s'", + $likers = q("select liker, xchan.* from likes left join xchan on liker = xchan_hash where channel_id = %d and (target_type = 'Profile' OR target_type = '%s') and (verb = 'Like' OR verb = '%s')", intval(App::$profile['profile_uid']), dbesc(ACTIVITY_OBJ_PROFILE), dbesc(ACTIVITY_LIKE) ); + $profile['likers'] = array(); $profile['like_count'] = count($likers); $profile['like_button_label'] = tt('Like','Likes',$profile['like_count'],'noun'); diff --git a/include/conversation.php b/include/conversation.php index c04e32999..7074e1c36 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -90,7 +90,7 @@ function item_redir_and_replace_images($body, $images, $cid) { function localize_item(&$item){ - if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE) || activity_match($item['verb'],ACTIVITY_SHARE)){ + if (activity_match($item['verb'], ['Like', 'Dislike', ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_SHARE])){ if(! $item['obj']) return; @@ -143,7 +143,7 @@ function localize_item(&$item){ switch($obj['type']) { case ACTIVITY_OBJ_PHOTO: - case 'Photo': + case 'Image': $post_type = t('photo'); break; case ACTIVITY_OBJ_EVENT: @@ -151,6 +151,7 @@ function localize_item(&$item){ $post_type = t('event'); break; case ACTIVITY_OBJ_PERSON: + case 'Person': $post_type = t('channel'); $author_name = $obj['title']; if($obj['link']) { @@ -189,26 +190,17 @@ function localize_item(&$item){ $plink = '[zrl=' . zid($item_url) . ']' . $post_type . '[/zrl]'; - if(activity_match($item['verb'],ACTIVITY_LIKE)) { + if(activity_match($item['verb'], ['Like', ACTIVITY_LIKE])) { $bodyverb = t('%1$s likes %2$s\'s %3$s'); - } - elseif(activity_match($item['verb'],ACTIVITY_DISLIKE)) { - $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s'); - } - elseif(activity_match($item['verb'],ACTIVITY_SHARE)) { - $bodyverb = t('%1$s repeated %2$s\'s %3$s'); - } - - - // short version, in notification strings the author will be displayed separately - - if(activity_match($item['verb'],ACTIVITY_LIKE)) { + // short version, in notification strings the author will be displayed separately $shortbodyverb = t('likes %1$s\'s %2$s'); } - elseif(activity_match($item['verb'],ACTIVITY_DISLIKE)) { + elseif(activity_match($item['verb'], ['Dislike', ACTIVITY_DISLIKE])) { + $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s'); $shortbodyverb = t('doesn\'t like %1$s\'s %2$s'); } - elseif(activity_match($item['verb'],ACTIVITY_SHARE)) { + elseif(activity_match($item['verb'], ACTIVITY_SHARE)) { + $bodyverb = t('%1$s repeated %2$s\'s %3$s'); $shortbodyverb = t('repeated %1$s\'s %2$s'); } @@ -225,9 +217,9 @@ function localize_item(&$item){ } - if (activity_match($item['verb'],ACTIVITY_FRIEND)) { + if (activity_match($item['verb'], ACTIVITY_FRIEND)) { - if ($item['obj_type'] == "" || $item['obj_type'] !== ACTIVITY_OBJ_PERSON) + if ($item['obj_type'] == "" || !in_array($item['obj_type'], ['Person', ACTIVITY_OBJ_PERSON])) return; $Aname = $item['author']['xchan_name']; @@ -264,7 +256,8 @@ function localize_item(&$item){ if(! $verb) return; - if ($item['obj_type']=="" || $item['obj_type']!== ACTIVITY_OBJ_PERSON) return; + if ($item['obj_type']=="" || !in_array($item['obj_type'], ['Person', ACTIVITY_OBJ_PERSON])) + return; $Aname = $item['author']['xchan_name']; $Alink = $item['author']['xchan_url']; @@ -314,102 +307,6 @@ function localize_item(&$item){ $item['body'] = sprintf($txt, $A, t($verb)); } - - -/* -// FIXME store parent item as object or target -// (and update to json storage) - - if (activity_match($item['verb'],ACTIVITY_TAG)) { - $r = q("SELECT * from item,contact WHERE - item.contact-id=contact.id AND item.mid='%s';", - dbesc($item['parent_mid'])); - if(count($r)==0) return; - $obj=$r[0]; - - $author = '[zrl=' . zid($item['author-link']) . ']' . $item['author-name'] . '[/zrl]'; - $objauthor = '[zrl=' . zid($obj['author-link']) . ']' . $obj['author-name'] . '[/zrl]'; - - switch($obj['verb']){ - case ACTIVITY_POST: - switch ($obj['obj_type']){ - case ACTIVITY_OBJ_EVENT: - $post_type = t('event'); - break; - default: - $post_type = t('status'); - } - break; - default: - if($obj['resource_id']){ - $post_type = t('photo'); - $m=array(); preg_match("/\[[zu]rl=([^]]*)\]/", $obj['body'], $m); - $rr['plink'] = $m[1]; - } else { - $post_type = t('status'); - } - } - $plink = '[zrl=' . $obj['plink'] . ']' . $post_type . '[/zrl]'; - -// $parsedobj = parse_xml_string($xmlhead.$item['obj']); - - $tag = sprintf('#[zrl=%s]%s[/zrl]', $parsedobj->id, $parsedobj->content); - $item['body'] = sprintf( t('%1$s tagged %2$s\'s %3$s with %4$s'), $author, $objauthor, $plink, $tag ); - - } - - if (activity_match($item['verb'],ACTIVITY_FAVORITE)){ - - if ($item['obj_type']== "") - return; - - $Aname = $item['author']['xchan_name']; - $Alink = $item['author']['xchan_url']; - - $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">"; - -// $obj = parse_xml_string($xmlhead.$item['obj']); - if(strlen($obj->id)) { - $r = q("select * from item where mid = '%s' and uid = %d limit 1", - dbesc($obj->id), - intval($item['uid']) - ); - if(count($r) && $r[0]['plink']) { - $target = $r[0]; - $Bname = $target['author-name']; - $Blink = $target['author-link']; - $A = '[zrl=' . zid($Alink) . ']' . $Aname . '[/zrl]'; - $B = '[zrl=' . zid($Blink) . ']' . $Bname . '[/zrl]'; - $P = '[zrl=' . $target['plink'] . ']' . t('post/item') . '[/zrl]'; - $item['body'] = sprintf( t('%1$s marked %2$s\'s %3$s as favorite'), $A, $B, $P)."\n"; - - } - } - } -*/ - -/* - $matches = null; - if(strpos($item['body'],'[zrl') !== false) { - if(preg_match_all('/@\[zrl=(.*?)\]/is',$item['body'],$matches,PREG_SET_ORDER)) { - foreach($matches as $mtch) { - if(! strpos($mtch[1],'zid=')) - $item['body'] = str_replace($mtch[0],'@[zrl=' . zid($mtch[1]). ']',$item['body']); - } - } - } - - if(strpos($item['body'],'[zmg') !== false) { - // add zid's to public images - if(preg_match_all('/\[zrl=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[zmg(.*?)\]h(.*?)\[\/zmg\]\[\/zrl\]/is',$item['body'],$matches,PREG_SET_ORDER)) { - foreach($matches as $mtch) { - $item['body'] = str_replace($mtch[0],'[zrl=' . zid( $mtch[1] . '/photos/' . $mtch[2] . '/image/' . $mtch[3]) . '][zmg' . $mtch[4] . ']h' . $mtch[5] . '[/zmg][/zrl]',$item['body']); - } - } - } -*/ - - } /** @@ -448,7 +345,7 @@ function count_descendants($item) { * @return boolean */ function visible_activity($item) { - $hidden_activities = [ ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_SHARE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE, ACTIVITY_POLLRESPONSE ]; + $hidden_activities = ['Like', 'Dislike', 'Accept', 'Reject', 'TentativeAccept', ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_SHARE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE]; if(intval($item['item_notshown'])) return false; @@ -483,27 +380,6 @@ function visible_activity($item) { return true; } -/** - * @brief Check if a given activity is an edit activity - * - * - * @param array $item - * @return boolean - */ - -function is_edit_activity($item) { - - $post_types = [ ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT, basename(ACTIVITY_OBJ_NOTE), basename(ACTIVITY_OBJ_COMMENT)]; - - // In order to share edits with networks which have no concept of editing, we'll create - // separate activities to indicate the edit. Our network will not require them, since our - // edits are automatically applied and the activity indicated. - - if(($item['verb'] === ACTIVITY_UPDATE) && (in_array($item['obj_type'],$post_types))) - return true; - - return false; -} /** * @brief "Render" a conversation or list of items for HTML display. @@ -726,9 +602,9 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa $is_new = false; if($mode === 'search' || $mode === 'community') { - if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) - && ($item['id'] != $item['parent'])) + if(activity_match($item['verb'], ['Like', 'Dislike', ACTIVITY_LIKE, ACTIVITY_DISLIKE]) && $item['id'] != $item['parent']) { continue; + } } $sp = false; @@ -1192,7 +1068,7 @@ function builtin_activity_puller($item, &$conv_responses) { // if this item is a post or comment there's nothing for us to do here, just return. - if(activity_match($item['verb'],ACTIVITY_POST) && $item['obj_type'] !== 'Answer') + if(activity_match($item['verb'], ['Create', ACTIVITY_POST]) && $item['obj_type'] !== 'Answer') return; foreach($conv_responses as $mode => $v) { @@ -1201,10 +1077,10 @@ function builtin_activity_puller($item, &$conv_responses) { switch($mode) { case 'like': - $verb = ACTIVITY_LIKE; + $verb = ['Like', ACTIVITY_LIKE]; break; case 'dislike': - $verb = ACTIVITY_DISLIKE; + $verb = ['Dislike', ACTIVITY_DISLIKE]; break; case 'agree': $verb = ACTIVITY_AGREE; @@ -1216,16 +1092,16 @@ function builtin_activity_puller($item, &$conv_responses) { $verb = ACTIVITY_ABSTAIN; break; case 'attendyes': - $verb = ACTIVITY_ATTEND; + $verb = ['Accept', ACTIVITY_ATTEND]; break; case 'attendno': - $verb = ACTIVITY_ATTENDNO; + $verb = ['Reject', ACTIVITY_ATTENDNO]; break; case 'attendmaybe': - $verb = ACTIVITY_ATTENDMAYBE; + $verb = ['TentativeAccept', ACTIVITY_ATTENDMAYBE]; break; case 'answer': - $verb = ACTIVITY_POST; + $verb = ['Create', ACTIVITY_POST]; break; case 'announce': $verb = 'Announce'; diff --git a/include/event.php b/include/event.php index dde5c405d..701f3c330 100644 --- a/include/event.php +++ b/include/event.php @@ -1311,7 +1311,7 @@ function event_store_item($arr, $event) { dbesc($sig), intval($r[0]['item_flags']), intval($private), - dbesc(ACTIVITY_OBJ_EVENT), + dbesc('Event'), intval($r[0]['id']), intval($arr['uid']) ); @@ -1408,7 +1408,7 @@ function event_store_item($arr, $event) { $item_arr['resource_type'] = 'event'; $item_arr['resource_id'] = $event['event_hash']; - $item_arr['obj_type'] = ACTIVITY_OBJ_EVENT; + $item_arr['obj_type'] = 'Event'; $item_arr['body'] = $prefix . format_event_bbcode($arr); // if it's local send the permalink to the channel page. diff --git a/include/feedutils.php b/include/feedutils.php index a2d52c698..f05c15414 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -184,7 +184,7 @@ function construct_verb($item) { if ($item['verb']) return $item['verb']; - return ACTIVITY_POST; + return 'Create'; } function construct_activity_object($item) { @@ -305,7 +305,7 @@ function get_atom_author($feed, $item) { } $rawactor = $item->get_item_tags(NAMESPACE_ACTIVITY, 'actor'); - if($rawactor && activity_match($rawactor[0]['child'][NAMESPACE_ACTIVITY]['obj_type'][0]['data'], ACTIVITY_OBJ_PERSON)) { + if($rawactor && activity_match($rawactor[0]['child'][NAMESPACE_ACTIVITY]['obj_type'][0]['data'], ['Person', ACTIVITY_OBJ_PERSON])) { $base = $rawactor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']; if($base && count($base)) { foreach($base as $link) { @@ -350,7 +350,7 @@ function get_atom_author($feed, $item) { $rawactor = $feed->get_feed_tags(NAMESPACE_ACTIVITY, 'subject'); - if($rawactor && activity_match($rawactor[0]['child'][NAMESPACE_ACTIVITY]['obj_type'][0]['data'],ACTIVITY_OBJ_PERSON)) { + if($rawactor && activity_match($rawactor[0]['child'][NAMESPACE_ACTIVITY]['obj_type'][0]['data'], ['Person', ACTIVITY_OBJ_PERSON])) { $base = $rawactor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']; if($base && count($base)) { @@ -508,36 +508,17 @@ function get_atom_elements($feed, $item) { } } - $ostatus_protocol = ($ostatus_conversation || (x($res,'verb') && $res['verb']) ? true : false); - $mastodon = (($item->get_item_tags('http://mastodon.social/schema/1.0','scope')) ? true : false); if($mastodon) { - $ostatus_protocol = true; if(($mastodon[0]['data']) && ($mastodon[0]['data'] !== 'public')) $res['item_private'] = 1; } - logger('ostatus_protocol: ' . intval($ostatus_protocol), LOGGER_DEBUG); - $apps = $item->get_item_tags(NAMESPACE_STATUSNET, 'notice_info'); if($apps && $apps[0]['attribs']['']['source']) { $res['app'] = strip_tags(unxmlify($apps[0]['attribs']['']['source'])); } - if($ostatus_protocol) { - - // translate OStatus unfollow to activity streams if it happened to get selected - - if((x($res,'verb')) && ($res['verb'] === 'http://ostatus.org/schema/1.0/unfollow')) { - $res['verb'] = ACTIVITY_UNFOLLOW; - } - - // And OStatus 'favorite' is pretty much what we call 'like' on other networks - - if((x($res,'verb')) && ($res['verb'] === ACTIVITY_FAVORITE)) { - $res['verb'] = ACTIVITY_LIKE; - } - } /* * If there's a copy of the body content which is guaranteed to have survived mangling in transit, use it. @@ -600,10 +581,7 @@ function get_atom_elements($feed, $item) { $terms = []; - if($ostatus_protocol) { - $res['title'] = ''; - } - elseif($res['plink'] && $res['title']) { + if($res['plink'] && $res['title']) { $res['body'] = '#^[url=' . $res['plink'] . ']' . $res['title'] . '[/url]' . "\n\n" . $res['body']; $terms[] = array( 'otype' => TERM_OBJ_POST, @@ -814,7 +792,7 @@ function get_atom_elements($feed, $item) { if(array_key_exists('verb',$res) && $res['verb'] === ACTIVITY_SHARE - && array_key_exists('obj_type',$res) && in_array($res['obj_type'], [ ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT, ACTIVITY_OBJ_ACTIVITY ] )) { + && array_key_exists('obj_type',$res) && in_array($res['obj_type'], ['Note', ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT])) { feed_get_reshare($res,$item); } @@ -1197,7 +1175,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { // Update content if 'updated' changes if($r) { - if(activity_match($datarray['verb'],ACTIVITY_DELETE) + if(activity_match($datarray['verb'], ['Delete', ACTIVITY_DELETE]) && $datarray['author_xchan'] === $r[0]['author_xchan']) { if(! intval($r[0]['item_deleted'])) { logger('deleting item ' . $r[0]['id'] . ' mid=' . $datarray['mid'], LOGGER_DEBUG); @@ -1361,7 +1339,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { // allow likes of comments - if($item_parent_mid && activity_match($datarray['verb'],ACTIVITY_LIKE)) { + if($item_parent_mid && activity_match($datarray['verb'], ['Like', ACTIVITY_LIKE])) { $datarray['thr_parent'] = $item_parent_mid[0]['parent_mid']; } @@ -1465,7 +1443,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { // Update content if 'updated' changes if($r) { - if(isset($datarray['verb']) && activity_match($datarray['verb'], ACTIVITY_DELETE) + if(isset($datarray['verb']) && activity_match($datarray['verb'], ['Delete', ACTIVITY_DELETE]) && isset($datarray['author_xchan']) && $datarray['author_xchan'] === $r[0]['author_xchan']) { if(! intval($r[0]['item_deleted'])) { logger('deleting item ' . $r[0]['id'] . ' mid=' . $datarray['mid'], LOGGER_DEBUG); @@ -1955,7 +1933,7 @@ function atom_entry($item, $type, $author, $owner, $comment = false, $cid = 0, $ $o .= '<thr:in-reply-to ref="' . xmlify($parent_item) . '" type="text/html" href="' . xmlify($item['plink']) . '" />' . "\r\n"; } - if(activity_match($item['obj_type'],ACTIVITY_OBJ_EVENT) && activity_match($item['verb'],ACTIVITY_POST)) { + if((activity_match($item['obj_type'], ACTIVITY_OBJ_EVENT) || activity_match($item['obj_type'], 'Event')) && activity_match($item['verb'],['Create', ACTIVITY_POST])) { $obj = ((is_array($item['obj'])) ? $item['obj'] : json_decode($item['obj'],true)); $o .= '<title>' . xmlify($item['title']) . '</title>' . "\r\n"; diff --git a/include/items.php b/include/items.php index f30a986bb..f689cc7b5 100644 --- a/include/items.php +++ b/include/items.php @@ -468,10 +468,8 @@ function post_activity_item($arr, $allow_code = false, $deliver = true) { $arr['owner_xchan'] = ((x($arr,'owner_xchan')) ? $arr['owner_xchan'] : $channel['channel_hash']); $arr['author_xchan'] = ((x($arr,'author_xchan')) ? $arr['author_xchan'] : $observer['xchan_hash']); - $arr['verb'] = ((x($arr,'verb')) ? $arr['verb'] : ACTIVITY_POST); - $arr['obj_type'] = ((x($arr,'obj_type')) ? $arr['obj_type'] : ACTIVITY_OBJ_NOTE); - if(($is_comment) && ($arr['obj_type'] === ACTIVITY_OBJ_NOTE)) - $arr['obj_type'] = ACTIVITY_OBJ_COMMENT; + $arr['verb'] = ((x($arr,'verb')) ? $arr['verb'] : 'Create'); + $arr['obj_type'] = ((x($arr,'obj_type')) ? $arr['obj_type'] : 'Note'); if(! ( array_key_exists('allow_cid',$arr) || array_key_exists('allow_gid',$arr) || array_key_exists('deny_cid',$arr) || array_key_exists('deny_gid',$arr))) { @@ -1751,8 +1749,8 @@ function item_store($arr, $allow_exec = false, $deliver = true) { $arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : ''); $arr['parent_mid'] = ((x($arr,'parent_mid')) ? notags(trim($arr['parent_mid'])) : ''); $arr['thr_parent'] = ((x($arr,'thr_parent')) ? notags(trim($arr['thr_parent'])) : $arr['parent_mid']); - $arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : ACTIVITY_POST); - $arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : ACTIVITY_OBJ_NOTE); + $arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : 'Create'); + $arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : 'Note'); $arr['obj'] = ((x($arr,'obj')) ? trim($arr['obj']) : ''); $arr['tgt_type'] = ((x($arr,'tgt_type')) ? notags(trim($arr['tgt_type'])) : ''); $arr['target'] = ((x($arr,'target')) ? trim($arr['target']) : ''); @@ -1827,9 +1825,6 @@ function item_store($arr, $allow_exec = false, $deliver = true) { return $ret; } - if(($arr['obj_type'] == ACTIVITY_OBJ_NOTE) && (! $arr['obj'])) - $arr['obj_type'] = ACTIVITY_OBJ_COMMENT; - // is the new message multi-level threaded? // even though we don't support it now, preserve the info // and re-attach to the conversation parent. @@ -2448,7 +2443,7 @@ function send_status_notifications($post_id,$item) { $type = ((intval($item['item_private']) === 2) ? NOTIFY_MAIL : NOTIFY_COMMENT); - if(array_key_exists('verb',$item) && (activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE))) { + if(array_key_exists('verb',$item) && activity_match($item['verb'], ['Like', 'Dislike', ACTIVITY_LIKE, ACTIVITY_DISLIKE])) { $type = NOTIFY_LIKE; @@ -2493,7 +2488,7 @@ function send_status_notifications($post_id,$item) { // but it will be extremely rare for this to be wrong. if(($xx['verb'] === ACTIVITY_UNFOLLOW) - && ($xx['obj_type'] === ACTIVITY_OBJ_NOTE || $xx['obj_type'] === ACTIVITY_OBJ_PHOTO) + && (in_array($xx['obj_type'], ['Note', 'Image', ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_PHOTO])) && ($xx['parent'] != $xx['id'])) $unfollowed = true; } @@ -2636,7 +2631,7 @@ function tag_deliver($uid, $item_id) { if (stristr($item['verb'],ACTIVITY_POKE)) { $poke_notify = true; - if(($item['obj_type'] == "") || ($item['obj_type'] !== ACTIVITY_OBJ_PERSON) || (! $item['obj'])) + if(($item['obj_type'] == "") || (!in_array($item['obj_type'], ['Person', ACTIVITY_OBJ_PERSON])) || (! $item['obj'])) $poke_notify = false; $obj = json_decode($item['obj'],true); @@ -3302,7 +3297,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $group = false $arr['owner_xchan'] = $channel['channel_hash']; $arr['obj_type'] = $item['obj_type']; - $arr['verb'] = ACTIVITY_POST; + $arr['verb'] = 'Create'; $arr['allow_cid'] = $channel['channel_allow_cid']; $arr['allow_gid'] = $channel['channel_allow_gid']; @@ -5156,83 +5151,13 @@ function fix_attached_permissions($uid, $body, $str_contact_allow, $str_group_al } } -function item_create_edit_activity($post) { - - if((! $post) || (! $post['item']) || ($post['item']['item_type'] != ITEM_TYPE_POST)) - return; - - $update_item = $post['item']; - - $new_item = $update_item; - - $author = q("select * from xchan where xchan_hash = '%s' limit 1", - dbesc($new_item['author_xchan']) - ); - if($author) - $item_author = $author[0]; - - - $new_item['id'] = 0; - $new_item['parent'] = 0; - $new_item['uuid'] = item_message_id(); - $new_item['mid'] = z_root() . '/item/' . $new_item['uuid']; - - $new_item['body'] = sprintf( t('[Edited %s]'), (($update_item['item_thread_top']) ? t('Post','edit_activity') : t('Comment','edit_activity'))); - - $new_item['body'] .= "\n\n"; - $new_item['body'] .= $update_item['body']; - - $new_item['sig'] = ''; - - $new_item['verb'] = ACTIVITY_UPDATE; - $new_item['item_thread_top'] = 0; - $new_item['created'] = $new_item['edited'] = datetime_convert(); - $new_item['obj_type'] = (($update_item['item_thread_top']) ? ACTIVITY_OBJ_NOTE : ACTIVITY_OBJ_COMMENT); - $new_item['obj'] = json_encode(array( - 'type' => $new_item['obj_type'], - 'id' => $update_item['mid'], - 'parent' => $update_item['parent_mid'], - 'link' => array(array('rel' => 'alternate','type' => 'text/html', 'href' => $update_item['plink'])), - 'title' => $update_item['title'], - 'content' => $update_item['body'], - 'created' => $update_item['created'], - 'edited' => $update_item['edited'], - 'author' => array( - 'name' => $item_author['xchan_name'], - 'address' => $item_author['xchan_addr'], - 'guid' => $item_author['xchan_guid'], - 'guid_sig' => $item_author['xchan_guid_sig'], - 'link' => array( - array('rel' => 'alternate', 'type' => 'text/html', 'href' => $item_author['xchan_url']), - array('rel' => 'photo', 'type' => $item_author['xchan_photo_mimetype'], 'href' => $item_author['xchan_photo_m'])), - ), - )); - - $x = post_activity_item($new_item); - - $post_id = $x['id']; - if($post_id) { - $r = q("select * from item where id = %d", - intval($post_id) - ); - if($r) { - xchan_query($r); - $sync_item = fetch_post_tags($r); - Libsync::build_sync_packet($new_item['uid'],array('item' => array(encode_item($sync_item[0],true)))); - } - } - - Master::Summon([ 'Notifier', 'edit_activity', $post_id ]); -} /** * @brief copies an entire conversation from the pubstream to this channel's stream * which will allow you to interact with it. */ - - function copy_of_pubitem($channel,$mid) { $result = null; diff --git a/include/photos.php b/include/photos.php index 8d83b8475..5e993e15f 100644 --- a/include/photos.php +++ b/include/photos.php @@ -455,7 +455,7 @@ function photo_upload($channel, $observer, $args) { $item['body'] = $summary; $item['mimetype'] = 'text/bbcode'; - $item['obj_type'] = ACTIVITY_OBJ_PHOTO; + $item['obj_type'] = 'Image'; $object['id'] = $item['mid']; $object['diaspora:guid'] = $item['uuid']; @@ -511,8 +511,8 @@ function photo_upload($channel, $observer, $args) { 'allow_gid' => $ac['allow_gid'], 'deny_cid' => $ac['deny_cid'], 'deny_gid' => $ac['deny_gid'], - 'verb' => ACTIVITY_POST, - 'obj_type' => ACTIVITY_OBJ_PHOTO, + 'verb' => 'Create', + 'obj_type' => 'Image', 'obj' => json_encode($object), 'tgt_type' => 'orderedCollection', 'target' => json_encode($target), diff --git a/include/sharedwithme.php b/include/sharedwithme.php deleted file mode 100644 index b342f51d5..000000000 --- a/include/sharedwithme.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php - -function apply_updates() { - - //check for updated items and remove them - $x = q("SELECT mid, max(obj) AS obj FROM item WHERE verb = '%s' AND obj_type = '%s' GROUP BY mid", - dbesc(ACTIVITY_UPDATE), - dbesc(ACTIVITY_OBJ_FILE) - ); - - if($x) { - - foreach($x as $xx) { - - $object = json_decode($xx['obj'],true); - - $d_mid = $object['d_mid']; - $u_mid = $xx['mid']; - - $y = q("DELETE FROM item WHERE obj_type = '%s' AND (verb = '%s' AND mid = '%s') OR (verb = '%s' AND mid = '%s')", - dbesc(ACTIVITY_OBJ_FILE), - dbesc(ACTIVITY_POST), - dbesc($d_mid), - dbesc(ACTIVITY_UPDATE), - dbesc($u_mid) - ); - - } - - } - -} diff --git a/include/text.php b/include/text.php index 052c26594..ea9cf45e1 100644 --- a/include/text.php +++ b/include/text.php @@ -1776,7 +1776,7 @@ function prepare_body(&$item,$attach = false,$opts = false) { $s = ''; $photo = ''; - $is_photo = ((($item['verb'] === ACTIVITY_POST) && ($item['obj_type'] === ACTIVITY_OBJ_PHOTO)) ? true : false); + $is_photo = (((in_array($item['verb'], ['Create', ACTIVITY_POST])) && (in_array($item['obj_type'], ['Image', ACTIVITY_OBJ_PHOTO]))) ? true : false); if ($is_photo) { $object = json_decode($item['obj'],true); @@ -1821,7 +1821,7 @@ function prepare_body(&$item,$attach = false,$opts = false) { } - $poll = (($item['obj_type'] === 'Question' && in_array($item['verb'],[ ACTIVITY_POST, ACTIVITY_UPDATE, ACTIVITY_SHARE ])) ? format_poll($item, $s, $opts) : false); + $poll = (($item['obj_type'] === 'Question' && in_array($item['verb'],['Create', ACTIVITY_POST, ACTIVITY_UPDATE, ACTIVITY_SHARE])) ? format_poll($item, $s, $opts) : false); if ($poll) { $s = $poll; } @@ -2120,7 +2120,7 @@ function prepare_text($text, $content_type = 'text/bbcode', $opts = false) { function create_export_photo_body(&$item) { - if(($item['verb'] === ACTIVITY_POST) && ($item['obj_type'] === ACTIVITY_OBJ_PHOTO)) { + if((in_array($item['verb'], ['Create', ACTIVITY_POST])) && (in_array($item['obj_type'], ['Image', ACTIVITY_OBJ_PHOTO]))) { $j = json_decode($item['obj'],true); if($j) { $item['body'] .= "\n\n" . (($j['body']) ? $j['body'] : $j['bbcode']); |