namespace Friendica\Protocol;
-use DOMAttr;
use DOMDocument;
use DOMElement;
use DOMXPath;
Contact::update($contact, ['id' => $contact['id']], $current);
if (!empty($author['author-avatar']) && ($author['author-avatar'] != $current['avatar'])) {
- Logger::info("Update profile picture for contact ".$contact["id"]);
+ Logger::info('Update profile picture for contact ' . $contact['id']);
Contact::updateAvatar($contact['id'], $author['author-avatar']);
}
foreach ($hub_attributes as $hub_attribute) {
if ($hub_attribute->name == 'href') {
$hub = $hub_attribute->textContent;
- Logger::info("Found hub ", ['hub' => $hub]);
+ Logger::info('Found hub ', ['hub' => $hub]);
}
}
}
if (in_array($item['verb'], [Activity::O_UNFAVOURITE, Activity::UNFAVORITE])) {
// Ignore "Unfavorite" message
- Logger::info("Ignore unfavorite message ", ['item' => $item]);
+ Logger::info('Ignore unfavorite message ', ['item' => $item]);
continue;
}
if ($item['verb'] == Activity::JOIN) {
// ignore "Join" messages
- Logger::info("Ignore join message ", ['item' => $item]);
+ Logger::info('Ignore join message ', ['item' => $item]);
continue;
}
if ($item['verb'] == 'http://mastodon.social/schema/1.0/block') {
// ignore mastodon "block" messages
- Logger::info("Ignore block message ", ['item' => $item]);
+ Logger::info('Ignore block message ', ['item' => $item]);
continue;
}
if ($item['verb'] == Activity::FAVORITE) {
$orig_uri = $xpath->query('activity:object/atom:id', $entry)->item(0)->nodeValue;
- Logger::notice("Favorite", ['uri' => $orig_uri, 'item' => $item]);
+ Logger::notice('Favorite', ['uri' => $orig_uri, 'item' => $item]);
$item['verb'] = Activity::LIKE;
$item['thr-parent'] = $orig_uri;
// http://activitystrea.ms/schema/1.0/rsvp-yes
if (!in_array($item['verb'], [Activity::POST, Activity::LIKE, Activity::SHARE])) {
- Logger::info("Unhandled verb", ['verb' => $item['verb'], 'item' => $item]);
+ Logger::info('Unhandled verb', ['verb' => $item['verb'], 'item' => $item]);
}
self::processPost($xpath, $entry, $item, $importer);
$valid = !$uid || DI::pConfig()->get($uid, 'system', 'accept_only_sharer') != Item::COMPLETION_NONE;
if ($valid) {
- Logger::info("Item with uri " . self::$itemlist[0]['uri'] . " will be imported due to the system settings.");
+ Logger::info('Item with URI ' . self::$itemlist[0]['uri'] . ' will be imported due to the system settings.');
}
} else {
- Logger::info("Item with uri " . self::$itemlist[0]['uri'] . " belongs to a contact (" . self::$itemlist[0]['contact-id'] . "). It will be imported.");
+ Logger::info('Item with URI ' . self::$itemlist[0]['uri'] . ' belongs to a contact (' . self::$itemlist[0]['contact-id'] . '). It will be imported.');
}
if ($valid && DI::pConfig()->get($uid, 'system', 'accept_only_sharer') != Item::COMPLETION_LIKE) {
}
}
if ($valid) {
- Logger::info("Item with URI " . self::$itemlist[0]['uri'] . " will be imported since the thread contains posts or shares.");
+ Logger::info('Item with URI ' . self::$itemlist[0]['uri'] . ' will be imported since the thread contains posts or shares.');
}
}
} else {
foreach (self::$itemlist as $item) {
$found = Post::exists(['uid' => $importer['uid'], 'uri' => $item['uri']]);
if ($found) {
- Logger::notice("Item with uri " . $item['uri'] . " for user " . $importer['uid'] . " already exists.");
+ Logger::notice('Item with URI ' . $item['uri'] . ' for user ' . $importer['uid'] . ' already exists.');
} elseif ($item['contact-id'] < 0) {
- Logger::notice("Item with uri " . $item['uri'] . " is from a blocked contact.");
+ Logger::notice('Item with URI ' . $item['uri'] . ' is from a blocked contact.');
} else {
$ret = Item::insert($item);
- Logger::info("Item with uri " . $item['uri'] . " for user " . $importer['uid'] . " stored. Return value: " . $ret);
+ Logger::info('Item with URI ' . $item['uri'] . ' for user ' . $importer['uid'] . ' stored. Return value: ' . $ret);
}
}
}
$conversation = DBA::selectFirst('conversation', ['source'], $condition);
if (DBA::isResult($conversation)) {
$stored = true;
- Logger::info('Got cached XML from conversation for URI '.$related_uri);
+ Logger::info('Got cached XML from conversation for URI ' . $related_uri);
$xml = $conversation['source'];
}
}
if ($xml != '') {
self::process($xml, $importer, $contact, $hub, $stored, false, Conversation::PULL);
} else {
- Logger::info("XML couldn't be fetched for URI: " . $related_uri . " - href: " . $related);
+ Logger::info('XML could not be fetched for URI: ' . $related_uri . ' - href: ' . $related);
}
return;
}
break;
default:
- Logger::warning('Unsupported rel=' . $attribute['rel'] . ',href=' . $attribute['href'] . ',object-type=' . $attribute['object-type']);
+ Logger::warning('Unsupported rel=' . $attribute['rel'] . ', href=' . $attribute['href'] . ', object-type=' . $attribute['object-type']);
}
}
}
* Cleans the body of a post if it contains picture links
*
* @param string $body The body
- * @param integer $uriid URI id
+ * @param integer $uriId
* @return string The cleaned body
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
$url = $siteinfo['image'];
}
- $body = trim($siteinfo['text']) . " [url]" . $url . "[/url]\n[img]" . $preview . "[/img]";
+ $body = trim($siteinfo['text']) . ' [url]' . $url . "[/url]\n[img]" . $preview . '[/img]';
}
return $body;
* @param array $owner Contact data of the poster
* @param string $filter The related feed filter (activity, posts or comments)
*
- * @return DOMAttr Header root element
+ * @return DOMElement Header root element
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- private static function addHeader(DOMDocument $doc, array $owner, string $filter): DOMAttr
+ private static function addHeader(DOMDocument $doc, array $owner, string $filter): DOMElement
{
$root = $doc->createElementNS(ActivityNamespace::ATOM1, 'feed');
$doc->appendChild($root);
if ($owner['contact-type'] == Contact::TYPE_COMMUNITY) {
$members = DBA::count('contact', [
- 'uid' => $owner['uid'],
- 'self' => false,
+ 'uid' => $owner['uid'],
+ 'self' => false,
'pending' => false,
'archive' => false,
- 'hidden' => false,
+ 'hidden' => false,
'blocked' => false,
]);
XML::addElement($doc, $root, 'statusnet:group_info', '', ['member_count' => $members]);
* Add the link to the push hubs to the XML document
*
* @param DOMDocument $doc XML document
- * @param addHubLink $root XML root element where the hub links are added
+ * @param DOMElement $root XML root element where the hub links are added
* @param string $nick Nickname
* @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public static function addHubLink(DOMDocument $doc, DOMAttr $root, string $nick)
+ public static function addHubLink(DOMDocument $doc, DOMElement $root, string $nick)
{
$h = DI::baseUrl() . '/pubsubhubbub/' . $nick;
XML::addElement($doc, $root, 'link', '', ['href' => $h, 'rel' => 'hub']);
* Adds attachment data to the XML document
*
* @param DOMDocument $doc XML document
- * @param DOMAttr $root XML root element where the hub links are added
+ * @param DOMElement $root XML root element where the hub links are added
* @param array $item Data of the item that is to be posted
* @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public static function getAttachment(DOMDocument $doc, DOMAttr $root, array $item)
+ public static function getAttachment(DOMDocument $doc, DOMElement $root, array $item)
{
$siteinfo = BBCode::getAttachedData($item['body']);
}
}
break;
+
case 'video':
$attributes = [
'rel' => 'enclosure',
];
XML::addElement($doc, $root, 'link', '', $attributes);
break;
+
default:
+ Logger::warning('Unsupported type', ['type' => $siteinfo['type'], 'url' => $siteinfo['url'] ?? '']);
break;
}
private static function likeEntry(DOMDocument $doc, array $item, array $owner, bool $toplevel): DOMElement
{
if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
- Logger::info("OStatus entry is from author " . $owner['url'] . " - not from " . $item['author-link'] . ". Quitting.");
+ Logger::info('OStatus entry is from author ' . $owner['url'] . ' - not from ' . $item['author-link'] . '. Quitting.');
}
$entry = self::entryHeader($doc, $owner, $item, $toplevel);
private static function noteEntry(DOMDocument $doc, array $item, array $owner, bool $toplevel): DOMElement
{
if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
- Logger::info("OStatus entry is from author " . $owner['url'] . " - not from " . $item['author-link'] . ". Quitting.");
+ Logger::info('OStatus entry is from author ' . $owner['url'] . ' - not from ' . $item['author-link'] . '. Quitting.');
}
if (!$toplevel) {
if (!empty($item['title'])) {
$title = BBCode::convertForUriId($item['uri-id'], $item['title'], BBCode::OSTATUS);
} else {
- $title = sprintf("New note by %s", $owner['nick']);
+ $title = sprintf('New note by %s', $owner['nick']);
}
} else {
- $title = sprintf("New comment by %s", $owner['nick']);
+ $title = sprintf('New comment by %s', $owner['nick']);
}
$entry = self::entryHeader($doc, $owner, $item, $toplevel);
$body = self::formatPicturePost($body, $item['uri-id']);
if (!empty($item['title'])) {
- $body = "[b]" . $item['title'] . "[/b]\n\n" . $body;
+ $body = '[b]' . $item['title'] . "[/b]\n\n" . $body;
}
$body = BBCode::convertForUriId($item['uri-id'], $body, BBCode::OSTATUS);
$contact = Contact::getByURL($mention, false, ['contact-type']);
if (!empty($contact) && ($contact['contact-type'] == Contact::TYPE_COMMUNITY)) {
XML::addElement($doc, $entry, 'link', '', [
- 'rel' => 'mentioned',
- 'ostatus:object-type' => Activity\ObjectType::GROUP,
- 'href' => $mention,
+ 'rel' => 'mentioned',
+ 'ostatus:object-type' => Activity\ObjectType::GROUP,
+ 'href' => $mention,
]);
} else {
XML::addElement($doc, $entry, 'link', '', [
- 'rel' => 'mentioned',
- 'ostatus:object-type' => Activity\ObjectType::PERSON,
+ 'rel' => 'mentioned',
+ 'ostatus:object-type' => Activity\ObjectType::PERSON,
'href' => $mention,
]);
}
* cache or it is empty
*
* @param string $owner_nick Nickname of the feed owner
- * @param string $last_update Date of the last update
+ * @param string $last_update Date of the last update (in "Y-m-d H:i:s" format)
* @param integer $max_items Number of maximum items to fetch
* @param string $filter Feed items filter (activity, posts or comments)
* @param boolean $nocache Wether to bypass caching