Update an entities.Discord
(ctx context.Context, params *DiscordUpdateParams)
| 197 | |
| 198 | // Update an entities.Discord |
| 199 | func (service *DiscordService) Update(ctx context.Context, params *DiscordUpdateParams) (*entities.Discord, error) { |
| 200 | ctx, span, ctxLogger := service.tracer.StartWithLogger(ctx, service.logger) |
| 201 | defer span.End() |
| 202 | |
| 203 | discordIntegration, err := service.repository.Load(ctx, params.UserID, params.DiscordID) |
| 204 | if err != nil { |
| 205 | msg := fmt.Sprintf("cannot load discord integration with userID [%s] and discordID [%s]", params.UserID, params.DiscordID) |
| 206 | return nil, service.tracer.WrapErrorSpan(span, stacktrace.PropagateWithCode(err, stacktrace.GetCode(err), msg)) |
| 207 | } |
| 208 | |
| 209 | if err = service.createSlashCommand(ctx, params.ServerID); err != nil { |
| 210 | msg := fmt.Sprintf("cannot create slash command for server [%s]", params.ServerID) |
| 211 | return nil, service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg)) |
| 212 | } |
| 213 | |
| 214 | discordIntegration.Name = params.Name |
| 215 | discordIntegration.ServerID = params.ServerID |
| 216 | discordIntegration.IncomingChannelID = params.IncomingChannelID |
| 217 | |
| 218 | if err = service.repository.Save(ctx, discordIntegration); err != nil { |
| 219 | msg := fmt.Sprintf("cannot save discord integration with id [%s] after update", discordIntegration.ID) |
| 220 | return nil, service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg)) |
| 221 | } |
| 222 | |
| 223 | ctxLogger.Info(fmt.Sprintf("discord integration updated with id [%s] in the [%T]", discordIntegration.ID, service.repository)) |
| 224 | return discordIntegration, nil |
| 225 | } |
| 226 | |
| 227 | // HandleMessageReceived sends an incoming SMS to a discord channel |
| 228 | func (service *DiscordService) HandleMessageReceived(ctx context.Context, userID entities.UserID, event cloudevents.Event) error { |
nothing calls this directly
no test coverage detected