use Friendica\Model\Contact;
use Friendica\Model\Conversation;
use Friendica\Model\Event;
-use Friendica\Model\FContact;
use Friendica\Model\GServer;
use Friendica\Model\Item;
use Friendica\Model\ItemURI;
use Friendica\Model\Profile;
use Friendica\Model\Tag;
use Friendica\Model\User;
+use Friendica\Network\HTTPException;
use Friendica\Network\Probe;
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
DI::config()->set('system', 'site_pubkey', $res['pubkey']);
}
- $profilephotos = Photo::selectToArray(['resource-id' , 'scale'], ['profile' => true, 'uid' => $uid], ['order' => ['scale']]);
+ $profilephotos = Photo::selectToArray(['resource-id', 'scale', 'type'], ['profile' => true, 'uid' => $uid], ['order' => ['scale']]);
$photos = [];
$ext = Images::supportedTypes();
foreach ($profilephotos as $p) {
- $photos[$p['scale']] = DI::baseUrl().'/photo/'.$p['resource-id'].'-'.$p['scale'].'.'.$ext[$p['type']];
+ $photos[$p['scale']] = DI::baseUrl() . '/photo/' . $p['resource-id'] . '-' . $p['scale'] . '.' . $ext[$p['type']];
}
-
$doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true;
XML::addElement($doc, $author, 'poco:utcOffset', DateTimeFormat::timezoneNow($profile['timezone'], 'P'));
- if (trim($profile['homepage']) != '') {
+ if (trim($profile['homepage'])) {
$urls = $doc->createElement('poco:urls');
XML::addElement($doc, $urls, 'poco:type', 'homepage');
XML::addElement($doc, $urls, 'poco:value', $profile['homepage']);
$author->appendChild($urls);
}
- if (trim($profile['pub_keywords']) != '') {
+ if (trim($profile['pub_keywords'] ?? '')) {
$keywords = explode(',', $profile['pub_keywords']);
foreach ($keywords as $keyword) {
}
}
- if (trim($profile['xmpp']) != '') {
+ if (trim($profile['xmpp'])) {
$ims = $doc->createElement('poco:ims');
XML::addElement($doc, $ims, 'poco:type', 'xmpp');
XML::addElement($doc, $ims, 'poco:value', $profile['xmpp']);
$author->appendChild($ims);
}
- if (trim($profile['locality'] . $profile['region'] . $profile['country-name']) != '') {
+ if (trim($profile['locality'] . $profile['region'] . $profile['country-name'])) {
$element = $doc->createElement('poco:address');
XML::addElement($doc, $element, 'poco:formatted', Profile::formatLocation($profile));
*/
private static function getAttachment($doc, $root, array $item)
{
- foreach (Post\Media::getByURIId($item['uri-id'], [Post\Media::DOCUMENT, Post\Media::TORRENT, Post\Media::UNKNOWN]) as $attachment) {
+ foreach (Post\Media::getByURIId($item['uri-id'], [Post\Media::DOCUMENT, Post\Media::TORRENT]) as $attachment) {
$attributes = ['rel' => 'enclosure',
'href' => $attachment['url'],
'type' => $attachment['mimetype']];
$entry->setAttribute("xmlns:statusnet", ActivityNamespace::STATUSNET);
}
- $body = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body'] ?? '');
+ $body = Post\Media::addAttachmentsToBody($item['uri-id'], DI::contentItem()->addSharedPost($item));
if ($item['private'] == Item::PRIVATE) {
$body = Item::fixPrivatePhotos($body, $owner['uid'], $item, $cid);
$dfrnowner = self::addEntryAuthor($doc, "dfrn:owner", $item["owner-link"], $item);
$entry->appendChild($dfrnowner);
- if ($item['gravity'] != GRAVITY_PARENT) {
+ if ($item['gravity'] != Item::GRAVITY_PARENT) {
$parent = Post::selectFirst(['guid', 'plink'], ['uri' => $item['thr-parent'], 'uid' => $item['uid']]);
if (DBA::isResult($parent)) {
$attributes = ["ref" => $item['thr-parent'], "type" => "text/html",
if ($item['object-type'] != '') {
XML::addElement($doc, $entry, 'activity:object-type', $item['object-type']);
- } elseif ($item['gravity'] == GRAVITY_PARENT) {
+ } elseif ($item['gravity'] == Item::GRAVITY_PARENT) {
XML::addElement($doc, $entry, 'activity:object-type', Activity\ObjectType::NOTE);
} else {
XML::addElement($doc, $entry, 'activity:object-type', Activity\ObjectType::COMMENT);
}
}
- $fcontact = FContact::getByURL($contact['addr']);
- if (empty($fcontact)) {
+ try {
+ $pubkey = DI::dsprContact()->getByAddr(WebFingerUri::fromString($contact['addr']))->pubKey;
+ } catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
Logger::notice('Unable to find contact details for ' . $contact['id'] . ' - ' . $contact['addr']);
return -22;
}
- $pubkey = $fcontact['pubkey'] ?? '';
} else {
$pubkey = '';
}
$fields = ['id', 'uid', 'url', 'network', 'avatar-date', 'avatar', 'name-date', 'uri-date', 'addr',
'name', 'nick', 'about', 'location', 'keywords', 'xmpp', 'bdyear', 'bd', 'hidden', 'contact-type'];
- $condition = ["`uid` = ? AND `nurl` = ? AND `network` != ? AND NOT `pending` AND NOT `blocked`",
- $importer["importer_uid"], Strings::normaliseLink($author["link"]), Protocol::STATUSNET];
+ $condition = ["`uid` = ? AND `nurl` = ? AND NOT `pending` AND NOT `blocked`",
+ $importer["importer_uid"], Strings::normaliseLink($author["link"])];
if ($importer['account-type'] != User::ACCOUNT_TYPE_COMMUNITY) {
$condition = DBA::mergeConditions($condition, ['rel' => [Contact::SHARING, Contact::FRIEND]]);
|| ($item['verb'] == Activity::ATTENDMAYBE)
|| ($item['verb'] == Activity::ANNOUNCE)
) {
- $item['gravity'] = GRAVITY_ACTIVITY;
+ $item['gravity'] = Item::GRAVITY_ACTIVITY;
// only one like or dislike per person
// split into two queries for performance issues
$condition = [
- 'uid' => $item['uid'],
- 'author-id' => $item['author-id'],
- 'gravity' => GRAVITY_ACTIVITY,
- 'verb' => $item['verb'],
+ 'uid' => $item['uid'],
+ 'author-id' => $item['author-id'],
+ 'gravity' => Item::GRAVITY_ACTIVITY,
+ 'verb' => $item['verb'],
'parent-uri' => $item['thr-parent'],
];
if (Post::exists($condition)) {
return false;
}
- $condition = ['uid' => $item['uid'], 'author-id' => $item['author-id'], 'gravity' => GRAVITY_ACTIVITY,
+ $condition = ['uid' => $item['uid'], 'author-id' => $item['author-id'], 'gravity' => Item::GRAVITY_ACTIVITY,
'verb' => $item['verb'], 'thr-parent' => $item['thr-parent']];
if (Post::exists($condition)) {
return false;
$item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]);
- $item['body'] = Item::improveSharedDataInBody($item);
+ $quote_uri_id = Item::getQuoteUriId($item['body'], $item['uid']);
+ if (!empty($quote_uri_id)) {
+ $item['quote-uri-id'] = $quote_uri_id;
+ $item['body'] = BBCode::removeSharedData($item['body']);
+ }
Tag::storeFromBody($item['uri-id'], $item['body']);
// Now assign the rest of the values that depend on the type of the message
if (in_array($entrytype, [self::REPLY, self::REPLY_RC])) {
- $item['gravity'] = GRAVITY_COMMENT;
+ $item['gravity'] = Item::GRAVITY_COMMENT;
if (!isset($item['object-type'])) {
$item['object-type'] = Activity\ObjectType::COMMENT;
if ($entrytype == self::REPLY_RC) {
$item['wall'] = 1;
} elseif ($entrytype == self::TOP_LEVEL) {
- $item['gravity'] = GRAVITY_PARENT;
+ $item['gravity'] = Item::GRAVITY_PARENT;
if (!isset($item['object-type'])) {
$item['object-type'] = Activity\ObjectType::NOTE;
Logger::info('Contact is not sharing with the user', ['uid' => $item['uid'], 'owner-id' => $item['owner-id'], 'author-id' => $item['author-id'], 'gravity' => $item['gravity'], 'uri' => $item['uri']]);
return;
}
- if (($item['gravity'] == GRAVITY_ACTIVITY) && DI::pConfig()->get($item['uid'], 'system', 'accept_only_sharer') == Item::COMPLETION_COMMENT) {
+ if (($item['gravity'] == Item::GRAVITY_ACTIVITY) && DI::pConfig()->get($item['uid'], 'system', 'accept_only_sharer') == Item::COMPLETION_COMMENT) {
Logger::info('Completion is set to "comment", but this is an activity. so we stop here.', ['uid' => $item['uid'], 'owner-id' => $item['owner-id'], 'author-id' => $item['author-id'], 'gravity' => $item['gravity'], 'uri' => $item['uri']]);
return;
}
}
// When it is a starting post it has to belong to the person that wants to delete it
- if (($item['gravity'] == GRAVITY_PARENT) && ($item['contact-id'] != $importer['id'])) {
+ if (($item['gravity'] == Item::GRAVITY_PARENT) && ($item['contact-id'] != $importer['id'])) {
Logger::info('Item with URI ' . $uri . ' do not belong to contact ' . $importer['id'] . ' - ignoring deletion.');
return;
}
// Comments can be deleted by the thread owner or comment owner
- if (($item['gravity'] != GRAVITY_PARENT) && ($item['contact-id'] != $importer['id'])) {
+ if (($item['gravity'] != Item::GRAVITY_PARENT) && ($item['contact-id'] != $importer['id'])) {
$condition = ['id' => $item['parent'], 'contact-id' => $importer['id']];
if (!Post::exists($condition)) {
Logger::info('Item with URI ' . $uri . ' was not found or must not be deleted by contact ' . $importer['id'] . ' - ignoring deletion.');