Improve local forum distribution
This commit is contained in:
parent
a5a1c81790
commit
d404f15312
|
@ -1402,9 +1402,15 @@ class Item
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((($item['gravity'] == GRAVITY_COMMENT) || $is_reshare) && !Post::exists(['uri-id' => $item['thr-parent-id'], 'uid' => $uid])) {
|
if ((($item['gravity'] == GRAVITY_COMMENT) || $is_reshare) && !Post::exists(['uri-id' => $item['thr-parent-id'], 'uid' => $uid])) {
|
||||||
// Only do an auto complete with the source uid "0" to prevent privavy problems
|
// Fetch the origin user for the post
|
||||||
|
$origin_uid = self::GetOriginUidForUriId($item['thr-parent-id'], $uid);
|
||||||
|
if (is_null($origin_uid)) {
|
||||||
|
Logger::info('Origin item was not found', ['uid' => $uid, 'uri-id' => $item['thr-parent-id']]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
$causer = $item['causer-id'] ?: $item['author-id'];
|
$causer = $item['causer-id'] ?: $item['author-id'];
|
||||||
$result = self::storeForUserByUriId($item['thr-parent-id'], $uid, ['causer-id' => $causer, 'post-reason' => self::PR_FETCHED]);
|
$result = self::storeForUserByUriId($item['thr-parent-id'], $uid, ['causer-id' => $causer, 'post-reason' => self::PR_FETCHED], $origin_uid);
|
||||||
Logger::info('Fetched thread parent', ['uri-id' => $item['thr-parent-id'], 'uid' => $uid, 'causer' => $causer, 'result' => $result]);
|
Logger::info('Fetched thread parent', ['uri-id' => $item['thr-parent-id'], 'uid' => $uid, 'causer' => $causer, 'result' => $result]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1413,6 +1419,46 @@ class Item
|
||||||
return $stored;
|
return $stored;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the origin uid of a post if the given user is allowed to see it.
|
||||||
|
*
|
||||||
|
* @param int $uriid
|
||||||
|
* @param int $uid
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private static function GetOriginUidForUriId(int $uriid, int $uid)
|
||||||
|
{
|
||||||
|
if (Post::exists(['uri-id' => $uriid, 'uid' => $uid])) {
|
||||||
|
return $uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
$post = Post::selectFirst(['uid', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'private'], ['uri-id' => $uriid, 'origin' => true]);
|
||||||
|
if (empty($post)) {
|
||||||
|
if (Post::exists(['uri-id' => $uriid, 'uid' => 0])) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($post['private'], [Item::PUBLIC, Item::UNLISTED])) {
|
||||||
|
return $post['uid'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$pcid = Contact::getPublicIdByUserId($uid);
|
||||||
|
if (empty($pcid)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (Item::enumeratePermissions($post, true) as $receiver) {
|
||||||
|
if ($receiver == $pcid) {
|
||||||
|
return $post['uid'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store a public item array for the given users
|
* Store a public item array for the given users
|
||||||
*
|
*
|
||||||
|
@ -1928,7 +1974,7 @@ class Item
|
||||||
|
|
||||||
$allow_cid = '<' . $owner['id'] . '>';
|
$allow_cid = '<' . $owner['id'] . '>';
|
||||||
$allow_gid = '<' . Group::getIdForForum($owner['id']) . '>';
|
$allow_gid = '<' . Group::getIdForForum($owner['id']) . '>';
|
||||||
$deny_cid = '';
|
$deny_cid = '';
|
||||||
$deny_gid = '';
|
$deny_gid = '';
|
||||||
self::performActivity($item['id'], 'announce', $uid, $allow_cid, $allow_gid, $deny_cid, $deny_gid);
|
self::performActivity($item['id'], 'announce', $uid, $allow_cid, $allow_gid, $deny_cid, $deny_gid);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -600,23 +600,32 @@ class Transmitter
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($profile = APContact::getByURL($contact['url'], false))) {
|
$profile = APContact::getByURL($term['url'], false);
|
||||||
|
if (!empty($profile)) {
|
||||||
|
if ($term['type'] == Tag::EXCLUSIVE_MENTION) {
|
||||||
|
$exclusive = true;
|
||||||
|
if (!empty($profile['followers']) && ($profile['type'] == 'Group')) {
|
||||||
|
$data['cc'][] = $profile['followers'];
|
||||||
|
}
|
||||||
|
}
|
||||||
$data['to'][] = $profile['url'];
|
$data['to'][] = $profile['url'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($receiver_list as $receiver) {
|
if (!$exclusive) {
|
||||||
$contact = DBA::selectFirst('contact', ['url', 'hidden', 'network', 'protocol', 'gsid'], ['id' => $receiver, 'network' => Protocol::FEDERATED]);
|
foreach ($receiver_list as $receiver) {
|
||||||
if (!DBA::isResult($contact) || !self::isAPContact($contact, $networks)) {
|
$contact = DBA::selectFirst('contact', ['url', 'hidden', 'network', 'protocol', 'gsid'], ['id' => $receiver, 'network' => Protocol::FEDERATED]);
|
||||||
continue;
|
if (!DBA::isResult($contact) || !self::isAPContact($contact, $networks)) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($profile = APContact::getByURL($contact['url'], false))) {
|
if (!empty($profile = APContact::getByURL($contact['url'], false))) {
|
||||||
if ($contact['hidden'] || $always_bcc) {
|
if ($contact['hidden'] || $always_bcc) {
|
||||||
$data['bcc'][] = $profile['url'];
|
$data['bcc'][] = $profile['url'];
|
||||||
} else {
|
} else {
|
||||||
$data['cc'][] = $profile['url'];
|
$data['cc'][] = $profile['url'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user