Cache the profile as well
This commit is contained in:
parent
75534fa3f3
commit
4e3e9dc763
2 changed files with 12 additions and 1 deletions
|
@ -1225,6 +1225,7 @@ class Item
|
||||||
|
|
||||||
if ($posted_item['origin'] && ($posted_item['uid'] != 0) && in_array($posted_item['gravity'], [GRAVITY_PARENT, GRAVITY_COMMENT])) {
|
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']);
|
DI::cache()->delete(ActivityPub\Transmitter::CACHEKEY_OUTBOX . $posted_item['uid']);
|
||||||
|
DI::cache()->delete(ActivityPub\Transmitter::CACHEKEY_PROFILE . $posted_item['uid']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $post_user_id;
|
return $post_user_id;
|
||||||
|
|
|
@ -61,6 +61,7 @@ class Transmitter
|
||||||
const CACHEKEY_FEATURED = 'transmitter:getFeatured:';
|
const CACHEKEY_FEATURED = 'transmitter:getFeatured:';
|
||||||
const CACHEKEY_CONTACTS = 'transmitter:getContacts:';
|
const CACHEKEY_CONTACTS = 'transmitter:getContacts:';
|
||||||
const CACHEKEY_OUTBOX = 'transmitter:getOutbox:';
|
const CACHEKEY_OUTBOX = 'transmitter:getOutbox:';
|
||||||
|
const CACHEKEY_PROFILE = 'transmitter:getProfile:';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add relay servers to the list of inboxes
|
* Add relay servers to the list of inboxes
|
||||||
|
@ -429,12 +430,19 @@ class Transmitter
|
||||||
* Return the ActivityPub profile of the given user
|
* Return the ActivityPub profile of the given user
|
||||||
*
|
*
|
||||||
* @param int $uid User ID
|
* @param int $uid User ID
|
||||||
|
* @param boolean $nocache Wether to bypass caching
|
||||||
* @return array with profile data
|
* @return array with profile data
|
||||||
* @throws HTTPException\NotFoundException
|
* @throws HTTPException\NotFoundException
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function getProfile(int $uid): array
|
public static function getProfile(int $uid, $nocache = false): array
|
||||||
{
|
{
|
||||||
|
$cachekey = self::CACHEKEY_PROFILE . $uid;
|
||||||
|
$result = DI::cache()->get($cachekey);
|
||||||
|
if (!$nocache && !is_null($result)) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
$owner = User::getOwnerDataById($uid);
|
$owner = User::getOwnerDataById($uid);
|
||||||
if (!isset($owner['id'])) {
|
if (!isset($owner['id'])) {
|
||||||
DI::logger()->error('Unable to find owner data for uid', ['uid' => $uid, 'callstack' => System::callstack(20)]);
|
DI::logger()->error('Unable to find owner data for uid', ['uid' => $uid, 'callstack' => System::callstack(20)]);
|
||||||
|
@ -528,6 +536,8 @@ class Transmitter
|
||||||
|
|
||||||
$data['generator'] = self::getService();
|
$data['generator'] = self::getService();
|
||||||
|
|
||||||
|
DI::cache()->set($cachekey, $data, Duration::DAY);
|
||||||
|
|
||||||
// tags: https://kitty.town/@inmysocks/100656097926961126.json
|
// tags: https://kitty.town/@inmysocks/100656097926961126.json
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue