aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-10-06 08:25:53 +0000
committerMario <mario@mariovavti.com>2020-10-06 08:25:53 +0000
commitb37c8bf9287efd3ae810560be356ba96848a2573 (patch)
treec094f9a8048992309d11e8075bdb0764c5b9c444 /Zotlabs
parent923ae14c471221fb3b199894a153eb136c477b65 (diff)
downloadvolse-hubzilla-b37c8bf9287efd3ae810560be356ba96848a2573.tar.gz
volse-hubzilla-b37c8bf9287efd3ae810560be356ba96848a2573.tar.bz2
volse-hubzilla-b37c8bf9287efd3ae810560be356ba96848a2573.zip
code optimisation
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Lib/Activity.php15
-rw-r--r--Zotlabs/Lib/ActivityStreams.php15
2 files changed, 17 insertions, 13 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 9a31304d1..13ba224cb 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -652,7 +652,7 @@ class Activity {
- static function encode_activity($i, $dismiss_deleted = false) {
+ static function encode_activity($i, $recurse = false) {
$ret = [];
$reply = false;
@@ -666,10 +666,10 @@ class Activity {
$ret['type'] = self::activity_mapper($i['verb']);
$fragment = '';
- if (intval($i['item_deleted']) && !$dismiss_deleted) {
+ if (intval($i['item_deleted']) && !$recurse) {
$is_response = false;
- if (in_array($ret['type'], [ 'Like', 'Dislike', 'Accept', 'Reject', 'TentativeAccept', 'TentativeReject' ])) {
+ if (ActivityStreams::is_response_activity($ret['type'])) {
$ret['type'] = 'Undo';
$fragment = 'undo';
$is_response = true;
@@ -686,12 +686,11 @@ class Activity {
else
return [];
-// $ret['object'] = str_replace('/item/','/activity/',$i['mid']);
-
$obj = (($is_response) ? self::encode_activity($i,true) : self::encode_item($i,true));
if ($obj) {
- // do not leak private content in deletes
- unset($obj['object']);
+ if (array_path_exists('object/id',$obj)) {
+ $obj['object'] = $obj['object']['id'];
+ }
unset($obj['cc']);
$obj['to'] = [ ACTIVITY_PUBLIC_INBOX ];
$ret['object'] = $obj;
@@ -2052,7 +2051,7 @@ class Activity {
$s['expires'] = datetime_convert('UTC','UTC',$act->obj['expires']);
}
- if(in_array($act->type, [ 'Like', 'Dislike', 'Flag', 'Block', 'Announce', 'Accept', 'Reject', 'TentativeAccept', 'emojiReaction' ])) {
+ if(ActivityStreams::is_response_activity($act->type)) {
$response_activity = true;
diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php
index b1ef59364..a0ba52aa6 100644
--- a/Zotlabs/Lib/ActivityStreams.php
+++ b/Zotlabs/Lib/ActivityStreams.php
@@ -274,12 +274,19 @@ class ActivityStreams {
return self::fetch($url);
}
- static function fetch($url,$channel = null) {
- return Activity::fetch($url,$channel);
+ static function fetch($url, $channel = null) {
+ return Activity::fetch($url, $channel);
}
static function is_an_actor($s) {
- return(in_array($s,[ 'Application','Group','Organization','Person','Service' ]));
+ return (in_array($s, [ 'Application','Group','Organization','Person','Service' ]));
+ }
+
+ static function is_response_activity($s) {
+ if (! $s) {
+ return false;
+ }
+ return (in_array($s, [ 'Like', 'Dislike', 'Flag', 'Block', 'Announce', 'Accept', 'Reject', 'TentativeAccept', 'TentativeReject', 'emojiReaction', 'EmojiReaction', 'EmojiReact' ]));
}
/**
@@ -402,7 +409,6 @@ class ActivityStreams {
return $x;
}
-
static function is_as_request() {
$x = getBestSupportedMimeType([
@@ -415,5 +421,4 @@ class ActivityStreams {
}
-
}