public static function remove($id)
{
// We want just to make sure that we don't delete our "self" contact
- $contact = DBA::selectFirst('contact', ['uri-id', 'photo', 'thumb', 'micro'], ['id' => $id, 'self' => false]);
+ $contact = DBA::selectFirst('contact', ['uri-id', 'photo', 'thumb', 'micro', 'uid'], ['id' => $id, 'self' => false]);
if (!DBA::isResult($contact)) {
return;
}
+ self::clearFollowerFollowingEndpointCache($contact['uid']);
+
// Archive the contact
self::update(['archive' => true, 'network' => Protocol::PHANTOM, 'deleted' => true], ['id' => $id]);
self::remove($contact['id']);
}
+ private static function clearFollowerFollowingEndpointCache(int $uid)
+ {
+ if (empty($uid)) {
+ return;
+ }
+
+ DI::cache()->delete(ActivityPub\Transmitter::CACHEKEY_CONTACTS . 'followers:' . $uid);
+ DI::cache()->delete(ActivityPub\Transmitter::CACHEKEY_CONTACTS . 'following:' . $uid);
+ }
/**
* Marks a contact for archival after a communication issue delay
break;
default:
/**
- * Use a random picture.
+ * Use a random picture.
* The service provides random pictures from Unsplash.
* @license https://unsplash.com/license
*/
Worker::add(PRIORITY_LOW, 'FetchFeaturedPosts', $ret['url']);
}
}
-
+
$ret['last-item'] = Probe::getLastUpdate($ret);
Logger::info('Fetched last item', ['id' => $id, 'probed_url' => $ret['url'], 'last-item' => $ret['last-item'], 'callstack' => System::callstack(20)]);
}
$contact = DBA::selectFirst('contact', [], ['id' => $cid]);
}
+ self::clearFollowerFollowingEndpointCache($importer['uid']);
+
if (!empty($contact)) {
if (!empty($contact['pending'])) {
Logger::info('Pending contact request already exists.', ['url' => $url, 'uid' => $importer['uid']]);
return;
}
+ self::clearFollowerFollowingEndpointCache($contact['uid']);
+
$cdata = self::getPublicAndUserContactID($contact['id'], $contact['uid']);
DI::notification()->deleteForUserByVerb($contact['uid'], Activity::FOLLOW, ['actor-id' => $cdata['public']]);
*/
public static function removeSharer(array $contact)
{
+ self::clearFollowerFollowingEndpointCache($contact['uid']);
+
if ($contact['rel'] == self::SHARING || in_array($contact['network'], [Protocol::FEED, Protocol::MAIL])) {
self::remove($contact['id']);
} else {
self::updateDisplayCache($posted_item['uri-id']);
}
+ if ($posted_item['origin'] && ($posted_item['uid'] != 0) && in_array($posted_item['gravity'], [GRAVITY_PARENT, GRAVITY_COMMENT])) {
+ DI::cache()->delete(ActivityPub\Transmitter::CACHEKEY_OUTBOX . $posted_item['uid']);
+ }
+
return $post_user_id;
}
use Friendica\Database\DBA;
use BadMethodCallException;
use Friendica\Database\Database;
+use Friendica\DI;
+use Friendica\Protocol\ActivityPub;
class Collection
{
*
* @param integer $uri_id
* @param integer $type
+ * @param integer $cache_uid If set to a non zero value, the featured cache is cleared
*/
- public static function add(int $uri_id, int $type)
+ public static function add(int $uri_id, int $type, int $cache_uid = 0)
{
if (empty($uri_id)) {
throw new BadMethodCallException('Empty URI_id');
}
DBA::insert('post-collection', ['uri-id' => $uri_id, 'type' => $type], Database::INSERT_IGNORE);
+
+ if (!empty($cache_uid) && ($type == self::FEATURED)) {
+ DI::cache()->delete(ActivityPub\Transmitter::CACHEKEY_FEATURED . $cache_uid);
+ }
}
/**
*
* @param integer $uri_id
* @param integer $type
+ * @param integer $cache_uid If set to a non zero value, the featured cache is cleared
*/
- public static function remove(int $uri_id, int $type)
+ public static function remove(int $uri_id, int $type, int $cache_uid = 0)
{
if (empty($uri_id)) {
throw new BadMethodCallException('Empty URI_id');
}
DBA::delete('post-collection', ['uri-id' => $uri_id, 'type' => $type]);
+
+ if (!empty($cache_uid) && ($type == self::FEATURED)) {
+ DI::cache()->delete(ActivityPub\Transmitter::CACHEKEY_FEATURED . $cache_uid);
+ }
}
/**
DI::mstdnError()->RecordNotFound();
}
- Post\Collection::add($this->parameters['id'], Post\Collection::FEATURED);
+ Post\Collection::add($this->parameters['id'], Post\Collection::FEATURED, $uid);
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
DI::mstdnError()->RecordNotFound();
}
- Post\Collection::remove($this->parameters['id'], Post\Collection::FEATURED);
+ Post\Collection::remove($this->parameters['id'], Post\Collection::FEATURED, $uid);
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
$pinned = !$item['featured'];
if ($pinned) {
- Post\Collection::add($item['uri-id'], Post\Collection::FEATURED);
+ Post\Collection::add($item['uri-id'], Post\Collection::FEATURED, local_user());
} else {
- Post\Collection::remove($item['uri-id'], Post\Collection::FEATURED);
+ Post\Collection::remove($item['uri-id'], Post\Collection::FEATURED, local_user());
}
// See if we've been passed a return path to redirect to
if (!$show_contacts) {
if (!empty($cachekey)) {
- DI::cache()->set($cachekey, $data, Duration::QUARTER_HOUR);
+ DI::cache()->set($cachekey, $data, Duration::DAY);
}
return $data;
}
if (!empty($cachekey)) {
- DI::cache()->set($cachekey, $data, Duration::QUARTER_HOUR);
+ DI::cache()->set($cachekey, $data, Duration::DAY);
}
return $data;
}
if (!empty($cachekey)) {
- DI::cache()->set($cachekey, $data, Duration::QUARTER_HOUR);
+ DI::cache()->set($cachekey, $data, Duration::DAY);
}
return $data;
$data['orderedItems'] = $list;
if (!empty($cachekey)) {
- DI::cache()->set($cachekey, $data, Duration::QUARTER_HOUR);
+ DI::cache()->set($cachekey, $data, Duration::DAY);
}
return $data;