Unverified Commit 79bbe4b8 authored by Athurg Gooth's avatar Athurg Gooth Committed by GitHub

feat: support filter creator in /api/v2/memos (#2432)

* Add creator_id param in /api/v2/memos

* make creator_id optional
parent 035d71e0
......@@ -73,6 +73,22 @@ func (s *MemoService) ListMemos(ctx context.Context, request *apiv2pb.ListMemosR
if user == nil {
memoFind.VisibilityList = []store.Visibility{store.Public}
}
if request.CreatorId != nil {
memoFind.CreatorID = request.CreatorId
}
// Remove the private memos from the list if the user is not the creator.
if user != nil && request.CreatorId != nil && *request.CreatorId != user.ID {
var filteredVisibility []store.Visibility
for _, v := range memoFind.VisibilityList {
if v != store.Private {
filteredVisibility = append(filteredVisibility, v)
}
}
memoFind.VisibilityList = filteredVisibility
}
if request.PageSize != 0 {
offset := int(request.Page * request.PageSize)
limit := int(request.PageSize)
......
......@@ -78,6 +78,8 @@ message ListMemosRequest {
// Filter is used to filter memos returned in the list.
string filter = 3;
optional int32 creator_id = 4;
}
message ListMemosResponse {
......
......@@ -249,6 +249,7 @@
| page | [int32](#int32) | | |
| page_size | [int32](#int32) | | |
| filter | [string](#string) | | Filter is used to filter memos returned in the list. |
| creator_id | [int32](#int32) | optional | |
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment