예제 #1
0
        public static Task <bool> AuthenticateAsync(HttpClient httpClient, RocketChatClientAuthentication auth)
        {
            httpClient.BaseAddress = new Uri(auth.BaseUrl.EnsureEndsWith('/'));
            httpClient.DefaultRequestHeaders.Add("X-User-ID", auth.UserId);
            httpClient.DefaultRequestHeaders.Add("X-Auth-Token", auth.AuthToken);

            return(Task.FromResult(true));
        }
예제 #2
0
        public void AddTokenRegistration(RocketChatClientAuthentication auth)
        {
            var key = RocketChatClientAuthentication.CalculateCacheKey(auth.BaseUrl, auth.Username);

            if (!authenticationMap.ContainsKey(key))
            {
                authenticationMap.Add(key, auth);
            }
        }
예제 #3
0
        public async Task SetUserPresenceAsync(RocketChatClientAuthentication auth, string status, string message)
        {
            using (var client = HttpClientFactory.CreateClient("RocketChat"))
            {
                await RocketChatAuthenticationHelper.AuthenticateAsync(client, auth);

                _ = await client.PostAsJsonAsync("api/v1/users.setStatus", new { message = message, status = status });
            }
        }
예제 #4
0
 // TODO: Refactor this out of the authenticator
 public async Task SignOffAsync(RocketChatClientAuthentication auth)
 {
     await SetUserPresenceAsync(auth, "offline", "404 not found");
 }