Merge remote-tracking branch 'upstream/develop' into contact-id-new

This commit is contained in:
Michael 2019-08-02 16:52:34 +00:00
commit 9819d31591
33 changed files with 1735 additions and 190 deletions

View file

@ -1246,7 +1246,6 @@ class Item extends BaseObject
return $contact_id;
}
}
return $item['author-id'];
}
@ -1472,6 +1471,9 @@ class Item extends BaseObject
$item['plink'] = defaults($item, 'plink', System::baseUrl() . '/display/' . urlencode($item['guid']));
// The contact-id should be set before "self::insert" was called - but there seems to be issues sometimes
$item["contact-id"] = self::contactId($item);
$default = ['url' => $item['author-link'], 'name' => $item['author-name'],
'photo' => $item['author-avatar'], 'network' => $item['network']];
@ -1527,9 +1529,6 @@ class Item extends BaseObject
unset($item['causer-id']);
unset($item['causer-link']);
// The contact-id should be set before "self::insert" was called - but there seems to be issues sometimes
$item['contact-id'] = self::contactId($item);
if ($item['network'] == Protocol::PHANTOM) {
$item['network'] = Protocol::DFRN;
Logger::notice('Missing network, setting to {network}.', [
@ -2804,7 +2803,7 @@ class Item extends BaseObject
$replace = true;
}
} elseif ($item) {
if (self::samePermissions($item, $photo)) {
if (self::samePermissions($uid, $item, $photo)) {
$replace = true;
}
}
@ -2854,7 +2853,7 @@ class Item extends BaseObject
!empty($obj['deny_cid']) || !empty($obj['deny_gid']);
}
private static function samePermissions($obj1, $obj2)
private static function samePermissions($uid, $obj1, $obj2)
{
// first part is easy. Check that these are exactly the same.
if (($obj1['allow_cid'] == $obj2['allow_cid'])
@ -2875,12 +2874,12 @@ class Item extends BaseObject
}
// returns an array of contact-ids that are allowed to see this object
public static function enumeratePermissions($obj)
public static function enumeratePermissions(array $obj)
{
$allow_people = expand_acl($obj['allow_cid']);
$allow_groups = Group::expand(expand_acl($obj['allow_gid']));
$allow_groups = Group::expand($obj['uid'], expand_acl($obj['allow_gid']));
$deny_people = expand_acl($obj['deny_cid']);
$deny_groups = Group::expand(expand_acl($obj['deny_gid']));
$deny_groups = Group::expand($obj['uid'], expand_acl($obj['deny_gid']));
$recipients = array_unique(array_merge($allow_people, $allow_groups));
$deny = array_unique(array_merge($deny_people, $deny_groups));
$recipients = array_diff($recipients, $deny);