mirror of
https://github.com/friendica/friendica
synced 2024-11-09 17:02:54 +00:00
Merge pull request #14202 from annando/fix-attachment
Fix: Posts with attached links work again
This commit is contained in:
commit
03db8ee52c
1 changed files with 41 additions and 27 deletions
|
@ -162,7 +162,7 @@ class Transmitter
|
||||||
public static function getContacts(array $owner, array $rel, string $module, int $page = null, string $requester = null, bool $nocache = false): array
|
public static function getContacts(array $owner, array $rel, string $module, int $page = null, string $requester = null, bool $nocache = false): array
|
||||||
{
|
{
|
||||||
if (empty($page)) {
|
if (empty($page)) {
|
||||||
$cachekey = self::CACHEKEY_CONTACTS . $module . ':'. $owner['uid'];
|
$cachekey = self::CACHEKEY_CONTACTS . $module . ':' . $owner['uid'];
|
||||||
$result = DI::cache()->get($cachekey);
|
$result = DI::cache()->get($cachekey);
|
||||||
if (!$nocache && !is_null($result)) {
|
if (!$nocache && !is_null($result)) {
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -262,8 +262,10 @@ class Transmitter
|
||||||
|
|
||||||
$owner_cid = Contact::getIdForURL($owner['url'], 0, false);
|
$owner_cid = Contact::getIdForURL($owner['url'], 0, false);
|
||||||
|
|
||||||
$condition = ["`uri-id` IN (SELECT `uri-id` FROM `collection-view` WHERE `cid` = ? AND `type` = ?)",
|
$condition = [
|
||||||
$owner_cid, Post\Collection::FEATURED];
|
"`uri-id` IN (SELECT `uri-id` FROM `collection-view` WHERE `cid` = ? AND `type` = ?)",
|
||||||
|
$owner_cid, Post\Collection::FEATURED
|
||||||
|
];
|
||||||
|
|
||||||
$condition = DBA::mergeConditions($condition, [
|
$condition = DBA::mergeConditions($condition, [
|
||||||
'uid' => $owner['uid'],
|
'uid' => $owner['uid'],
|
||||||
|
@ -377,8 +379,10 @@ class Transmitter
|
||||||
$data['name'] = $full ? $owner['name'] : $owner['nick'];
|
$data['name'] = $full ? $owner['name'] : $owner['nick'];
|
||||||
|
|
||||||
if ($full && !empty($owner['country-name'] . $owner['region'] . $owner['locality'])) {
|
if ($full && !empty($owner['country-name'] . $owner['region'] . $owner['locality'])) {
|
||||||
$data['vcard:hasAddress'] = ['@type' => 'vcard:Home', 'vcard:country-name' => $owner['country-name'],
|
$data['vcard:hasAddress'] = [
|
||||||
'vcard:region' => $owner['region'], 'vcard:locality' => $owner['locality']];
|
'@type' => 'vcard:Home', 'vcard:country-name' => $owner['country-name'],
|
||||||
|
'vcard:region' => $owner['region'], 'vcard:locality' => $owner['locality']
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($full && !empty($owner['about'])) {
|
if ($full && !empty($owner['about'])) {
|
||||||
|
@ -399,9 +403,11 @@ class Transmitter
|
||||||
$data['url'] = $owner['url'];
|
$data['url'] = $owner['url'];
|
||||||
$data['manuallyApprovesFollowers'] = in_array($owner['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP]);
|
$data['manuallyApprovesFollowers'] = in_array($owner['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP]);
|
||||||
$data['discoverable'] = (bool)$owner['net-publish'] && $full;
|
$data['discoverable'] = (bool)$owner['net-publish'] && $full;
|
||||||
$data['publicKey'] = ['id' => $owner['url'] . '#main-key',
|
$data['publicKey'] = [
|
||||||
|
'id' => $owner['url'] . '#main-key',
|
||||||
'owner' => $owner['url'],
|
'owner' => $owner['url'],
|
||||||
'publicKeyPem' => $owner['pubkey']];
|
'publicKeyPem' => $owner['pubkey']
|
||||||
|
];
|
||||||
$data['endpoints'] = ['sharedInbox' => DI::baseUrl() . '/inbox'];
|
$data['endpoints'] = ['sharedInbox' => DI::baseUrl() . '/inbox'];
|
||||||
if ($full && $uid != 0) {
|
if ($full && $uid != 0) {
|
||||||
$data['icon'] = ['type' => 'Image', 'url' => User::getAvatarUrl($owner)];
|
$data['icon'] = ['type' => 'Image', 'url' => User::getAvatarUrl($owner)];
|
||||||
|
@ -1201,7 +1207,7 @@ class Transmitter
|
||||||
$mail['sensitive'] = false;
|
$mail['sensitive'] = false;
|
||||||
$mail['author-link'] = $mail['owner-link'] = $mail['from-url'];
|
$mail['author-link'] = $mail['owner-link'] = $mail['from-url'];
|
||||||
$mail['owner-id'] = $mail['author-id'];
|
$mail['owner-id'] = $mail['author-id'];
|
||||||
$mail['allow_cid'] = '<'.$mail['contact-id'].'>';
|
$mail['allow_cid'] = '<' . $mail['contact-id'] . '>';
|
||||||
$mail['allow_gid'] = '';
|
$mail['allow_gid'] = '';
|
||||||
$mail['deny_cid'] = '';
|
$mail['deny_cid'] = '';
|
||||||
$mail['deny_gid'] = '';
|
$mail['deny_gid'] = '';
|
||||||
|
@ -1212,7 +1218,7 @@ class Transmitter
|
||||||
$mail['parent-uri'] = $reply['uri'];
|
$mail['parent-uri'] = $reply['uri'];
|
||||||
$mail['parent-uri-id'] = $reply['uri-id'];
|
$mail['parent-uri-id'] = $reply['uri-id'];
|
||||||
$mail['parent-author-id'] = Contact::getIdForURL($reply['from-url'], 0, false);
|
$mail['parent-author-id'] = Contact::getIdForURL($reply['from-url'], 0, false);
|
||||||
$mail['gravity'] = ($mail['reply'] ? Item::GRAVITY_COMMENT: Item::GRAVITY_PARENT);
|
$mail['gravity'] = ($mail['reply'] ? Item::GRAVITY_COMMENT : Item::GRAVITY_PARENT);
|
||||||
$mail['event-type'] = '';
|
$mail['event-type'] = '';
|
||||||
$mail['language'] = '';
|
$mail['language'] = '';
|
||||||
$mail['parent'] = 0;
|
$mail['parent'] = 0;
|
||||||
|
@ -1655,10 +1661,12 @@ class Transmitter
|
||||||
}
|
}
|
||||||
$urls[] = $attachment['url'];
|
$urls[] = $attachment['url'];
|
||||||
|
|
||||||
$attach = ['type' => 'Document',
|
$attach = [
|
||||||
|
'type' => 'Document',
|
||||||
'mediaType' => $attachment['mimetype'],
|
'mediaType' => $attachment['mimetype'],
|
||||||
'url' => $attachment['url'],
|
'url' => $attachment['url'],
|
||||||
'name' => $attachment['description']];
|
'name' => $attachment['description']
|
||||||
|
];
|
||||||
|
|
||||||
if (!empty($attachment['height'])) {
|
if (!empty($attachment['height'])) {
|
||||||
$attach['height'] = $attachment['height'];
|
$attach['height'] = $attachment['height'];
|
||||||
|
@ -1790,7 +1798,6 @@ class Transmitter
|
||||||
|
|
||||||
$title = $item['title'];
|
$title = $item['title'];
|
||||||
$summary = $item['content-warning'] ?: BBCode::toPlaintext(BBCode::getAbstract($item['body'], Protocol::ACTIVITYPUB));
|
$summary = $item['content-warning'] ?: BBCode::toPlaintext(BBCode::getAbstract($item['body'], Protocol::ACTIVITYPUB));
|
||||||
$source = $item['body'];
|
|
||||||
|
|
||||||
if ($item['event-type'] == 'event') {
|
if ($item['event-type'] == 'event') {
|
||||||
$type = 'Event';
|
$type = 'Event';
|
||||||
|
@ -1805,9 +1812,8 @@ class Transmitter
|
||||||
if (!$summary) {
|
if (!$summary) {
|
||||||
$summary = $title;
|
$summary = $title;
|
||||||
} else {
|
} else {
|
||||||
$item['raw-body'] = '[b]' . $title . "[/b]\n\n" . $item['raw-body'];
|
$item['raw-body'] = '[h4][b]' . $title . "[/b][/h4]\n\n" . $item['raw-body'];
|
||||||
$item['body'] = '[b]' . $title . "[/b]\n\n" . $item['body'];
|
$item['body'] = '[h4][b]' . $title . "[/b][/h4]\n\n" . $item['body'];
|
||||||
$source = '[h4]' . $title . "[/h4]\n" . $source;
|
|
||||||
}
|
}
|
||||||
$title = '';
|
$title = '';
|
||||||
break;
|
break;
|
||||||
|
@ -1815,7 +1821,6 @@ class Transmitter
|
||||||
$type = 'Note';
|
$type = 'Note';
|
||||||
$item['raw-body'] = '[b]' . $title . "[/b]\n\n" . $item['raw-body'];
|
$item['raw-body'] = '[b]' . $title . "[/b]\n\n" . $item['raw-body'];
|
||||||
$item['body'] = '[b]' . $title . "[/b]\n\n" . $item['body'];
|
$item['body'] = '[b]' . $title . "[/b]\n\n" . $item['body'];
|
||||||
$source = '[h4]' . $title . "[/h4]\n" . $source;
|
|
||||||
$title = '';
|
$title = '';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1954,7 +1959,9 @@ class Transmitter
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] != $item['uri-id'])) {
|
if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] != $item['uri-id'])) {
|
||||||
$source = DI::contentItem()->addSharedPost($item, $source);
|
$source = DI::contentItem()->addSharedPost($item, $item['body']);
|
||||||
|
} else {
|
||||||
|
$source = $item['body'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['source'] = ['content' => $source, 'mediaType' => "text/bbcode"];
|
$data['source'] = ['content' => $source, 'mediaType' => "text/bbcode"];
|
||||||
|
@ -2128,8 +2135,8 @@ class Transmitter
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$hash = hash('ripemd128', $contact['uid'].'-'.$contact['id'].'-'.$contact['created']);
|
$hash = hash('ripemd128', $contact['uid'] . '-' . $contact['id'] . '-' . $contact['created']);
|
||||||
$uuid = substr($hash, 0, 8). '-' . substr($hash, 8, 4) . '-' . substr($hash, 12, 4) . '-' . substr($hash, 16, 4) . '-' . substr($hash, 20, 12);
|
$uuid = substr($hash, 0, 8) . '-' . substr($hash, 8, 4) . '-' . substr($hash, 12, 4) . '-' . substr($hash, 16, 4) . '-' . substr($hash, 20, 12);
|
||||||
return DI::baseUrl() . '/activity/' . $uuid;
|
return DI::baseUrl() . '/activity/' . $uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2207,7 +2214,8 @@ class Transmitter
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = ['@context' => ActivityPub::CONTEXT,
|
$data = [
|
||||||
|
'@context' => ActivityPub::CONTEXT,
|
||||||
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
||||||
'type' => 'Delete',
|
'type' => 'Delete',
|
||||||
'actor' => $owner['url'],
|
'actor' => $owner['url'],
|
||||||
|
@ -2215,7 +2223,8 @@ class Transmitter
|
||||||
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||||
'instrument' => self::getService(),
|
'instrument' => self::getService(),
|
||||||
'to' => [ActivityPub::PUBLIC_COLLECTION],
|
'to' => [ActivityPub::PUBLIC_COLLECTION],
|
||||||
'cc' => []];
|
'cc' => []
|
||||||
|
];
|
||||||
|
|
||||||
$signed = LDSignature::sign($data, $owner);
|
$signed = LDSignature::sign($data, $owner);
|
||||||
|
|
||||||
|
@ -2237,7 +2246,8 @@ class Transmitter
|
||||||
{
|
{
|
||||||
$profile = APContact::getByURL($owner['url']);
|
$profile = APContact::getByURL($owner['url']);
|
||||||
|
|
||||||
$data = ['@context' => ActivityPub::CONTEXT,
|
$data = [
|
||||||
|
'@context' => ActivityPub::CONTEXT,
|
||||||
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
||||||
'type' => 'Update',
|
'type' => 'Update',
|
||||||
'actor' => $owner['url'],
|
'actor' => $owner['url'],
|
||||||
|
@ -2245,7 +2255,8 @@ class Transmitter
|
||||||
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||||
'instrument' => self::getService(),
|
'instrument' => self::getService(),
|
||||||
'to' => [$profile['followers']],
|
'to' => [$profile['followers']],
|
||||||
'cc' => []];
|
'cc' => []
|
||||||
|
];
|
||||||
|
|
||||||
$signed = LDSignature::sign($data, $owner);
|
$signed = LDSignature::sign($data, $owner);
|
||||||
|
|
||||||
|
@ -2330,8 +2341,10 @@ class Transmitter
|
||||||
$uid = $admin['uid'];
|
$uid = $admin['uid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$condition = ['verb' => Activity::FOLLOW, 'uid' => 0, 'parent-uri' => $object,
|
$condition = [
|
||||||
'author-id' => Contact::getPublicIdByUserId($uid)];
|
'verb' => Activity::FOLLOW, 'uid' => 0, 'parent-uri' => $object,
|
||||||
|
'author-id' => Contact::getPublicIdByUserId($uid)
|
||||||
|
];
|
||||||
if (Post::exists($condition)) {
|
if (Post::exists($condition)) {
|
||||||
Logger::info('Follow for ' . $object . ' for user ' . $uid . ' does already exist.');
|
Logger::info('Follow for ' . $object . ' for user ' . $uid . ' does already exist.');
|
||||||
return false;
|
return false;
|
||||||
|
@ -2500,7 +2513,8 @@ class Transmitter
|
||||||
|
|
||||||
foreach (Tag::getByURIId($uriid, [Tag::IMPLICIT_MENTION]) as $tag) {
|
foreach (Tag::getByURIId($uriid, [Tag::IMPLICIT_MENTION]) as $tag) {
|
||||||
$profile = Contact::getByURL($tag['url'], false, ['addr', 'contact-type', 'nick']);
|
$profile = Contact::getByURL($tag['url'], false, ['addr', 'contact-type', 'nick']);
|
||||||
if (!empty($profile['addr'])
|
if (
|
||||||
|
!empty($profile['addr'])
|
||||||
&& $profile['contact-type'] != Contact::TYPE_COMMUNITY
|
&& $profile['contact-type'] != Contact::TYPE_COMMUNITY
|
||||||
&& !strstr($body, $profile['addr'])
|
&& !strstr($body, $profile['addr'])
|
||||||
&& !strstr($body, $tag['url'])
|
&& !strstr($body, $tag['url'])
|
||||||
|
|
Loading…
Reference in a new issue