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

Method Update

api/pkg/services/user_service.go:194–220  ·  view source on GitHub ↗

Update an entities.User

(ctx context.Context, source string, authUser entities.AuthContext, params UserUpdateParams)

Source from the content-addressed store, hash-verified

192
193// Update an entities.User
194func (service *UserService) Update(ctx context.Context, source string, authUser entities.AuthContext, params UserUpdateParams) (*entities.User, error) {
195 ctx, span := service.tracer.Start(ctx)
196 defer span.End()
197
198 ctxLogger := service.tracer.CtxLogger(service.logger, span)
199
200 user, isNew, err := service.repository.LoadOrStore(ctx, authUser)
201 if err != nil {
202 msg := fmt.Sprintf("could not get [%T] with from [%+#v]", user, authUser)
203 return nil, service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
204 }
205
206 if isNew {
207 service.dispatchUserCreatedEvent(ctx, source, user)
208 }
209
210 user.Timezone = params.Timezone.String()
211 user.ActivePhoneID = params.ActivePhoneID
212
213 if err = service.repository.Update(ctx, user); err != nil {
214 msg := fmt.Sprintf("cannot save user with id [%s]", user.ID)
215 return nil, service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
216 }
217
218 ctxLogger.Info(fmt.Sprintf("user saved with id [%s] in the userRepository", user.ID))
219 return user, nil
220}
221
222// UserNotificationUpdateParams are parameters for updating the notifications of a user
223type UserNotificationUpdateParams struct {

Callers

nothing calls this directly

Calls 8

StartMethod · 0.65
CtxLoggerMethod · 0.65
LoadOrStoreMethod · 0.65
WrapErrorSpanMethod · 0.65
UpdateMethod · 0.65
InfoMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected