( ctx context.Context, req *userv1.UpdatePromptRequest, )
| 11 | ) |
| 12 | |
| 13 | func (s *UserServer) UpdatePrompt( |
| 14 | ctx context.Context, |
| 15 | req *userv1.UpdatePromptRequest, |
| 16 | ) (*userv1.UpdatePromptResponse, error) { |
| 17 | actor, err := contextutil.GetActor(ctx) |
| 18 | if err != nil { |
| 19 | return nil, err |
| 20 | } |
| 21 | |
| 22 | if req.GetPromptId() == "" { |
| 23 | return nil, shared.ErrBadRequest("prompt_id cannot be empty") |
| 24 | } |
| 25 | if req.GetTitle() == "" { |
| 26 | return nil, shared.ErrBadRequest("title cannot be empty") |
| 27 | } |
| 28 | if req.GetContent() == "" { |
| 29 | return nil, shared.ErrBadRequest("content cannot be empty") |
| 30 | } |
| 31 | |
| 32 | prompt := &models.Prompt{ |
| 33 | Title: req.GetTitle(), |
| 34 | Content: req.GetContent(), |
| 35 | } |
| 36 | |
| 37 | updatedPrompt, err := s.promptService.UpdatePrompt(ctx, actor.ID, req.GetPromptId(), prompt) |
| 38 | if err != nil { |
| 39 | return nil, err |
| 40 | } |
| 41 | |
| 42 | return &userv1.UpdatePromptResponse{ |
| 43 | Prompt: mapper.MapModelPromptToProto(updatedPrompt), |
| 44 | }, nil |
| 45 | } |
nothing calls this directly
no test coverage detected