$actor_profile = APContact::getByURL($item['author-link']);
}
+ $exclusive = false;
+
$terms = Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]);
if ($item['private'] != Item::PRIVATE) {
foreach ($terms as $term) {
$profile = APContact::getByURL($term['url'], false);
if (!empty($profile)) {
+ if ($term['type'] == Tag::EXCLUSIVE_MENTION) {
+ $exclusive = true;
+ }
$data['to'][] = $profile['url'];
}
}
$data['cc'][] = $actor_profile['followers'];
}
}
- } else {
+ } elseif (!$exclusive) {
// Public thread parent post always are directed to the followers
if (($item['private'] != Item::PRIVATE) && !$forum_mode) {
$data['cc'][] = $actor_profile['followers'];
$contacts = DBA::select('contact', ['id', 'url', 'network', 'protocol', 'gsid'], $condition);
while ($contact = DBA::fetch($contacts)) {
- if (Contact::isLocal($contact['url'])) {
- continue;
- }
-
if (!self::isAPContact($contact, $networks)) {
continue;
}
$profile = APContact::getByURL($contact['url'], false);
if (!empty($profile)) {
- if (empty($profile['sharedinbox']) || $personal) {
+ if (empty($profile['sharedinbox']) || $personal || Contact::isLocal($contact['url'])) {
$target = $profile['inbox'];
} else {
$target = $profile['sharedinbox'];
if ($item_profile && ($receiver == $item_profile['followers']) && ($uid == $profile_uid)) {
$inboxes = array_merge($inboxes, self::fetchTargetInboxesforUser($uid, $personal, self::isAPPost($last_id)));
} else {
- if (Contact::isLocal($receiver)) {
- continue;
- }
-
$profile = APContact::getByURL($receiver, false);
if (!empty($profile)) {
$contact = Contact::getByURLForUser($receiver, $uid, false, ['id']);
- if (empty($profile['sharedinbox']) || $personal || $blindcopy) {
+ if (empty($profile['sharedinbox']) || $personal || $blindcopy || Contact::isLocal($receiver)) {
$target = $profile['inbox'];
} else {
$target = $profile['sharedinbox'];
* @return array
* @throws \Exception
*/
- public static function ItemArrayFromMail($mail_id)
+ public static function ItemArrayFromMail($mail_id, $use_title = false)
{
$mail = DBA::selectFirst('mail', [], ['id' => $mail_id]);
if (!DBA::isResult($mail)) {
return [];
}
- $mail['uri-id'] = ItemURI::insert(['uri' => $mail['uri'], 'guid' => $mail['guid']]);
-
- $reply = DBA::selectFirst('mail', ['uri'], ['parent-uri' => $mail['parent-uri'], 'reply' => false]);
+ $reply = DBA::selectFirst('mail', ['uri', 'uri-id', 'from-url'], ['parent-uri' => $mail['parent-uri'], 'reply' => false]);
// Making the post more compatible for Mastodon by:
// - Making it a note and not an article (no title)
// - Moving the title into the "summary" field that is used as a "content warning"
- $mail['body'] = '[abstract]' . $mail['title'] . "[/abstract]\n" . $mail['body'];
- $mail['title'] = '';
-
- $mail['author-link'] = $mail['owner-link'] = $mail['from-url'];
- $mail['allow_cid'] = '<'.$mail['contact-id'].'>';
- $mail['allow_gid'] = '';
- $mail['deny_cid'] = '';
- $mail['deny_gid'] = '';
- $mail['private'] = true;
- $mail['deleted'] = false;
- $mail['edited'] = $mail['created'];
- $mail['plink'] = $mail['uri'];
- $mail['thr-parent'] = $reply['uri'];
- $mail['gravity'] = ($mail['reply'] ? GRAVITY_COMMENT: GRAVITY_PARENT);
- $mail['event-type'] = '';
-
- $mail['parent'] = 0;
+ if (!$use_title) {
+ $mail['body'] = '[abstract]' . $mail['title'] . "[/abstract]\n" . $mail['body'];
+ $mail['title'] = '';
+ }
+
+ $mail['author-link'] = $mail['owner-link'] = $mail['from-url'];
+ $mail['owner-id'] = $mail['author-id'];
+ $mail['allow_cid'] = '<'.$mail['contact-id'].'>';
+ $mail['allow_gid'] = '';
+ $mail['deny_cid'] = '';
+ $mail['deny_gid'] = '';
+ $mail['private'] = Item::PRIVATE;
+ $mail['deleted'] = false;
+ $mail['edited'] = $mail['created'];
+ $mail['plink'] = DI::baseUrl() . '/message/' . $mail['id'];
+ $mail['parent-uri'] = $reply['uri'];
+ $mail['parent-uri-id'] = $reply['uri-id'];
+ $mail['parent-author-id'] = Contact::getIdForURL($reply['from-url'], 0, false);
+ $mail['gravity'] = ($mail['reply'] ? GRAVITY_COMMENT: GRAVITY_PARENT);
+ $mail['event-type'] = '';
+ $mail['language'] = '';
+ $mail['parent'] = 0;
return $mail;
}
if ($type == 'Note') {
$body = $item['raw-body'] ?? self::removePictures($body);
- } elseif (($type == 'Article') && empty($data['summary'])) {
- $regexp = "/[@!]\[url\=([^\[\]]*)\].*?\[\/url\]/ism";
- $summary = preg_replace_callback($regexp, ['self', 'mentionAddrCallback'], $body);
- $data['summary'] = BBCode::toPlaintext(Plaintext::shorten(self::removePictures($summary), 1000));
}
+ /**
+ * @todo Improve the automated summary
+ * This part is currently deactivated. The automated summary seems to be more
+ * confusing than helping. But possibly we will find a better way.
+ * So the code is left here for now as a reminder
+ *
+ * } elseif (($type == 'Article') && empty($data['summary'])) {
+ * $regexp = "/[@!]\[url\=([^\[\]]*)\].*?\[\/url\]/ism";
+ * $summary = preg_replace_callback($regexp, ['self', 'mentionAddrCallback'], $body);
+ * $data['summary'] = BBCode::toPlaintext(Plaintext::shorten(self::removePictures($summary), 1000));
+ * }
+ */
+
if (empty($item['uid']) || !Feature::isEnabled($item['uid'], 'explicit_mentions')) {
$body = self::prependMentions($body, $item['uri-id'], $item['author-link']);
}