CancelSubscription starts a subscription for an entities.User
(ctx context.Context, params *events.UserSubscriptionCancelledPayload)
| 457 | |
| 458 | // CancelSubscription starts a subscription for an entities.User |
| 459 | func (service *UserService) CancelSubscription(ctx context.Context, params *events.UserSubscriptionCancelledPayload) error { |
| 460 | ctx, span := service.tracer.Start(ctx) |
| 461 | defer span.End() |
| 462 | |
| 463 | user, err := service.repository.Load(ctx, params.UserID) |
| 464 | if err != nil { |
| 465 | msg := fmt.Sprintf("could not get [%T] with with ID [%s]", user, params.UserID) |
| 466 | return service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg)) |
| 467 | } |
| 468 | |
| 469 | user.SubscriptionID = ¶ms.SubscriptionID |
| 470 | user.SubscriptionName = params.SubscriptionName |
| 471 | user.SubscriptionRenewsAt = nil |
| 472 | user.SubscriptionStatus = ¶ms.SubscriptionStatus |
| 473 | user.SubscriptionEndsAt = ¶ms.SubscriptionEndsAt |
| 474 | |
| 475 | if err = service.repository.Update(ctx, user); err != nil { |
| 476 | msg := fmt.Sprintf("could not update [%T] with with ID [%s] after update", user, params.UserID) |
| 477 | return service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg)) |
| 478 | } |
| 479 | |
| 480 | return nil |
| 481 | } |
| 482 | |
| 483 | // ExpireSubscription finishes a subscription for an entities.User |
| 484 | func (service *UserService) ExpireSubscription(ctx context.Context, params *events.UserSubscriptionExpiredPayload) error { |
no test coverage detected