aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/Activity.php62
-rw-r--r--Zotlabs/Lib/Libzot.php11
2 files changed, 47 insertions, 26 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 7cc77f124..d1a1a1385 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -644,41 +644,29 @@ class Activity {
}
$ret['type'] = self::activity_mapper($i['verb']);
-
-
+ $fragment = '';
if (intval($i['item_deleted'])) {
- $is_response = false;
if (in_array($ret['type'], [ 'Like', 'Dislike', 'Accept', 'Reject', 'TentativeAccept', 'TentativeReject' ])) {
$ret['type'] = 'Undo';
- $is_response = true;
+ $fragment = 'undo';
}
else {
$ret['type'] = 'Delete';
+ $fragment = 'delete';
}
- $ret['id'] = str_replace('/item/','/activity/',$i['mid']) . '#delete';
+
+ $ret['id'] = str_replace('/item/','/activity/',$i['mid']) . '#' . $fragment;
$actor = self::encode_person($i['author'],false);
if ($actor)
$ret['actor'] = $actor;
else
return [];
- if ($i['obj'] && !$is_response) {
- if (! is_array($i['obj'])) {
- $i['obj'] = json_decode($i['obj'],true);
- }
- $obj = self::encode_object($i['obj']);
- if ($obj)
- $ret['object'] = $obj;
- else
- return [];
- }
- else {
- $obj = self::encode_item($i);
- if ($obj)
- $ret['object'] = $obj;
- else
- return [];
+ $ret['object'] = str_replace('/item/','/activity/',$i['mid']);
+
+ if($i['id'] != $i['parent']) {
+ $ret['inReplyTo'] = $i['thr_parent'];
}
$ret['to'] = [ ACTIVITY_PUBLIC_INBOX ];
@@ -1166,7 +1154,9 @@ class Activity {
'Question' => 'Question',
'Document' => 'Document',
'Audio' => 'Audio',
- 'Video' => 'Video'
+ 'Video' => 'Video',
+ 'Delete' => 'Delete',
+ 'Undo' => 'Undo'
];
call_hooks('activity_obj_decode_mapper',$objs);
@@ -1203,7 +1193,9 @@ class Activity {
'Invite' => 'Invite',
'Question' => 'Question',
'Audio' => 'Audio',
- 'Video' => 'Video'
+ 'Video' => 'Video',
+ 'Delete' => 'Delete',
+ 'Undo' => 'Undo'
];
call_hooks('activity_obj_mapper',$objs);
@@ -3115,5 +3107,29 @@ class Activity {
return $content;
}
+ // Find either an Authorization: Bearer token or 'token' request variable
+ // in the current web request and return it
+
+ static function token_from_request() {
+
+ foreach ( [ 'REDIRECT_REMOTE_USER', 'HTTP_AUTHORIZATION' ] as $s ) {
+ $auth = ((array_key_exists($s,$_SERVER) && strpos($_SERVER[$s],'Bearer ') === 0)
+ ? str_replace('Bearer ', EMPTY_STR, $_SERVER[$s])
+ : EMPTY_STR
+ );
+ if ($auth) {
+ break;
+ }
+ }
+
+ if (! $auth) {
+ if (array_key_exists('token',$_REQUEST) && $_REQUEST['token']) {
+ $auth = $_REQUEST['token'];
+ }
+ }
+
+ return $auth;
+ }
+
}
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index 87da5ff7a..d7285ca12 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -1496,13 +1496,14 @@ class Libzot {
// Try again using the delivery channel credentials.
// We will also need to re-parse the $item array,
// but preserve any values that were set during anonymous parsing.
-
+
$o = Activity::fetch($act->obj,$channel);
if($o) {
$act->obj = $o;
$arr = array_merge(Activity::decode_note($act),$arr);
}
else {
+
$DR->update('Incomplete or corrupt activity');
$result[] = $DR->get();
continue;
@@ -2116,6 +2117,10 @@ class Libzot {
$item_found = false;
$post_id = 0;
+ $m = parse_url($item['mid']);
+ unset($m['fragment']);
+ $normalised = unparse_url($m);
+
// reactions such as like and dislike could have an mid with /activity/ in it.
// Check for both forms in order to prevent duplicates.
@@ -2124,8 +2129,8 @@ class Libzot {
dbesc($sender),
dbesc($sender),
dbesc($sender),
- dbesc(str_replace('/activity/', '/item/', $item['mid'])),
- dbesc(str_replace('/item/', '/activity/', $item['mid'])),
+ dbesc($normalised),
+ dbesc(str_replace('/activity/', '/item/', $normalised)),
intval($uid)
);