mirror of
https://github.com/usememos/memos.git
synced 2025-10-14 00:07:15 +08:00
chore: fix linter
This commit is contained in:
parent
760c164328
commit
174b1a0361
4 changed files with 19 additions and 20 deletions
|
@ -122,8 +122,6 @@ message GetActivityRequest {
|
|||
// Format: activities/{id}, id is the system generated auto-incremented id.
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {
|
||||
type: "memos.api.v1/Activity"
|
||||
}
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Activity"}
|
||||
];
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ func (ts *TestService) CreateRegularUser(ctx context.Context, username string) (
|
|||
}
|
||||
|
||||
// CreateUserContext creates a context with the given username for authentication.
|
||||
func (ts *TestService) CreateUserContext(ctx context.Context, username string) context.Context {
|
||||
func (*TestService) CreateUserContext(ctx context.Context, username string) context.Context {
|
||||
// Use the real context key from the parent package
|
||||
return apiv1.CreateTestUserContext(ctx, username)
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ import (
|
|||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
// CreateTestUserContext creates a context with username for testing purposes
|
||||
// This function is only intended for use in tests
|
||||
// CreateTestUserContext creates a context with username for testing purposes.
|
||||
// This function is only intended for use in tests.
|
||||
func CreateTestUserContext(ctx context.Context, username string) context.Context {
|
||||
return context.WithValue(ctx, usernameContextKey, username)
|
||||
}
|
||||
|
||||
// CreateTestUserContextWithUser creates a context and ensures the user exists for testing
|
||||
// This function is only intended for use in tests
|
||||
func CreateTestUserContextWithUser(ctx context.Context, s *APIV1Service, user *store.User) context.Context {
|
||||
// CreateTestUserContextWithUser creates a context and ensures the user exists for testing.
|
||||
// This function is only intended for use in tests.
|
||||
func CreateTestUserContextWithUser(ctx context.Context, _ *APIV1Service, user *store.User) context.Context {
|
||||
return context.WithValue(ctx, usernameContextKey, user.Username)
|
||||
}
|
||||
|
|
|
@ -25,19 +25,20 @@ func (s *APIV1Service) CreateWebhook(ctx context.Context, request *v1pb.CreateWe
|
|||
return nil, status.Errorf(codes.Unauthenticated, "user not authenticated")
|
||||
}
|
||||
|
||||
// Only host users can create webhooks
|
||||
if !isSuperUser(currentUser) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
|
||||
// Only host users can create webhooks
|
||||
if !isSuperUser(currentUser) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
// Validate required fields
|
||||
if request.Webhook == nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "webhook is required")
|
||||
}
|
||||
if strings.TrimSpace(request.Webhook.Url) == "" {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "webhook URL is required")
|
||||
}
|
||||
|
||||
// Validate required fields
|
||||
if request.Webhook == nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "webhook is required")
|
||||
}
|
||||
if strings.TrimSpace(request.Webhook.Url) == "" {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "webhook URL is required")
|
||||
} // TODO: Handle webhook_id, validate_only, and request_id fields
|
||||
// TODO: Handle webhook_id, validate_only, and request_id fields
|
||||
if request.ValidateOnly {
|
||||
// Perform validation checks without actually creating the webhook
|
||||
return &v1pb.Webhook{
|
||||
|
|
Loading…
Add table
Reference in a new issue