-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return UserRelation instead of UserCompact for friends API #7768
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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