aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2024-02-25 19:29:50 +0000
committerMario <mario@mariovavti.com>2024-02-25 19:29:50 +0000
commit3dd739424718596b94f5a61d2015388db2491999 (patch)
tree336e19816349b7b0c3d5c4ba49bf4bf19ae4e46a /Zotlabs/Lib
parentb860b730a9fe718ad35cd918ab237afe42cf386c (diff)
downloadvolse-hubzilla-3dd739424718596b94f5a61d2015388db2491999.tar.gz
volse-hubzilla-3dd739424718596b94f5a61d2015388db2491999.tar.bz2
volse-hubzilla-3dd739424718596b94f5a61d2015388db2491999.zip
AS2
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/Activity.php142
-rw-r--r--Zotlabs/Lib/Enotify.php12
-rw-r--r--Zotlabs/Lib/Libzot.php2
-rw-r--r--Zotlabs/Lib/Share.php2
-rw-r--r--Zotlabs/Lib/ThreadItem.php2
-rw-r--r--Zotlabs/Lib/ThreadStream.php2
6 files changed, 31 insertions, 131 deletions
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;
}