Return UserRelation instead of UserCompact for friends API#7768
Return UserRelation instead of UserCompact for friends API#7768cl8n wants to merge 3 commits intoppy:masterfrom
Conversation
|
It looks like this will need to be coordinated with lazer. |
|
yep. I'll wait for review on this first to get the API decided I also removed the |
|
Fine to go ahead with this at your discretion (assuming this seems like a sane change - I think it does but haven't looked into it with too much thought). Will coordinate the lazer side changes if/when this is merged. |
| if (is_api_request()) { | ||
| return $usersJson; | ||
| } | ||
|
|
There was a problem hiding this comment.
About statistics; identify scope is always implied. If anything, the check should be at default_mode function instead.
| 'target', | ||
| 'target.country', | ||
| 'target.cover', | ||
| 'target.groups', | ||
| 'target.support_level', |
There was a problem hiding this comment.
static $userIncludes = [ ... ];
if (is_api_request()) {
return json_collection(..., ..., [
"target:mode({$currentMode})",
...array_map(..., $userIncludes),
]);
}| ->relations() | ||
| ->friends() | ||
| ->withMutual() |
There was a problem hiding this comment.
Make its own relation and load that instead.
// in User model
public function relationFriends()
{
return $this->relations()->friends()->withMutual();
}
// in this controller action
// the loaded reloaded data will be used regardless (in json for api, in current user default json for html)
$relations = $currentUser->relationFriends;
$relations->load(['target' => fn ($q) => $q->...]);
if (is_api...) {
...
}
$user = $relations->pluck('target');
// in Transformers etc
$user->relationFriends|
@cl8n still willing to apply the review to this one? |
|
The main thing has been merged through a different PR. Feel free to open another PR for the documentation (or maybe wait for the documentation system update PR (#11433) first?). |
resolves #7637