<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
class Suggestions extends BaseApi
{
/**
- * @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public static function rawContent(array $parameters = [])
+ protected function rawContent(array $request = [])
{
- self::login(self::SCOPE_READ);
+ self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
- // Maximum number of results to return. Defaults to 40.
- $limit = (int)!isset($_REQUEST['limit']) ? 40 : $_REQUEST['limit'];
+ $request = $this->getRequest([
+ 'limit' => 40, // Maximum number of results to return. Defaults to 40.
+ ], $request);
- $suggestions = Contact\Relation::getSuggestions($uid, 0, $limit);
+ $suggestions = Contact\Relation::getCachedSuggestions($uid, 0, $request['limit']);
$accounts = [];
foreach ($suggestions as $suggestion) {
- $accounts[] = DI::mstdnAccount()->createFromContactId($suggestion['id'], $uid);
+ $accounts[] = [
+ 'source' => 'past_interactions',
+ 'account' => DI::mstdnAccount()->createFromContactId($suggestion['id'], $uid)
+ ];
}
System::jsonExit($accounts);