mirror of
https://github.com/friendica/friendica
synced 2025-04-24 06:30:13 +00:00
Merge remote-tracking branch 'friendica/stable' into develop
# Conflicts: # composer.lock
This commit is contained in:
commit
a852455d0e
154 changed files with 26577 additions and 25630 deletions
|
@ -58,6 +58,15 @@ class Item
|
|||
const PT_DOCUMENT = 19;
|
||||
const PT_EVENT = 32;
|
||||
const PT_TAG = 64;
|
||||
const PT_TO = 65;
|
||||
const PT_CC = 66;
|
||||
const PT_BTO = 67;
|
||||
const PT_BCC = 68;
|
||||
const PT_FOLLOWER = 69;
|
||||
const PT_ANNOUNCEMENT = 70;
|
||||
const PT_COMMENT = 71;
|
||||
const PT_STORED = 72;
|
||||
const PT_GLOBAL = 73;
|
||||
const PT_PERSONAL_NOTE = 128;
|
||||
|
||||
// Field list that is used to display the items
|
||||
|
@ -202,19 +211,7 @@ class Item
|
|||
return [];
|
||||
}
|
||||
|
||||
if (empty($condition) || !is_array($condition)) {
|
||||
$condition = ['iid' => $pinned];
|
||||
} else {
|
||||
reset($condition);
|
||||
$first_key = key($condition);
|
||||
if (!is_int($first_key)) {
|
||||
$condition['iid'] = $pinned;
|
||||
} else {
|
||||
$values_string = substr(str_repeat("?, ", count($pinned)), 0, -2);
|
||||
$condition[0] = '(' . $condition[0] . ") AND `iid` IN (" . $values_string . ")";
|
||||
$condition = array_merge($condition, $pinned);
|
||||
}
|
||||
}
|
||||
$condition = DBA::mergeConditions(['iid' => $pinned], $condition);
|
||||
|
||||
return self::selectThreadForUser($uid, $selected, $condition, $params);
|
||||
}
|
||||
|
@ -1704,6 +1701,11 @@ class Item
|
|||
'photo' => $item['owner-avatar'], 'network' => $item['network']];
|
||||
$item['owner-id'] = ($item['owner-id'] ?? 0) ?: Contact::getIdForURL($item['owner-link'], 0, null, $default);
|
||||
|
||||
$actor = ($item['gravity'] == GRAVITY_PARENT) ? $item['owner-id'] : $item['author-id'];
|
||||
if (!$item['origin'] && in_array($item['post-type'], [self::PT_ARTICLE, self::PT_COMMENT, self::PT_GLOBAL]) && Contact::isSharing($actor, $item['uid'])) {
|
||||
$item['post-type'] = self::PT_FOLLOWER;
|
||||
}
|
||||
|
||||
// Ensure that there is an avatar cache
|
||||
Contact::checkAvatarCache($item['author-id']);
|
||||
Contact::checkAvatarCache($item['owner-id']);
|
||||
|
@ -2006,10 +2008,10 @@ class Item
|
|||
*/
|
||||
private static function setOwnerforResharedItem(array $item)
|
||||
{
|
||||
$parent = self::selectFirst(['id', 'owner-id', 'author-id', 'author-link', 'origin'],
|
||||
['uri-id' => $item['parent-uri-id'], 'uid' => $item['uid']]);
|
||||
$parent = self::selectFirst(['id', 'owner-id', 'author-id', 'author-link', 'origin', 'post-type'],
|
||||
['uri-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
|
||||
if (!DBA::isResult($parent)) {
|
||||
Logger::error('Parent not found', ['uri-id' => $item['parent-uri-id'], 'uid' => $item['uid']]);
|
||||
Logger::error('Parent not found', ['uri-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2019,19 +2021,24 @@ class Item
|
|||
return;
|
||||
}
|
||||
|
||||
if ($author['contact-type'] != Contact::TYPE_COMMUNITY) {
|
||||
logger::info('The resharer is no forum: quit', ['resharer' => $item['author-id'], 'owner' => $parent['owner-id'], 'author' => $parent['author-id'], 'uid' => $item['uid']]);
|
||||
return;
|
||||
}
|
||||
|
||||
$cid = Contact::getIdForURL($author['url'], $item['uid']);
|
||||
if (empty($cid) || !Contact::isSharing($cid, $item['uid'])) {
|
||||
logger::info('The resharer is not a following contact: quit', ['resharer' => $author['url'], 'uid' => $item['uid']]);
|
||||
Logger::info('The resharer is not a following contact: quit', ['resharer' => $author['url'], 'uid' => $item['uid']]);
|
||||
return;
|
||||
}
|
||||
|
||||
Item::update(['owner-id' => $item['author-id'], 'contact-id' => $cid], ['id' => $parent['id']]);
|
||||
Logger::info('Change owner of the parent', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'uid' => $item['uid'], 'owner-id' => $item['author-id'], 'contact-id' => $cid]);
|
||||
if ($author['contact-type'] != Contact::TYPE_COMMUNITY) {
|
||||
if (!in_array($parent['post-type'], [self::PT_ARTICLE, self::PT_COMMENT]) || Contact::isSharing($parent['owner-id'], $item['uid'])) {
|
||||
Logger::info('The resharer is no forum: quit', ['resharer' => $item['author-id'], 'owner' => $parent['owner-id'], 'author' => $parent['author-id'], 'uid' => $item['uid']]);
|
||||
return;
|
||||
}
|
||||
self::update(['post-type' => self::PT_ANNOUNCEMENT], ['id' => $parent['id']]);
|
||||
Logger::info('Set announcement post-type', ['uri-id' => $item['uri-id'], 'thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
|
||||
return;
|
||||
}
|
||||
|
||||
self::update(['owner-id' => $item['author-id'], 'contact-id' => $cid], ['id' => $parent['id']]);
|
||||
Logger::info('Change owner of the parent', ['uri-id' => $item['uri-id'], 'thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid'], 'owner-id' => $item['author-id'], 'contact-id' => $cid]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2237,6 +2244,8 @@ class Item
|
|||
return 0;
|
||||
}
|
||||
|
||||
$item['post-type'] = self::PT_STORED;
|
||||
|
||||
$item = array_merge($item, $fields);
|
||||
|
||||
$stored = self::storeForUser($item, $uid);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue