diff options
author | Max Kostikov <max@kostikov.co> | 2021-02-27 19:47:26 +0000 |
---|---|---|
committer | Max Kostikov <max@kostikov.co> | 2021-02-27 19:47:26 +0000 |
commit | 1d899d387e89b67245249204249052bf7b65f5c1 (patch) | |
tree | 86b8ed42e016bb9cbfcb5ececbc03585a941a23a /Zotlabs/Lib/Activity.php | |
parent | 5440a65607f3c67cc6ecacbf2d54c5895e5bc212 (diff) | |
parent | fbb1d6aa41d9eb7a27b4a8bc79747ac0797db0c7 (diff) | |
download | volse-hubzilla-1d899d387e89b67245249204249052bf7b65f5c1.tar.gz volse-hubzilla-1d899d387e89b67245249204249052bf7b65f5c1.tar.bz2 volse-hubzilla-1d899d387e89b67245249204249052bf7b65f5c1.zip |
Merge branch 'dev' into 'dev'
Dev sync
See merge request kostikov/core!2
Diffstat (limited to 'Zotlabs/Lib/Activity.php')
-rw-r--r-- | Zotlabs/Lib/Activity.php | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index d0799bb66..5fefb2979 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -434,7 +434,7 @@ class Activity { $ret['published'] = datetime_convert('UTC', 'UTC', $i['created'], ATOM_TIME); if ($i['created'] !== $i['edited']) $ret['updated'] = datetime_convert('UTC', 'UTC', $i['edited'], ATOM_TIME); - if ($i['expires'] <= NULL_DATE) { + if ($i['expires'] > NULL_DATE) { $ret['expires'] = datetime_convert('UTC', 'UTC', $i['expires'], ATOM_TIME); } @@ -461,7 +461,7 @@ class Activity { $ret['directMessage'] = true; } - if (array_key_exists('comments_closed', $i) && $i['comments_closed'] !== EMPTY_STR && $i['comments_closed'] !== NULL_DATE) { + if (array_key_exists('comments_closed', $i) && $i['comments_closed'] !== EMPTY_STR && $i['comments_closed'] > NULL_DATE) { if ($ret['commentPolicy']) { $ret['commentPolicy'] .= ' '; } @@ -1120,6 +1120,34 @@ class Activity { return $ret; } + static function encode_item_object($item, $elm = 'obj') { + $ret = []; + + if ($item[$elm]) { + if (! is_array($item[$elm])) { + $item[$elm] = json_decode($item[$elm],true); + } + if ($item[$elm]['type'] === ACTIVITY_OBJ_PHOTO) { + $item[$elm]['id'] = $item['mid']; + } + + $obj = self::encode_object($item[$elm]); + if ($obj) + return $obj; + else + return []; + } + else { + $obj = self::encode_item($item); + if ($obj) + return $obj; + else + return []; + } + + } + + static function activity_mapper($verb) { if (strpos($verb, '/') === false) { @@ -3303,17 +3331,17 @@ class Activity { $ret = false; foreach ($attach as $a) { - if (strpos($a['type'], 'image') !== false) { + if (array_key_exists('type',$a) && stripos($a['type'], 'image') !== false) { if (self::media_not_in_body($a['href'], $body)) { $ret .= "\n\n" . '[img]' . $a['href'] . '[/img]'; } } - if (array_key_exists('type', $a) && strpos($a['type'], 'video') === 0) { + if (array_key_exists('type', $a) && stripos($a['type'], 'video') !== false) { if (self::media_not_in_body($a['href'], $body)) { $ret .= "\n\n" . '[video]' . $a['href'] . '[/video]'; } } - if (array_key_exists('type', $a) && strpos($a['type'], 'audio') === 0) { + if (array_key_exists('type', $a) && stripos($a['type'], 'audio') !== false) { if (self::media_not_in_body($a['href'], $body)) { $ret .= "\n\n" . '[audio]' . $a['href'] . '[/audio]'; } |