mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: polish creator definition
This commit is contained in:
@@ -36,7 +36,7 @@ func (s *APIV1Service) GetActivity(ctx context.Context, request *v1pb.GetActivit
|
||||
func (*APIV1Service) convertActivityFromStore(_ context.Context, activity *store.Activity) (*v1pb.Activity, error) {
|
||||
return &v1pb.Activity{
|
||||
Name: fmt.Sprintf("%s%d", ActivityNamePrefix, activity.ID),
|
||||
CreatorId: activity.CreatorID,
|
||||
Creator: fmt.Sprintf("%s%d", UserNamePrefix, activity.CreatorID),
|
||||
Type: activity.Type.String(),
|
||||
Level: activity.Level.String(),
|
||||
CreateTime: timestamppb.New(time.Unix(activity.CreatedTs, 0)),
|
||||
|
@@ -670,7 +670,7 @@ func convertMemoToWebhookPayload(memo *v1pb.Memo) (*v1pb.WebhookRequestPayload,
|
||||
return nil, errors.Wrap(err, "invalid memo creator")
|
||||
}
|
||||
return &v1pb.WebhookRequestPayload{
|
||||
CreatorId: creatorID,
|
||||
Creator: fmt.Sprintf("%s%d", UserNamePrefix, creatorID),
|
||||
CreateTime: timestamppb.New(time.Now()),
|
||||
Memo: memo,
|
||||
}, nil
|
||||
|
@@ -2,6 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
@@ -31,8 +32,13 @@ func (s *APIV1Service) CreateWebhook(ctx context.Context, request *v1pb.CreateWe
|
||||
}
|
||||
|
||||
func (s *APIV1Service) ListWebhooks(ctx context.Context, request *v1pb.ListWebhooksRequest) (*v1pb.ListWebhooksResponse, error) {
|
||||
creatorID, err := ExtractUserIDFromName(request.Creator)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid creator name: %v", err)
|
||||
}
|
||||
|
||||
webhooks, err := s.Store.ListWebhooks(ctx, &store.FindWebhook{
|
||||
CreatorID: &request.CreatorId,
|
||||
CreatorID: &creatorID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to list webhooks, error: %+v", err)
|
||||
@@ -103,7 +109,7 @@ func convertWebhookFromStore(webhook *store.Webhook) *v1pb.Webhook {
|
||||
Id: webhook.ID,
|
||||
CreateTime: timestamppb.New(time.Unix(webhook.CreatedTs, 0)),
|
||||
UpdateTime: timestamppb.New(time.Unix(webhook.UpdatedTs, 0)),
|
||||
CreatorId: webhook.CreatorID,
|
||||
Creator: fmt.Sprintf("%s%d", UserNamePrefix, webhook.CreatorID),
|
||||
Name: webhook.Name,
|
||||
Url: webhook.URL,
|
||||
}
|
||||
|
Reference in New Issue
Block a user