mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: exclude comments in memo list response
This commit is contained in:
@@ -60,7 +60,6 @@ type Memo struct {
|
||||
Pinned bool `json:"pinned"`
|
||||
|
||||
// Related fields
|
||||
Parent *Memo `json:"parent"`
|
||||
CreatorName string `json:"creatorName"`
|
||||
CreatorUsername string `json:"creatorUsername"`
|
||||
ResourceList []*Resource `json:"resourceList"`
|
||||
@@ -184,11 +183,6 @@ func (s *APIV1Service) GetMemoList(c echo.Context) error {
|
||||
if rowStatus != "" {
|
||||
find.RowStatus = &rowStatus
|
||||
}
|
||||
pinnedStr := c.QueryParam("pinned")
|
||||
if pinnedStr != "" {
|
||||
pinned := pinnedStr == "true"
|
||||
find.Pinned = &pinned
|
||||
}
|
||||
|
||||
contentSearch := []string{}
|
||||
tag := c.QueryParam("tag")
|
||||
@@ -867,24 +861,6 @@ func (s *APIV1Service) convertMemoFromStore(ctx context.Context, memo *store.Mem
|
||||
relationList = append(relationList, convertMemoRelationFromStore(relation))
|
||||
}
|
||||
memoMessage.RelationList = relationList
|
||||
for _, relation := range memoMessage.RelationList {
|
||||
if relation.MemoID == memoMessage.ID && relation.Type == MemoRelationComment {
|
||||
parentMemo, err := s.Store.GetMemo(ctx, &store.FindMemo{
|
||||
ID: &relation.RelatedMemoID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if parentMemo != nil {
|
||||
parent, err := s.convertMemoFromStore(ctx, parentMemo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
memoMessage.Parent = parent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return memoMessage, nil
|
||||
}
|
||||
|
||||
|
@@ -80,7 +80,10 @@ func (s *APIV2Service) CreateMemo(ctx context.Context, request *apiv2pb.CreateMe
|
||||
}
|
||||
|
||||
func (s *APIV2Service) ListMemos(ctx context.Context, request *apiv2pb.ListMemosRequest) (*apiv2pb.ListMemosResponse, error) {
|
||||
memoFind := &store.FindMemo{}
|
||||
memoFind := &store.FindMemo{
|
||||
// Exclude comments by default.
|
||||
ExcludeComments: true,
|
||||
}
|
||||
if request.Filter != "" {
|
||||
filter, err := parseListMemosFilter(request.Filter)
|
||||
if err != nil {
|
||||
@@ -411,10 +414,13 @@ func (s *APIV2Service) GetUserMemosStats(ctx context.Context, request *apiv2pb.G
|
||||
if user == nil {
|
||||
return nil, status.Errorf(codes.NotFound, "user not found")
|
||||
}
|
||||
|
||||
normalRowStatus := store.Normal
|
||||
memos, err := s.Store.ListMemos(ctx, &store.FindMemo{
|
||||
CreatorID: &user.ID,
|
||||
RowStatus: &normalRowStatus,
|
||||
CreatorID: &user.ID,
|
||||
RowStatus: &normalRowStatus,
|
||||
ExcludeComments: true,
|
||||
ExcludeContent: true,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to list memos")
|
||||
@@ -468,6 +474,7 @@ func (s *APIV2Service) convertMemoFromStore(ctx context.Context, memo *store.Mem
|
||||
Nodes: convertFromASTNodes(rawNodes),
|
||||
Visibility: convertVisibilityFromStore(memo.Visibility),
|
||||
Pinned: memo.Pinned,
|
||||
ParentId: memo.ParentID,
|
||||
Relations: listMemoRelationsResponse.Relations,
|
||||
Resources: listMemoResourcesResponse.Resources,
|
||||
}, nil
|
||||
|
Reference in New Issue
Block a user