<?php
/**
- * @file src/Protocol/diaspora.php
- * @brief The implementation of the diaspora protocol
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
*
- * The new protocol is described here: http://diaspora.github.io/diaspora_federation/index.html
- * This implementation here interprets the old and the new protocol and sends the new one.
- * In the future we will remove most stuff from "validPosting" and interpret only the new protocol.
*/
namespace Friendica\Protocol;
use Friendica\Content\Feature;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\Markdown;
-use Friendica\Core\Cache;
-use Friendica\Core\Config;
-use Friendica\Core\L10n;
+use Friendica\Core\Cache\Duration;
use Friendica\Core\Logger;
-use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
+use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Conversation;
use Friendica\Model\GContact;
-use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Model\ItemDeliveryData;
use Friendica\Model\Mail;
use Friendica\Model\Profile;
use Friendica\Model\User;
use Friendica\Network\Probe;
-use Friendica\Protocol\ActivityNamespace;
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map;
use SimpleXMLElement;
/**
- * @brief This class contain functions to create and send Diaspora XML files
- *
+ * This class contain functions to create and send Diaspora XML files
*/
class Diaspora
{
}
/**
- * @brief Return a list of relay servers
+ * Return a list of relay servers
*
* The list contains not only the official relays but also servers that we serve directly
*
$serverlist = [];
// Fetching relay servers
- $serverdata = Config::get("system", "relay_server");
+ $serverdata = DI::config()->get("system", "relay_server");
if (!empty($serverdata)) {
$servers = explode(",", $serverdata);
}
}
- if (Config::get("system", "relay_directly", false)) {
+ if (DI::config()->get("system", "relay_directly", false)) {
// We distribute our stuff based on the parent to ensure that the thread will be complete
$parent = Item::selectFirst(['parent'], ['id' => $item_id]);
if (!DBA::isResult($parent)) {
// Now we are collecting all relay contacts
foreach ($serverlist as $server_url) {
// We don't send messages to ourselves
- if (Strings::compareLink($server_url, System::baseUrl())) {
+ if (Strings::compareLink($server_url, DI::baseUrl())) {
continue;
}
$contact = self::getRelayContact($server_url);
}
/**
- * @brief Return a contact for a given server address or creates a dummy entry
+ * Return a contact for a given server address or creates a dummy entry
*
* @param string $server_url The url of the server
* @param array $fields Fieldlist
}
/**
- * @brief Update or insert a relay contact
+ * Update or insert a relay contact
*
* @param string $server_url The url of the server
* @param array $network_fields Optional network specific fields
}
/**
- * @brief Return a list of participating contacts for a thread
+ * Return a list of participating contacts for a thread
*
* This is used for the participation feature.
* One of the parameters is a contact array.
}
/**
- * @brief repairs a signature that was double encoded
+ * repairs a signature that was double encoded
*
* The function is unused at the moment. It was copied from the old implementation.
*
}
/**
- * @brief verify the envelope and return the verified data
+ * verify the envelope and return the verified data
*
* @param string $envelope The magic envelope
*
}
/**
- * @brief encrypts data via AES
+ * encrypts data via AES
*
* @param string $key The AES key
* @param string $iv The IV (is used for CBC encoding)
}
/**
- * @brief decrypts data via AES
+ * decrypts data via AES
*
* @param string $key The AES key
* @param string $iv The IV (is used for CBC encoding)
}
/**
- * @brief: Decodes incoming Diaspora message in the new format
+ * Decodes incoming Diaspora message in the new format
*
* @param string $raw raw post message
* @param string $privKey The private key of the importer
}
/**
- * @brief: Decodes incoming Diaspora message in the deprecated format
+ * Decodes incoming Diaspora message in the deprecated format
*
* @param string $xml urldecoded Diaspora salmon
* @param string $privKey The private key of the importer
/**
- * @brief Dispatches public messages and find the fitting receivers
+ * Dispatches public messages and find the fitting receivers
*
* @param array $msg The post that will be dispatched
*
*/
public static function dispatchPublic($msg)
{
- $enabled = intval(Config::get("system", "diaspora_enabled"));
+ $enabled = intval(DI::config()->get("system", "diaspora_enabled"));
if (!$enabled) {
Logger::log("diaspora is disabled");
return false;
}
/**
- * @brief Dispatches the different message types to the different functions
+ * Dispatches the different message types to the different functions
*
* @param array $importer Array of the importer user
* @param array $msg The post that will be dispatched
}
/**
- * @brief Checks if a posting is valid and fetches the data fields.
+ * Checks if a posting is valid and fetches the data fields.
*
* This function does not only check the signature.
* It also does the conversion between the old and the new diaspora format.
}
/**
- * @brief Fetches the public key for a given handle
+ * Fetches the public key for a given handle
*
* @param string $handle The handle
*
}
/**
- * @brief Fetches data for a given handle
+ * Fetches data for a given handle
*
* @param string $handle The handle
* @param boolean $update true = always update, false = never update, null = update when not found or outdated
}
/**
- * @brief Updates the fcontact table
+ * Updates the fcontact table
*
* @param array $arr The fcontact data
* @throws \Exception
}
/**
- * @brief get a handle (user@domain.tld) from a given contact id
+ * get a handle (user@domain.tld) from a given contact id
*
* @param int $contact_id The id in the contact table
* @param int $pcontact_id The id in the contact table (Used for the public contact)
}
/**
- * @brief get a url (scheme://domain.tld/u/user) from a given Diaspora*
+ * get a url (scheme://domain.tld/u/user) from a given Diaspora*
* fcontact guid
*
* @param mixed $fcontact_guid Hexadecimal string guid
}
/**
- * @brief Get a contact id for a given handle
+ * Get a contact id for a given handle
*
* @todo Move to Friendica\Model\Contact
*
private static function contactByHandle($uid, $handle)
{
$cid = Contact::getIdForURL($handle, $uid);
- if (!$cid) {
- $handle_parts = explode("@", $handle);
- $nurl_sql = "%%://" . $handle_parts[1] . "%%/profile/" . $handle_parts[0];
- $cid = Contact::getIdForURL($nurl_sql, $uid);
- }
-
if (!$cid) {
Logger::log("Haven't found a contact for user " . $uid . " and handle " . $handle, Logger::DEBUG);
return false;
}
/**
- * @brief Check if posting is allowed for this contact
+ * Check if posting is allowed for this contact
*
* @param array $importer Array of the importer user
* @param array $contact The contact that is checked
}
/**
- * @brief Fetches the contact id for a handle and checks if posting is allowed
+ * Fetches the contact id for a handle and checks if posting is allowed
*
* @param array $importer Array of the importer user
* @param string $handle The checked handle in the format user@domain.tld
}
/**
- * @brief Does the message already exists on the system?
+ * Does the message already exists on the system?
*
* @param int $uid The user id
* @param string $guid The guid of the message
}
/**
- * @brief Checks for links to posts in a message
+ * Checks for links to posts in a message
*
* @param array $item The item array
* @return void
}
/**
- * @brief Checks for relative /people/* links in an item body to match local
+ * Checks for relative /people/* links in an item body to match local
* contacts or prepends the remote host taken from the author link.
*
* @param string $body The item body to replace links from
}
/**
- * @brief sub function of "fetchGuid" which checks for links in messages
+ * sub function of "fetchGuid" which checks for links in messages
*
* @param array $match array containing a link that has to be checked for a message link
* @param array $item The item array
}
/**
- * @brief Fetches an item with a given guid from a given server
+ * Fetches an item with a given guid from a given server
*
* @param string $guid the message guid
* @param string $server The server address
}
/**
- * @brief Fetches a message from a server
+ * Fetches a message from a server
*
* @param string $guid message guid
* @param string $server The url of the server
}
/**
- * @brief Fetches an item with a given URL
+ * Fetches an item with a given URL
*
* @param string $url the message url
*
}
/**
- * @brief Fetches the item record of a given guid
+ * Fetches the item record of a given guid
*
* @param int $uid The user id
* @param string $guid message guid
}
/**
- * @brief returns contact details
+ * returns contact details
*
* @param array $def_contact The default contact if the person isn't found
* @param array $person The record of the person
}
/**
- * @brief Is the profile a hubzilla profile?
+ * Is the profile a hubzilla profile?
*
* @param string $url The profile link
*
}
/**
- * @brief Generate a post link with a given handle and message guid
+ * Generate a post link with a given handle and message guid
*
* @param string $addr The user handle
* @param string $guid message guid
}
/**
- * @brief Receives account migration
+ * Receives account migration
*
* @param array $importer Array of the importer user
* @param object $data The message object
}
/**
- * @brief Processes an account deletion
+ * Processes an account deletion
*
* @param object $data The message object
*
}
/**
- * @brief Fetch the uri from our database if we already have this item (maybe from ourselves)
+ * Fetch the uri from our database if we already have this item (maybe from ourselves)
*
* @param string $author Author handle
* @param string $guid Message guid
}
/**
- * @brief Fetch the guid from our database with a given uri
+ * Fetch the guid from our database with a given uri
*
* @param string $uri Message uri
* @param string $uid Author handle
}
/**
- * @brief Find the best importer for a comment, like, ...
+ * Find the best importer for a comment, like, ...
*
* @param string $guid The guid of the item
*
}
/**
- * @brief Processes an incoming comment
+ * Processes an incoming comment
*
* @param array $importer Array of the importer user
* @param string $sender The sender of the message
}
/**
- * @brief processes and stores private messages
+ * processes and stores private messages
*
* @param array $importer Array of the importer user
* @param array $contact The contact of the message
}
/**
- * @brief Processes new private messages (answers to private messages are processed elsewhere)
+ * Processes new private messages (answers to private messages are processed elsewhere)
*
* @param array $importer Array of the importer user
* @param array $msg Array of the processed message, author handle and key
}
/**
- * @brief Processes "like" messages
+ * Processes "like" messages
*
* @param array $importer Array of the importer user
* @param string $sender The sender of the message
}
/**
- * @brief Processes private messages
+ * Processes private messages
*
* @param array $importer Array of the importer user
* @param object $data The message object
}
/**
- * @brief Processes participations - unsupported by now
+ * Processes participations - unsupported by now
*
* @param array $importer Array of the importer user
* @param object $data The message object
return false;
}
- $item = Item::selectFirst(['id'], ['guid' => $parent_guid, 'origin' => true, 'private' => false]);
+ $item = Item::selectFirst(['id'], ['guid' => $parent_guid, 'origin' => true, 'private' => [Item::PUBLIC, Item::UNLISTED]]);
if (!DBA::isResult($item)) {
Logger::log('Item not found, no origin or private: '.$parent_guid);
return false;
}
/**
- * @brief Processes photos - unneeded
+ * Processes photos - unneeded
*
* @param array $importer Array of the importer user
* @param object $data The message object
}
/**
- * @brief Processes poll participations - unssupported
+ * Processes poll participations - unssupported
*
* @param array $importer Array of the importer user
* @param object $data The message object
}
/**
- * @brief Processes incoming profile updates
+ * Processes incoming profile updates
*
* @param array $importer Array of the importer user
* @param object $data The message object
$name = XML::unescape($data->first_name).((strlen($data->last_name)) ? " ".XML::unescape($data->last_name) : "");
$image_url = XML::unescape($data->image_url);
$birthday = XML::unescape($data->birthday);
- $gender = XML::unescape($data->gender);
$about = Markdown::toBBCode(XML::unescape($data->bio));
$location = Markdown::toBBCode(XML::unescape($data->location));
$searchable = (XML::unescape($data->searchable) == "true");
}
$fields = ['name' => $name, 'location' => $location,
- 'name-date' => DateTimeFormat::utcNow(),
- 'about' => $about, 'gender' => $gender,
+ 'name-date' => DateTimeFormat::utcNow(), 'about' => $about,
'addr' => $author, 'nick' => $nick, 'keywords' => $keywords,
'unsearchable' => !$searchable, 'sensitive' => $nsfw];
$gcontact = ["url" => $contact["url"], "network" => Protocol::DIASPORA, "generation" => 2,
"photo" => $image_url, "name" => $name, "location" => $location,
- "about" => $about, "birthday" => $birthday, "gender" => $gender,
+ "about" => $about, "birthday" => $birthday,
"addr" => $author, "nick" => $nick, "keywords" => $keywords,
"hide" => !$searchable, "nsfw" => $nsfw];
}
/**
- * @brief Processes incoming friend requests
+ * Processes incoming friend requests
*
* @param array $importer Array of the importer user
* @param array $contact The contact that send the request
}
/**
- * @brief Processes incoming sharing notification
+ * Processes incoming sharing notification
*
* @param array $importer Array of the importer user
* @param object $data The message object
}
/**
- * @brief Fetches a message with a given guid
+ * Fetches a message with a given guid
*
* @param string $guid message guid
* @param string $orig_author handle of the original post
}
// Do we already have this item?
- $fields = ['body', 'tag', 'app', 'created', 'object-type', 'uri', 'guid',
+ $fields = ['body', 'title', 'attach', 'tag', 'app', 'created', 'object-type', 'uri', 'guid',
'author-name', 'author-link', 'author-avatar'];
- $condition = ['guid' => $guid, 'visible' => true, 'deleted' => false, 'private' => false];
+ $condition = ['guid' => $guid, 'visible' => true, 'deleted' => false, 'private' => [Item::PUBLIC, Item::UNLISTED]];
$item = Item::selectFirst($fields, $condition);
if (DBA::isResult($item)) {
}
if ($stored) {
- $fields = ['body', 'tag', 'app', 'created', 'object-type', 'uri', 'guid',
+ $fields = ['body', 'title', 'attach', 'tag', 'app', 'created', 'object-type', 'uri', 'guid',
'author-name', 'author-link', 'author-avatar'];
- $condition = ['guid' => $guid, 'visible' => true, 'deleted' => false, 'private' => false];
+ $condition = ['guid' => $guid, 'visible' => true, 'deleted' => false, 'private' => [Item::PUBLIC, Item::UNLISTED]];
$item = Item::selectFirst($fields, $condition);
if (DBA::isResult($item)) {
}
/**
- * @brief Stores a reshare activity
+ * Stores a reshare activity
*
* @param array $item Array of reshare post
* @param integer $parent_message_id Id of the parent post
}
/**
- * @brief Processes a reshare message
+ * Processes a reshare message
*
* @param array $importer Array of the importer user
* @param object $data The message object
return false;
}
- $orig_url = System::baseUrl()."/display/".$original_item["guid"];
+ $orig_url = DI::baseUrl()."/display/".$original_item["guid"];
$datarray = [];
$original_item["created"],
$orig_url
);
+
+ if (!empty($original_item['title'])) {
+ $prefix .= '[h3]' . $original_item['title'] . "[/h3]\n";
+ }
+
$datarray["body"] = $prefix.$original_item["body"]."[/share]";
$datarray["tag"] = $original_item["tag"];
+ $datarray["attach"] = $original_item["attach"];
$datarray["app"] = $original_item["app"];
$datarray["plink"] = self::plink($author, $guid);
- $datarray["private"] = (($public == "false") ? 1 : 0);
+ $datarray["private"] = (($public == "false") ? Item::PRIVATE : Item::PUBLIC);
$datarray["changed"] = $datarray["created"] = $datarray["edited"] = $created_at;
$datarray["object-type"] = $original_item["object-type"];
}
/**
- * @brief Processes retractions
+ * Processes retractions
*
* @param array $importer Array of the importer user
* @param array $contact The contact of the item owner
}
/**
- * @brief Receives retraction messages
+ * Receives retraction messages
*
* @param array $importer Array of the importer user
* @param string $sender The sender of the message
}
/**
- * @brief Receives status messages
+ * Receives status messages
*
* @param array $importer Array of the importer user
* @param SimpleXMLElement $data The message object
}
$datarray["plink"] = self::plink($author, $guid);
- $datarray["private"] = (($public == "false") ? 1 : 0);
+ $datarray["private"] = (($public == "false") ? Item::PRIVATE : Item::PUBLIC);
$datarray["changed"] = $datarray["created"] = $datarray["edited"] = $created_at;
if (isset($address["address"])) {
* ************************************************************************************** */
/**
- * @brief returnes the handle of a contact
+ * returnes the handle of a contact
*
* @param array $contact contact array
*
$nick = $contact["nick"];
}
- return $nick . "@" . substr(System::baseUrl(), strpos(System::baseUrl(), "://") + 3);
+ return $nick . "@" . substr(DI::baseUrl(), strpos(DI::baseUrl(), "://") + 3);
}
/**
- * @brief Creates the data for a private message in the new format
+ * Creates the data for a private message in the new format
*
* @param string $msg The message that is to be transmitted
* @param array $user The record of the sender
}
/**
- * @brief Creates the envelope for the "fetch" endpoint and for the new format
+ * Creates the envelope for the "fetch" endpoint and for the new format
*
* @param string $msg The message that is to be transmitted
* @param array $user The record of the sender
}
/**
- * @brief Create the envelope for a message
+ * Create the envelope for a message
*
* @param string $msg The message that is to be transmitted
* @param array $user The record of the sender
}
/**
- * @brief Creates a signature for a message
+ * Creates a signature for a message
*
* @param array $owner the array of the owner of the message
* @param array $message The message that is to be signed
}
/**
- * @brief Transmit a message to a target server
+ * Transmit a message to a target server
*
* @param array $owner the array of the item owner
* @param array $contact Target of the communication
*/
private static function transmit(array $owner, array $contact, $envelope, $public_batch, $guid = "")
{
- $enabled = intval(Config::get("system", "diaspora_enabled"));
+ $enabled = intval(DI::config()->get("system", "diaspora_enabled"));
if (!$enabled) {
return 200;
}
Logger::log("transmit: ".$logid."-".$guid." ".$dest_url);
- if (!intval(Config::get("system", "diaspora_test"))) {
+ if (!intval(DI::config()->get("system", "diaspora_test"))) {
$content_type = (($public_batch) ? "application/magic-envelope+xml" : "application/json");
$postResult = Network::post($dest_url."/", $envelope, ["Content-Type: ".$content_type]);
/**
- * @brief Build the post xml
+ * Build the post xml
*
* @param string $type The message type
* @param array $message The message data
}
/**
- * @brief Builds and transmit messages
+ * Builds and transmit messages
*
* @param array $owner the array of the item owner
* @param array $contact Target of the communication
}
/**
- * @brief sends a participation (Used to get all further updates)
+ * sends a participation (Used to get all further updates)
*
* @param array $contact Target of the communication
* @param array $item Item array
private static function sendParticipation(array $contact, array $item)
{
// Don't send notifications for private postings
- if ($item['private']) {
+ if ($item['private'] == Item::PRIVATE) {
return;
}
$cachekey = "diaspora:sendParticipation:".$item['guid'];
- $result = Cache::get($cachekey);
+ $result = DI::cache()->get($cachekey);
if (!is_null($result)) {
return;
}
Logger::log("Send participation for ".$item["guid"]." by ".$author, Logger::DEBUG);
// It doesn't matter what we store, we only want to avoid sending repeated notifications for the same item
- Cache::set($cachekey, $item["guid"], Cache::QUARTER_HOUR);
+ DI::cache()->set($cachekey, $item["guid"], Duration::QUARTER_HOUR);
return self::buildAndTransmit($owner, $contact, "participation", $message);
}
/**
- * @brief sends an account migration
+ * sends an account migration
*
* @param array $owner the array of the item owner
* @param array $contact Target of the communication
*/
public static function sendAccountMigration(array $owner, array $contact, $uid)
{
- $old_handle = PConfig::get($uid, 'system', 'previous_addr');
+ $old_handle = DI::pConfig()->get($uid, 'system', 'previous_addr');
$profile = self::createProfileData($uid);
$signed_text = 'AccountMigration:'.$old_handle.':'.$profile['author'];
}
/**
- * @brief Sends a "share" message
+ * Sends a "share" message
*
* @param array $owner the array of the item owner
* @param array $contact Target of the communication
}
/**
- * @brief sends an "unshare"
+ * sends an "unshare"
*
* @param array $owner the array of the item owner
* @param array $contact Target of the communication
}
/**
- * @brief Checks a message body if it is a reshare
+ * Checks a message body if it is a reshare
*
* @param string $body The message body that is to be check
* @param bool $complete Should it be a complete check or a simple check?
{
$body = trim($body);
- // Skip if it isn't a pure repeated messages
- // Does it start with a share?
- if ((strpos($body, "[share") > 0) && $complete) {
- return false;
- }
-
- // Does it end with a share?
- if (strlen($body) > (strrpos($body, "[/share]") + 8)) {
+ $reshared = Item::getShareArray(['body' => $body]);
+ if (empty($reshared)) {
return false;
}
- $attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", "$1", $body);
- // Skip if there is no shared message in there
- if ($body == $attributes) {
+ // Skip if it isn't a pure repeated messages
+ // Does it start with a share?
+ if (!empty($reshared['comment']) && $complete) {
return false;
}
- // If we don't do the complete check we quit here
-
- $guid = "";
- preg_match("/guid='(.*?)'/ism", $attributes, $matches);
- if (!empty($matches[1])) {
- $guid = $matches[1];
- }
-
- preg_match('/guid="(.*?)"/ism', $attributes, $matches);
- if (!empty($matches[1])) {
- $guid = $matches[1];
- }
-
- if (($guid != "") && $complete) {
- $condition = ['guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
+ if (!empty($reshared['guid']) && $complete) {
+ $condition = ['guid' => $reshared['guid'], 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
$item = Item::selectFirst(['contact-id'], $condition);
if (DBA::isResult($item)) {
$ret = [];
$ret["root_handle"] = self::handleFromContact($item["contact-id"]);
- $ret["root_guid"] = $guid;
+ $ret["root_guid"] = $reshared['guid'];
return $ret;
} elseif ($complete) {
// We are resharing something that isn't a DFRN or Diaspora post.
// So we have to return "false" on "$complete" to not trigger a reshare.
return false;
}
- } elseif (($guid == "") && $complete) {
+ } elseif (empty($reshared['guid']) && $complete) {
return false;
}
- $ret["root_guid"] = $guid;
-
- $profile = "";
- preg_match("/profile='(.*?)'/ism", $attributes, $matches);
- if (!empty($matches[1])) {
- $profile = $matches[1];
- }
-
- preg_match('/profile="(.*?)"/ism', $attributes, $matches);
- if (!empty($matches[1])) {
- $profile = $matches[1];
- }
-
$ret = [];
- if (!empty($profile) && ($cid = Contact::getIdForURL($profile))) {
+ if (!empty($reshared['profile']) && ($cid = Contact::getIdForURL($reshared['profile']))) {
$contact = DBA::selectFirst('contact', ['addr'], ['id' => $cid]);
if (!empty($contact['addr'])) {
$ret['root_handle'] = $contact['addr'];
}
/**
- * @brief Create an event array
+ * Create an event array
*
* @param integer $event_id The id of the event
*
}
/**
- * @brief Create a post (status message or reshare)
+ * Create a post (status message or reshare)
*
* @param array $item The item that will be exported
* @param array $owner the array of the item owner
{
$cachekey = "diaspora:buildStatus:".$item['guid'];
- $result = Cache::get($cachekey);
+ $result = DI::cache()->get($cachekey);
if (!is_null($result)) {
return $result;
}
$myaddr = self::myHandle($owner);
- $public = ($item["private"] ? "false" : "true");
+ $public = ($item["private"] == Item::PRIVATE ? "false" : "true");
$created = DateTimeFormat::utc($item['received'], DateTimeFormat::ATOM);
$edited = DateTimeFormat::utc($item["edited"] ?? $item["created"], DateTimeFormat::ATOM);
// Detect a share element and do a reshare
- if (!$item['private'] && ($ret = self::isReshare($item["body"]))) {
+ if (($item['private'] != Item::PRIVATE) && ($ret = self::isReshare($item["body"]))) {
$message = ["author" => $myaddr,
"guid" => $item["guid"],
"created_at" => $created,
$body = $item["body"];
// Fetch the title from an attached link - if there is one
- if (empty($item["title"]) && PConfig::get($owner['uid'], 'system', 'attach_link_title')) {
+ if (empty($item["title"]) && DI::pConfig()->get($owner['uid'], 'system', 'attach_link_title')) {
$page_data = BBCode::getAttachmentData($item['body']);
if (!empty($page_data['type']) && !empty($page_data['title']) && ($page_data['type'] == 'link')) {
$title = $page_data['title'];
if ($item["attach"]) {
$cnt = preg_match_all('/href=\"(.*?)\"(.*?)title=\"(.*?)\"/ism', $item["attach"], $matches, PREG_SET_ORDER);
if ($cnt) {
- $body .= "\n".L10n::t("Attachments:")."\n";
+ $body .= "\n".DI::l10n()->t("Attachments:")."\n";
foreach ($matches as $mtch) {
$body .= "[".$mtch[3]."](".$mtch[1].")\n";
}
$msg = ["type" => $type, "message" => $message];
- Cache::set($cachekey, $msg, Cache::QUARTER_HOUR);
+ DI::cache()->set($cachekey, $msg, Duration::QUARTER_HOUR);
return $msg;
}
}
/**
- * @brief Sends a post
+ * Sends a post
*
* @param array $item The item that will be exported
* @param array $owner the array of the item owner
}
/**
- * @brief Creates a "like" object
+ * Creates a "like" object
*
* @param array $item The item that will be exported
* @param array $owner the array of the item owner
}
/**
- * @brief Creates an "EventParticipation" object
+ * Creates an "EventParticipation" object
*
* @param array $item The item that will be exported
* @param array $owner the array of the item owner
}
/**
- * @brief Creates the object for a comment
+ * Creates the object for a comment
*
* @param array $item The item that will be exported
* @param array $owner the array of the item owner
{
$cachekey = "diaspora:constructComment:".$item['guid'];
- $result = Cache::get($cachekey);
+ $result = DI::cache()->get($cachekey);
if (!is_null($result)) {
return $result;
}
if (
$item['author-id'] != $thread_parent_item['author-id']
&& (empty($item['uid']) || !Feature::isEnabled($item['uid'], 'explicit_mentions'))
- && !Config::get('system', 'disable_implicit_mentions')
+ && !DI::config()->get('system', 'disable_implicit_mentions')
) {
$body = self::prependParentAuthorMention($body, $thread_parent_item['author-link']);
}
$comment['thread_parent_guid'] = $thread_parent_item['guid'];
}
- Cache::set($cachekey, $comment, Cache::QUARTER_HOUR);
+ DI::cache()->set($cachekey, $comment, Duration::QUARTER_HOUR);
return($comment);
}
/**
- * @brief Send a like or a comment
+ * Send a like or a comment
*
* @param array $item The item that will be exported
* @param array $owner the array of the item owner
}
/**
- * @brief Creates a message from a signature record entry
+ * Creates a message from a signature record entry
*
* @param array $item The item that will be exported
* @return array The message
}
/**
- * @brief Relays messages (like, comment, retraction) to other servers if we are the thread owner
+ * Relays messages (like, comment, retraction) to other servers if we are the thread owner
*
* @param array $item The item that will be exported
* @param array $owner the array of the item owner
}
/**
- * @brief Sends a retraction (deletion) of a message, like or comment
+ * Sends a retraction (deletion) of a message, like or comment
*
* @param array $item The item that will be exported
* @param array $owner the array of the item owner
}
/**
- * @brief Sends a mail
+ * Sends a mail
*
* @param array $item The item that will be exported
* @param array $owner The owner
}
/**
- * @brief Split a name into first name and last name
+ * Split a name into first name and last name
*
* @param string $name The name
*
}
/**
- * @brief Create profile data
+ * Create profile data
*
* @param int $uid The user id
*
FROM `profile`
INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
INNER JOIN `contact` ON `profile`.`uid` = `contact`.`uid`
- WHERE `user`.`uid` = %d AND `profile`.`is-default` AND `contact`.`self` LIMIT 1",
+ WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1",
intval($uid)
);
$first = $split_name['first'];
$last = $split_name['last'];
- $large = System::baseUrl().'/photo/custom/300/'.$profile['uid'].'.jpg';
- $medium = System::baseUrl().'/photo/custom/100/'.$profile['uid'].'.jpg';
- $small = System::baseUrl().'/photo/custom/50/' .$profile['uid'].'.jpg';
- $searchable = (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false');
+ $large = DI::baseUrl().'/photo/custom/300/'.$profile['uid'].'.jpg';
+ $medium = DI::baseUrl().'/photo/custom/100/'.$profile['uid'].'.jpg';
+ $small = DI::baseUrl().'/photo/custom/50/' .$profile['uid'].'.jpg';
+ $searchable = ($profile['net-publish'] ? 'true' : 'false');
$dob = null;
$about = null;
$dob = DateTimeFormat::utc($year . '-' . $month . '-'. $day, 'Y-m-d');
}
- $about = $profile['about'];
- $about = strip_tags(BBCode::convert($about));
+ $about = BBCode::toMarkdown($profile['about']);
$location = Profile::formatLocation($profile);
$tags = '';
"image_url_medium" => $medium,
"image_url_small" => $small,
"birthday" => $dob,
- "gender" => $profile['gender'],
"bio" => $about,
"location" => $location,
"searchable" => $searchable,
}
/**
- * @brief Sends profile data
+ * Sends profile data
*
* @param int $uid The user id
* @param bool $recips optional, default false
}
/**
- * @brief Creates the signature for likes that are created on our system
+ * Creates the signature for likes that are created on our system
*
* @param integer $uid The user of that comment
* @param array $item Item array
}
/**
- * @brief Creates the signature for Comments that are created on our system
+ * Creates the signature for Comments that are created on our system
*
* @param integer $uid The user of that comment
* @param array $item Item array