Store a new entities.Discord
(ctx context.Context, params *DiscordStoreParams)
| 115 | |
| 116 | // Store a new entities.Discord |
| 117 | func (service *DiscordService) Store(ctx context.Context, params *DiscordStoreParams) (*entities.Discord, error) { |
| 118 | ctx, span, ctxLogger := service.tracer.StartWithLogger(ctx, service.logger) |
| 119 | defer span.End() |
| 120 | |
| 121 | if err := service.createSlashCommand(ctx, params.ServerID); err != nil { |
| 122 | msg := fmt.Sprintf("cannot create slash command for server [%s]", params.ServerID) |
| 123 | return nil, service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg)) |
| 124 | } |
| 125 | |
| 126 | discordIntegration := &entities.Discord{ |
| 127 | ID: uuid.New(), |
| 128 | UserID: params.UserID, |
| 129 | Name: params.Name, |
| 130 | ServerID: params.ServerID, |
| 131 | IncomingChannelID: params.IncomingChannelID, |
| 132 | CreatedAt: time.Now().UTC(), |
| 133 | UpdatedAt: time.Now().UTC(), |
| 134 | } |
| 135 | |
| 136 | if err := service.repository.Save(ctx, discordIntegration); err != nil { |
| 137 | msg := fmt.Sprintf("cannot save discord integration with id [%s]", discordIntegration.ID) |
| 138 | return nil, service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg)) |
| 139 | } |
| 140 | |
| 141 | ctxLogger.Info(fmt.Sprintf("discord integration saved with id [%s] in the [%T]", discordIntegration.ID, service.repository)) |
| 142 | return discordIntegration, nil |
| 143 | } |
| 144 | |
| 145 | func (service *DiscordService) createSlashCommand(ctx context.Context, serverID string) error { |
| 146 | ctx, span, ctxLogger := service.tracer.StartWithLogger(ctx, service.logger) |
nothing calls this directly
no test coverage detected