+ private static function convertMentions($body)
+ {
+ $URLSearchString = "^\[\]";
+ $body = preg_replace("/\[url\=([$URLSearchString]*)\]([#@!])(.*?)\[\/url\]/ism", '$2[url=$1]$3[/url]', $body);
+
+ return $body;
+ }
+
+ private static function constructTagList($tags, $sensitive)
+ {
+ if (empty($tags)) {
+ return '';
+ }
+
+ $tag_text = '';
+ foreach ($tags as $tag) {
+ if (in_array($tag['type'], ['Mention', 'Hashtag'])) {
+ if (!empty($tag_text)) {
+ $tag_text .= ',';
+ }
+
+ $tag_text .= substr($tag['name'], 0, 1) . '[url=' . $tag['href'] . ']' . substr($tag['name'], 1) . '[/url]';
+ }
+ }
+
+ /// @todo add nsfw for $sensitive
+
+ return $tag_text;
+ }
+
+ private static function constructAttachList($attachments, $item)
+ {
+ if (empty($attachments)) {
+ return $item;
+ }
+
+ foreach ($attachments as $attach) {
+ $filetype = strtolower(substr($attach['mediaType'], 0, strpos($attach['mediaType'], '/')));
+ if ($filetype == 'image') {
+ $item['body'] .= "\n[img]".$attach['url'].'[/img]';
+ } else {
+ if (!empty($item["attach"])) {
+ $item["attach"] .= ',';
+ } else {
+ $item["attach"] = '';
+ }
+ if (!isset($attach['length'])) {
+ $attach['length'] = "0";
+ }
+ $item["attach"] .= '[attach]href="'.$attach['url'].'" length="'.$attach['length'].'" type="'.$attach['mediaType'].'" title="'.defaults($attach, 'name', '').'"[/attach]';
+ }
+ }
+
+ return $item;
+ }
+
+ private static function createItem($activity, $body)
+ {
+ $item = [];
+ $item['verb'] = ACTIVITY_POST;
+ $item['parent-uri'] = $activity['reply-to-uri'];
+
+ if ($activity['reply-to-uri'] == $activity['uri']) {
+ $item['gravity'] = GRAVITY_PARENT;
+ $item['object-type'] = ACTIVITY_OBJ_NOTE;
+ } else {
+ $item['gravity'] = GRAVITY_COMMENT;
+ $item['object-type'] = ACTIVITY_OBJ_COMMENT;
+ }
+
+ self::postItem($activity, $item, $body);
+ }
+
+ private static function likeItem($activity, $body)
+ {
+ $item = [];
+ $item['verb'] = ACTIVITY_LIKE;
+ $item['parent-uri'] = $activity['object'];
+ $item['gravity'] = GRAVITY_ACTIVITY;
+ $item['object-type'] = ACTIVITY_OBJ_NOTE;
+
+ self::postItem($activity, $item, $body);
+ }
+
+ private static function postItem($activity, $item, $body)