MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / Update

Method Update

api/pkg/services/discord_service.go:199–225  ·  view source on GitHub ↗

Update an entities.Discord

(ctx context.Context, params *DiscordUpdateParams)

Source from the content-addressed store, hash-verified

197
198// Update an entities.Discord
199func (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
228func (service *DiscordService) HandleMessageReceived(ctx context.Context, userID entities.UserID, event cloudevents.Event) error {

Callers

nothing calls this directly

Calls 6

createSlashCommandMethod · 0.95
StartWithLoggerMethod · 0.65
LoadMethod · 0.65
WrapErrorSpanMethod · 0.65
SaveMethod · 0.65
InfoMethod · 0.65

Tested by

no test coverage detected