foreach ($categories as $category) {
foreach ($category->attributes as $attributes) {
if ($attributes->name == 'term') {
- $term = $attributes->textContent;
- if (!empty($item['tag'])) {
- $item['tag'] .= ',';
- } else {
- $item['tag'] = '';
- }
-
- $item['tag'] .= '#[url=' . DI::baseUrl() . '/search?tag=' . $term . ']' . $term . '[/url]';
-
// Store the hashtag
- Tag::store($item['uri-id'], Tag::HASHTAG, $term);
+ Tag::store($item['uri-id'], Tag::HASHTAG, $attributes->textContent);
}
}
}
$item["body"] = add_page_info_to_body($item["body"]);
}
+ Tag::storeFromBody($item['uri-id'], $item['body']);
+
// Mastodon Content Warning
if (($item["verb"] == Activity::POST) && $xpath->evaluate('boolean(atom:summary)', $entry)) {
$clear_text = XML::getFirstNodeValue($xpath, 'atom:summary/text()', $entry);
// Even more worse workaround for GNU Social ;-)
if ($xml == '') {
- $related_guess = OStatus::convertHref($related_uri);
+ $related_guess = self::convertHref($related_uri);
$curlResult = Network::curl(str_replace('/notice/', '/api/statuses/show/', $related_guess).'.atom');
if ($curlResult->isSuccess()) {
*
* @return string URL in the format http(s)://....
*/
- public static function convertHref($href)
+ private static function convertHref($href)
{
$elements = explode(":", $href);
XML::addElement($doc, $author, "name", $owner["nick"]);
XML::addElement($doc, $author, "email", $owner["addr"]);
if ($show_profile) {
- XML::addElement($doc, $author, "summary", BBCode::convert($owner["about"], false, 7));
+ XML::addElement($doc, $author, "summary", BBCode::convert($owner["about"], false, BBCode::OSTATUS));
}
$attributes = ["rel" => "alternate", "type" => "text/html", "href" => $owner["url"]];
XML::addElement($doc, $author, "poco:preferredUsername", $owner["nick"]);
XML::addElement($doc, $author, "poco:displayName", $owner["name"]);
if ($show_profile) {
- XML::addElement($doc, $author, "poco:note", BBCode::convert($owner["about"], false, 7));
+ XML::addElement($doc, $author, "poco:note", BBCode::convert($owner["about"], false, BBCode::OSTATUS));
if (trim($owner["location"]) != "") {
$element = $doc->createElement("poco:address");
*/
private static function reshareEntry(DOMDocument $doc, array $item, array $owner, $repeated_guid, $toplevel)
{
- if (($item["id"] != $item["parent"]) && (Strings::normaliseLink($item["author-link"]) != Strings::normaliseLink($owner["url"]))) {
+ if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item["author-link"]) != Strings::normaliseLink($owner["url"]))) {
Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG);
}
*/
private static function likeEntry(DOMDocument $doc, array $item, array $owner, $toplevel)
{
- if (($item["id"] != $item["parent"]) && (Strings::normaliseLink($item["author-link"]) != Strings::normaliseLink($owner["url"]))) {
+ if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item["author-link"]) != Strings::normaliseLink($owner["url"]))) {
Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG);
}
*/
private static function followEntry(DOMDocument $doc, array $item, array $owner, $toplevel)
{
- $item["id"] = $item["parent"] = 0;
+ $item["id"] = $item['parent'] = 0;
$item["created"] = $item["edited"] = date("c");
$item["private"] = Item::PRIVATE;
*/
private static function noteEntry(DOMDocument $doc, array $item, array $owner, $toplevel, $feed_mode)
{
- if (($item["id"] != $item["parent"]) && (Strings::normaliseLink($item["author-link"]) != Strings::normaliseLink($owner["url"]))) {
+ if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item["author-link"]) != Strings::normaliseLink($owner["url"]))) {
Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG);
}
if (!$toplevel) {
if (!empty($item['title'])) {
- $title = BBCode::convert($item['title'], false, 7);
+ $title = BBCode::convert($item['title'], false, BBCode::OSTATUS);
} else {
$title = sprintf("New note by %s", $owner["nick"]);
}
$body = "[b]".$item['title']."[/b]\n\n".$body;
}
- $body = BBCode::convert($body, false, 7);
+ $body = BBCode::convert($body, false, BBCode::OSTATUS);
XML::addElement($doc, $entry, "content", $body, ["type" => "html"]);
{
$mentioned = [];
- if (($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) {
- $parent = Item::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item["parent"]]);
+ if ($item['gravity'] != GRAVITY_PARENT) {
+ $parent = Item::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
$parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
$thrparent = Item::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner["uid"], 'uri' => $parent_item]);
XML::addElement($doc, $entry, "link", "", $attributes);
}
- if (!$feed_mode && (intval($item["parent"]) > 0)) {
+ if (!$feed_mode && (intval($item['parent']) > 0)) {
$conversation_href = $conversation_uri = str_replace('/objects/', '/context/', $item['parent-uri']);
if (isset($parent_item)) {
$attributes = [
"href" => $conversation_href,
- "local_id" => $item["parent"],
+ "local_id" => $item['parent'],
"ref" => $conversation_uri];
XML::addElement($doc, $entry, "ostatus:conversation", $conversation_uri, $attributes);
}
- $tags = item::getFeedTags($item);
-
- if (count($tags)) {
- foreach ($tags as $t) {
- if ($t[0] == "@") {
- $mentioned[$t[1]] = $t[1];
- }
- }
+ // uri-id isn't present for follow entry pseudo-items
+ $tags = Tag::getByURIId($item['uri-id'] ?? 0);
+ foreach ($tags as $tag) {
+ $mentioned[$tag['url']] = $tag['url'];
}
// Make sure that mentions are accepted (GNU Social has problems with mixing HTTP and HTTPS)
XML::addElement($doc, $entry, "mastodon:scope", "public");
}
- if (count($tags)) {
- foreach ($tags as $t) {
- if ($t[0] != "@") {
- XML::addElement($doc, $entry, "category", "", ["term" => $t[2]]);
- }
+ foreach ($tags as $tag) {
+ if ($tag['type'] == Tag::HASHTAG) {
+ XML::addElement($doc, $entry, "category", "", ["term" => $tag['name']]);
}
}