Example #1
0
        public async Task <FollowUserResponse> Handle(FollowUserRequest request, CancellationToken cancellationToken)
        {
            var(isFollowed, follow) = await userService.FollowUser(request.UserId);

            if (isFollowed)
            {
                var notification = await notifier.Push(NotificationMessages.UserFollowMessage(follow.Follower.UserName), request.UserId);

                await hubManager.Invoke(SignalrActions.NOTIFICATION_RECEIVED, request.UserId, mapper.Map <NotificationDto>(notification));
            }

            return(new FollowUserResponse {
                IsFollowed = isFollowed, Follow = mapper.Map <UserFollowDto>(follow)
            });
        }