public async Task <OpenApiResult> GetNotificationAsync( IOpenApiContext context, string notificationId) { // We can guarantee tenant Id is available because it's part of the Uri. ITenant tenant = await this.marainServicesTenancy.GetRequestingTenantAsync(context.CurrentTenantId !).ConfigureAwait(false); IUserNotificationStore userNotificationStore = await this.userNotificationStoreFactory.GetUserNotificationStoreForTenantAsync(tenant).ConfigureAwait(false); UserNotification notifications; try { notifications = await userNotificationStore.GetByIdAsync(notificationId).ConfigureAwait(false); } catch (ArgumentException) { // This will happen if the supplied notification Id is invalid. Return a BadRequest response. throw new OpenApiBadRequestException("The supplied notificationId is not valid"); } HalDocument response = await this.userNotificationMapper.MapAsync(notifications, context).ConfigureAwait(false); return(this.OkResult(response, "application/json")); }
private async Task UpdateNotificationDeliveryStatusAsync(string deliveryChannelId, string notificationId, UserNotificationDeliveryStatus deliveryStatus, ITenant tenant, string?failureMessage = null) { IUserNotificationStore store = await this.notificationStoreFactory.GetUserNotificationStoreForTenantAsync(tenant).ConfigureAwait(false); UserNotification originalNotification = await store.GetByIdAsync(notificationId).ConfigureAwait(false); UserNotification modifiedNotification = originalNotification.WithChannelDeliveryStatus( deliveryChannelId, deliveryStatus, DateTimeOffset.UtcNow, failureMessage); await store.StoreAsync(modifiedNotification).ConfigureAwait(false); }
public async Task ExecuteAsync( [ActivityTrigger] IDurableActivityContext context, ILogger logger) { TenantedFunctionData <BatchReadStatusUpdateRequestItem> request = context.GetInput <TenantedFunctionData <BatchReadStatusUpdateRequestItem> >(); ITenant tenant = await this.tenantProvider.GetTenantAsync(request.TenantId).ConfigureAwait(false); logger.LogInformation( "Executing UpdateNotificationReadStatusActivity for notification with Id {notificationId}", request.Payload.NotificationId); IUserNotificationStore store = await this.notificationStoreFactory.GetUserNotificationStoreForTenantAsync(tenant).ConfigureAwait(false); UserNotification originalNotification = await store.GetByIdAsync(request.Payload.NotificationId).ConfigureAwait(false); UserNotification modifiedNotification = originalNotification.WithChannelReadStatus( request.Payload.DeliveryChannelId, request.Payload.NewStatus, request.Payload.UpdateTimestamp); await store.StoreAsync(modifiedNotification).ConfigureAwait(false); }