mirror of
https://github.com/friendica/friendica
synced 2025-05-01 11:44:24 +02:00
Merge remote-tracking branch 'upstream/develop' into delivery-statistics
This commit is contained in:
commit
9bf065c9d8
21 changed files with 2400 additions and 1837 deletions
|
@ -1328,7 +1328,7 @@ class Contact extends BaseObject
|
|||
|
||||
// Update the contact in the background if needed but it is called by the frontend
|
||||
if ($update_contact && $no_update && in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
|
||||
Worker::add(PRIORITY_LOW, "UpdateContact", $contact_id);
|
||||
Worker::add(PRIORITY_LOW, "UpdateContact", $contact_id, ($uid == 0 ? 'force' : ''));
|
||||
}
|
||||
|
||||
if (!$update_contact || $no_update) {
|
||||
|
@ -1425,7 +1425,7 @@ class Contact extends BaseObject
|
|||
|
||||
// Update in the background when we fetched the data solely from the database
|
||||
if ($background_update) {
|
||||
Worker::add(PRIORITY_LOW, "UpdateContact", $contact_id);
|
||||
Worker::add(PRIORITY_LOW, "UpdateContact", $contact_id, ($uid == 0 ? 'force' : ''));
|
||||
}
|
||||
|
||||
// Update the newly created contact from data in the gcontact table
|
||||
|
@ -1452,7 +1452,7 @@ class Contact extends BaseObject
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($data['photo'])) {
|
||||
if (!empty($data['photo']) && ($data['network'] != Protocol::FEED)) {
|
||||
self::updateAvatar($data['photo'], $uid, $contact_id);
|
||||
}
|
||||
|
||||
|
@ -1755,6 +1755,51 @@ class Contact extends BaseObject
|
|||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Helper function for "updateFromProbe". Updates personal and public contact
|
||||
*
|
||||
* @param array $contact The personal contact entry
|
||||
* @param array $fields The fields that are updated
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function updateContact($id, $uid, $url, array $fields)
|
||||
{
|
||||
DBA::update('contact', $fields, ['id' => $id]);
|
||||
|
||||
if ($uid != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Archive or unarchive the contact. We only need to do this for the public contact.
|
||||
// The archive/unarchive function will update the personal contacts by themselves.
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $id]);
|
||||
if (!empty($fields['success_update'])) {
|
||||
self::unmarkForArchival($contact);
|
||||
} elseif (!empty($fields['failure_update'])) {
|
||||
self::markForArchival($contact);
|
||||
}
|
||||
|
||||
$condition = ['self' => false, 'nurl' => Strings::normaliseLink($url),
|
||||
'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]];
|
||||
|
||||
// These contacts are sharing with us, we don't poll them.
|
||||
// This means that we don't set the update fields in "OnePoll.php".
|
||||
$condition['rel'] = self::SHARING;
|
||||
DBA::update('contact', $fields, $condition);
|
||||
|
||||
unset($fields['last-update']);
|
||||
unset($fields['success_update']);
|
||||
unset($fields['failure_update']);
|
||||
|
||||
if (empty($fields)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We are polling these contacts, so we mustn't set the update fields here.
|
||||
$condition['rel'] = [self::FOLLOWER, self::FRIEND];
|
||||
DBA::update('contact', $fields, $condition);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $id contact id
|
||||
* @param string $network Optional network we are probing for
|
||||
|
@ -1767,7 +1812,7 @@ class Contact extends BaseObject
|
|||
{
|
||||
/*
|
||||
Warning: Never ever fetch the public key via Probe::uri and write it into the contacts.
|
||||
This will reliably kill your communication with Friendica contacts.
|
||||
This will reliably kill your communication with old Friendica contacts.
|
||||
*/
|
||||
|
||||
$fields = ['avatar', 'uid', 'name', 'nick', 'url', 'addr', 'batch', 'notify',
|
||||
|
@ -1785,12 +1830,14 @@ class Contact extends BaseObject
|
|||
|
||||
$ret = Probe::uri($contact['url'], $network, $uid, !$force);
|
||||
|
||||
// If Probe::uri fails the network code will be different (mostly "feed" or "unkn")
|
||||
if (in_array($ret['network'], [Protocol::FEED, Protocol::PHANTOM]) && ($ret['network'] != $contact['network'])) {
|
||||
return false;
|
||||
}
|
||||
$updated = DateTimeFormat::utcNow();
|
||||
|
||||
if (!in_array($ret['network'], Protocol::NATIVE_SUPPORT)) {
|
||||
// If Probe::uri fails the network code will be different (mostly "feed" or "unkn")
|
||||
if (!in_array($ret['network'], Protocol::NATIVE_SUPPORT) ||
|
||||
(in_array($ret['network'], [Protocol::FEED, Protocol::PHANTOM]) && ($ret['network'] != $contact['network']))) {
|
||||
if ($force && ($uid == 0)) {
|
||||
self::updateContact($id, $uid, $ret['url'], ['last-update' => $updated, 'failure_update' => $updated]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1807,17 +1854,28 @@ class Contact extends BaseObject
|
|||
}
|
||||
}
|
||||
|
||||
if ($ret['network'] != Protocol::FEED) {
|
||||
self::updateAvatar($ret['photo'], $uid, $id, $update || $force);
|
||||
}
|
||||
|
||||
if (!$update) {
|
||||
if ($force && ($uid == 0)) {
|
||||
self::updateContact($id, $uid, $ret['url'], ['last-update' => $updated, 'success_update' => $updated]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
$ret['nurl'] = Strings::normaliseLink($ret['url']);
|
||||
$ret['updated'] = DateTimeFormat::utcNow();
|
||||
$ret['updated'] = $updated;
|
||||
|
||||
self::updateAvatar($ret['photo'], $uid, $id, true);
|
||||
if ($force && ($uid == 0)) {
|
||||
$ret['last-update'] = $updated;
|
||||
$ret['success_update'] = $updated;
|
||||
}
|
||||
|
||||
unset($ret['photo']);
|
||||
DBA::update('contact', $ret, ['id' => $id]);
|
||||
|
||||
self::updateContact($id, $uid, $ret['url'], $ret);
|
||||
|
||||
// Update the corresponding gcontact entry
|
||||
PortableContact::lastUpdated($ret["url"]);
|
||||
|
|
|
@ -130,18 +130,21 @@ class Photo extends BaseObject
|
|||
*/
|
||||
public static function getPhoto($resourceid, $scale = 0)
|
||||
{
|
||||
$r = self::selectFirst(["uid"], ["resource-id" => $resourceid]);
|
||||
$r = self::selectFirst(["uid", "allow_cid", "allow_gid", "deny_cid", "deny_gid"], ["resource-id" => $resourceid]);
|
||||
if ($r === false) {
|
||||
return false;
|
||||
}
|
||||
$uid = $r["uid"];
|
||||
|
||||
// This is the first place, when retrieving just a photo, that we know who owns the photo.
|
||||
// Make sure that the requester's session is appropriately authenticated to that user
|
||||
// Check if the photo is public (empty allow and deny means public), if so, skip auth attempt, if not
|
||||
// make sure that the requester's session is appropriately authenticated to that user
|
||||
// otherwise permissions checks done by getPermissionsSQLByUserId() won't work correctly
|
||||
$r = DBA::selectFirst("user", ["nickname"], ["uid" => $uid], []);
|
||||
// this will either just return (if auth all ok) or will redirect and exit (starting over)
|
||||
DFRN::autoRedir(self::getApp(), $r["nickname"]);
|
||||
if (!empty($r["allow_cid"]) || !empty($r["allow_gid"]) || !empty($r["deny_cid"]) || !empty($r["deny_gid"])) {
|
||||
$r = DBA::selectFirst("user", ["nickname"], ["uid" => $uid], []);
|
||||
// this will either just return (if auth all ok) or will redirect and exit (starting over)
|
||||
DFRN::autoRedir(self::getApp(), $r["nickname"]);
|
||||
}
|
||||
|
||||
$sql_acl = Security::getPermissionsSQLByUserId($uid);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue