Пример #1
0
        public void SaveCastNotification(int userId, int postId, NotificationType type)
        {
            string message;
            var    castMessage = _castMessageService.GetMessage(postId);
            var    receiver    = _userService.GetUser(castMessage.UserID.Value);
            var    sender      = _userService.GetUser(userId);

            switch (type)
            {
            case NotificationType.Repost:
                message = $"{sender.FullName} RESPOSTED your Cast";
                break;

            case NotificationType.Replay:
                message = $"{sender.FullName} REPLIED your Cast";
                break;

            case NotificationType.Like:
                message = $"{sender.FullName} LIKED your Cast";
                break;

            case NotificationType.DisLike:
                message = $"{sender.FullName} DISLIKED your Cast";
                break;

            default:
                message = $"Notification From {sender.FullName}";
                break;
            }
            SendNotification(postId, type, userId, receiver.UserId, message, castMessage.Title);
        }
Пример #2
0
        public Reply ReplyPost(ReplyPostModel model)
        {
            if (string.IsNullOrEmpty(model.Base64Content))
            {
                return(new Reply(HttpStatusCode.BadRequest, "Message content is required"));
            }

            try
            {
                _sessionService.Validate(model.UserId, model.SessionToken);
            }
            catch (InvalidSessionException)
            {
                return(new Reply(HttpStatusCode.BadRequest, "Invalid session"));
            }

            _fileService.SaveFile(model.UserId, model.FileName, model.Base64Content);

            var message = _castMessageService.GetMessage(model.CastMessageId);

            var castMessage = _castMessageService.Save(model.FileName, model.UserId, message.Title, model.CastMessageId);
            var repost      = _castMessageService.Repost(model.UserId, castMessage.MessageInfo.Id, model.Comment, model.CastMessageId);

            _notificationService.SaveCastNotification(model.UserId, model.CastMessageId, NotificationType.Replay);
            return(new SendCastMessageReply(HttpStatusCode.OK, model.FileName)
            {
                CastMessageId = castMessage.MessageInfo.Id
            });
        }
Пример #3
0
        public void SendCastPush(int userId, int postId, NotificationType type)
        {
            string message;
            var    castMessage = _castMessageService.GetMessage(postId);
            var    receiver    = _userService.GetUser(castMessage.UserID.Value);
            var    sender      = _userService.GetUser(userId);

            //var message = $"{sender.FullName} Repost your Cast {castMessage.Title}.";
            switch (type)
            {
            case NotificationType.Repost:
                message = $"{sender.FullName} Repost your Cast {castMessage.Title}.";
                break;

            case NotificationType.Replay:
                message = $"{sender.FullName} Replay your Cast {castMessage.Title}.";
                break;

            case NotificationType.Like:
                message = $"{sender.FullName} Like your Cast {castMessage.Title}.";
                break;

            case NotificationType.DisLike:
                message = $"{sender.FullName} Dislike your Cast {castMessage.Title}.";
                break;

            default:
                message = $"{sender.FullName} Push Notification.";
                break;
            }

            PushAndroidNotification(receiver.DeviceId, message, sender.UserName, receiver.UserId, NotificationType.Repost, castMessage.Title);
        }