Esempio n. 1
0
        public Reply Send(CastMessageToUpload message)
        {
            if (string.IsNullOrEmpty(message.Base64Content))
            {
                return(new Reply(HttpStatusCode.BadRequest, "Message content is required"));
            }

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

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

            var castMessage = _castMessageService.Save(message.FileName, message.UserId, message.Title);

            _pushNotificationService.SendCastPush(message.UserId, castMessage);

            return(new SendCastMessageReply(HttpStatusCode.OK, message.FileName)
            {
                CastMessageId = castMessage.MessageInfo.Id
            });
        }