chore: fix collection service

This commit is contained in:
Steven
2023-11-11 21:06:52 +08:00
parent 8f982c5695
commit 8f608dc522
5 changed files with 16 additions and 3 deletions

View File

@ -100,7 +100,9 @@ func (s *APIV2Service) UpdateCollection(ctx context.Context, request *apiv2pb.Up
return nil, status.Errorf(codes.PermissionDenied, "Permission denied")
}
update := &store.UpdateCollection{}
update := &store.UpdateCollection{
ID: collection.Id,
}
for _, path := range request.UpdateMask.Paths {
switch path {
case "name":
@ -112,7 +114,7 @@ func (s *APIV2Service) UpdateCollection(ctx context.Context, request *apiv2pb.Up
case "shortcut_ids":
update.ShortcutIDs = request.Collection.ShortcutIds
case "visibility":
visibility := store.Visibility(request.Collection.Visibility)
visibility := store.Visibility(request.Collection.Visibility.String())
update.Visibility = &visibility
}
}

View File

@ -149,7 +149,7 @@ func (s *APIV2Service) UpdateShortcut(ctx context.Context, request *apiv2pb.Upda
case "description":
update.Description = &request.Shortcut.Description
case "visibility":
visibility := store.Visibility(request.Shortcut.Visibility)
visibility := store.Visibility(request.Shortcut.Visibility.String())
update.Visibility = &visibility
case "og_metadata":
if request.Shortcut.OgMetadata != nil {

View File

@ -23,6 +23,7 @@ type APIV2Service struct {
apiv2pb.UnimplementedUserServiceServer
apiv2pb.UnimplementedUserSettingServiceServer
apiv2pb.UnimplementedShortcutServiceServer
apiv2pb.UnimplementedCollectionServiceServer
Secret string
Profile *profile.Profile
@ -54,6 +55,7 @@ func NewAPIV2Service(secret string, profile *profile.Profile, store *store.Store
apiv2pb.RegisterUserServiceServer(grpcServer, apiV2Service)
apiv2pb.RegisterUserSettingServiceServer(grpcServer, apiV2Service)
apiv2pb.RegisterShortcutServiceServer(grpcServer, apiV2Service)
apiv2pb.RegisterCollectionServiceServer(grpcServer, apiV2Service)
reflection.Register(grpcServer)
return apiV2Service
@ -92,6 +94,9 @@ func (s *APIV2Service) RegisterGateway(ctx context.Context, e *echo.Echo) error
if err := apiv2pb.RegisterShortcutServiceHandler(context.Background(), gwMux, conn); err != nil {
return err
}
if err := apiv2pb.RegisterCollectionServiceHandler(context.Background(), gwMux, conn); err != nil {
return err
}
e.Any("/api/v2/*", echo.WrapHandler(gwMux))
// GRPC web proxy.