Example #1
0
        public async Task<bool> ClearMessages(MessageEntity messageEntity, UserAccountEntity userAccountEntity)
        {
            try
            {
                if (messageEntity.messages == null)
                {
                    return false;
                }
                var user = userAccountEntity.GetUserEntity();
                var messageUids = new List<int>();
                messageUids.AddRange(messageEntity.messages.Where(o => o.seenFlag == false).Select(message => message.messageUid));
                if (messageUids.Count == 0) return false;
                var url = string.Format(EndPoints.ClearMessages, user.Region, messageEntity.messageGroup.messageGroupId, string.Join(",", messageUids));
                var json = new StringContent("{\"seenFlag\":true}", Encoding.UTF8, "application/json");
                var result = await _webManager.PutData(new Uri(url), json, userAccountEntity);
                return result.IsSuccess;
            }
            catch (Exception ex)
            {

                throw new Exception("Failed to clear messages", ex);
            }
        }
Example #2
0
        public async Task<Stream> GetImageMessageContent(string id, MessageEntity.Message message,
            UserAccountEntity userAccountEntity)
        {
            try
            {
                var user = userAccountEntity.GetUserEntity();
                const string content = "image-data-0";
                var url = string.Format(EndPoints.MessageContent, user.Region, id, message.messageUid, content, user.Language);
                url += "&r=" + Guid.NewGuid();
                var theAuthClient = new HttpClient();
                var request = new HttpRequestMessage(HttpMethod.Get, url);
                request.Headers.CacheControl = new CacheControlHeaderValue { NoCache = true };
                request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", userAccountEntity.GetAccessToken());
                var response = await theAuthClient.SendAsync(request);
                var responseContent = await response.Content.ReadAsStreamAsync();
                return responseContent;
            }
            catch (Exception ex)
            {

                throw new Exception("Failed to get image message content", ex);
            }
        }