Skip to content

Commit

Permalink
Return only public user meta in the API
Browse files Browse the repository at this point in the history
remp/web#1167
  • Loading branch information
rootpd committed Nov 9, 2020
1 parent b5a779d commit 71ce0c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ Response:

#### POST `/api/v1/user-meta/list`

Return all the meta information of specified user. You can specify meta information by using the meta information key.
Return all public meta information of specified user. You can specify meta information by using the meta information key.

##### *Headers:*

Expand Down Expand Up @@ -743,14 +743,14 @@ Response:
```json5
[
{
"user_id": 123,
"key" : "foo",
"value" : "bar",
"is_public" : false
"value" : "bar"
},
{
"user_id": 123,
"key" : "fooz",
"value" : "1",
"is_public" : true
"value" : "1"
}
]
```
Expand Down
6 changes: 4 additions & 2 deletions src/api/UserMetaListHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ public function handle(ApiAuthorizationInterface $authorization)

$userMetaRows = [];
foreach ($authorization->getAuthorizedUsers() as $authorizedUser) {
$query = $this->userMetaRepository->userMetaRows($authorizedUser);
$query = $this->userMetaRepository
->userMetaRows($authorizedUser)
->where(['is_public' => true]);

if ($key !== null) {
$query->where('key = ?', $key);
}
Expand All @@ -60,7 +63,6 @@ public function handle(ApiAuthorizationInterface $authorization)
'user_id' => $data->user_id,
'key' => $data->key,
'value' => $data->value,
'is_public' => (bool)$data->is_public,
];
}, array_values($userMetaRows));

Expand Down

0 comments on commit 71ce0c9

Please sign in to comment.