continue;
}
- $fields = ['uri-id' => $uriid, 'name' => $person['addr'], 'url' => $person['url']];
+ $fields = ['uri-id' => $uriid, 'name' => substr($person['addr'], 0, 64), 'url' => $person['url']];
if ($match[1] == Term::TAG_CHARACTER[Term::MENTION]) {
$fields['type'] = Term::MENTION;
}
}
+ private static function storeTags(int $uriid, string $body)
+ {
+ $tags = BBCode::getTags($body);
+ if (empty($tags)) {
+ return;
+ }
+
+ foreach ($tags as $tag) {
+ if ((substr($tag, 0, 1) != Term::TAG_CHARACTER[Term::HASHTAG]) || (strlen($tag) <= 1)) {
+ Logger::info('Skip tag', ['uriid' => $uriid, 'tag' => $tag]);
+ continue;
+ }
+
+ $fields = ['uri-id' => $uriid, 'name' => substr($tag, 1, 64), 'type' => Term::HASHTAG];
+ DBA::insert('tag', $fields, true);
+ Logger::info('Stored tag', ['uriid' => $uriid, 'tag' => $tag, 'fields' => $fields]);
+ }
+ }
+
/**
* Processes an incoming comment
*
$datarray["changed"] = $datarray["created"] = $datarray["edited"] = $created_at;
$datarray["plink"] = self::plink($author, $guid, $parent_item['guid']);
-
- self::storeMentions($datarray['uri-id'], $text);
-
+
$body = Markdown::toBBCode($text);
$datarray["body"] = self::replacePeopleGuid($body, $person["url"]);
+ self::storeMentions($datarray['uri-id'], $text);
+ self::storeTags($datarray['uri-id'], $datarray["body"]);
+
self::fetchGuid($datarray);
// If we are the origin of the parent we store the original data.
$datarray["protocol"] = Conversation::PARCEL_DIASPORA;
$datarray["source"] = $xml;
- self::storeMentions($datarray['uri-id'], $text);
-
$datarray["body"] = self::replacePeopleGuid($body, $contact["url"]);
+ self::storeMentions($datarray['uri-id'], $text);
+ self::storeTags($datarray['uri-id'], $datarray["body"]);
+
if ($provider_display_name != "") {
$datarray["app"] = $provider_display_name;
}
Logger::log("Got relayable data ".$type." for item ".$item["guid"]." (".$item["id"].")", Logger::DEBUG);
- // Old way - is used by the internal Friendica functions
- /// @todo Change all signatur storing functions to the new format
- if ($item['signed_text'] && $item['signature'] && $item['signer']) {
- $message = self::messageFromSignature($item);
- } else {// New way
- $msg = json_decode($item['signed_text'], true);
-
- $message = [];
- if (is_array($msg)) {
- foreach ($msg as $field => $data) {
- if (!$item["deleted"]) {
- if ($field == "diaspora_handle") {
- $field = "author";
- }
- if ($field == "target_type") {
- $field = "parent_type";
- }
- }
+ $msg = json_decode($item['signed_text'], true);
- $message[$field] = $data;
+ $message = [];
+ if (is_array($msg)) {
+ foreach ($msg as $field => $data) {
+ if (!$item["deleted"]) {
+ if ($field == "diaspora_handle") {
+ $field = "author";
+ }
+ if ($field == "target_type") {
+ $field = "parent_type";
+ }
}
- } else {
- Logger::log("Signature text for item ".$item["guid"]." (".$item["id"].") couldn't be extracted: ".$item['signed_text'], Logger::DEBUG);
+
+ $message[$field] = $data;
}
+ } else {
+ Logger::log("Signature text for item ".$item["guid"]." (".$item["id"].") couldn't be extracted: ".$item['signed_text'], Logger::DEBUG);
}
$message["parent_author_signature"] = self::signature($owner, $message);