public async Task <CreatePostResponse> Handle(CreatePostRequest request, CancellationToken cancellationToken) { var createdPost = await postService.CreatePost(mapper.Map <Domain.Entities.Post.Post>(request), photo : request.Photo) ?? throw new CrudException("Post has not been created"); if (createdPost.Group != null && httpContextReader.CurrentUserId != createdPost.AuthorId) { var allMembersIds = createdPost.Group.GroupMembers .Where(m => m.IsAccepted && m.UserId != createdPost.AuthorId).Select(m => m.UserId); await notifier.Push( NotificationMessages.NewGroupPostNotification(createdPost.Author.Username, createdPost.Group.Name), createdPost.Group.AdminId, NotificationType.NewGroupPost); foreach (var memberId in allMembersIds) { await notifier.Push( NotificationMessages.NewGroupPostNotification(createdPost.Author.Username, createdPost.Group.Name), memberId, NotificationType.NewGroupPost); } } return(new CreatePostResponse { Post = mapper.Map <PostDto>(createdPost) }); }