/// <summary> /// Called when a reaction has been uploaded. This will /// post the reaction and notify the vlog owner. /// </summary> /// <remarks> /// <para> /// The reaction will belong to the current user. /// </para> /// <para> /// If the video file or thumbnail file does not /// exist in our blob storage this throws a /// <see cref="FileNotFoundException"/>. /// </para> /// </remarks> /// <param name="context">Context for posting a reaction.</param> public async Task PostAsync(PostReactionContext context) { if (context is null) { throw new ArgumentNullException(nameof(context)); } if (!await _blobStorageService.FileExistsAsync(StorageConstants.ReactionStorageFolderName, context.ReactionId.ToString())) { throw new FileNotFoundException(); } var reaction = new Reaction { Id = context.ReactionId, TargetVlogId = context.TargetVlogId, UserId = context.UserId, }; await _reactionRepository.CreateAsync(reaction); var targetVlog = await _vlogRepository.GetAsync(context.TargetVlogId); await _notificationService.NotifyReactionPlacedAsync(targetVlog.UserId, context.TargetVlogId, context.ReactionId); }
public IActionResult PostReaction([FromServices] DispatchManager dispatchManager, [FromServices] Core.AppContext appContext, [FromBody] ReactionDto input) { // Act. var postReactionContext = new PostReactionContext { IsPrivate = input.IsPrivate, ReactionId = input.Id, TargetVlogId = input.TargetVlogId, UserId = appContext.UserId, }; dispatchManager.Dispatch <PostReactionBackgroundTask>(postReactionContext); // Return. return(NoContent()); }