Exemplo n.º 1
0
    protected async Task <List <string> > findTeamEndpoints(int teamId)
    {
        var endpoints = new List <string>();
        ListEndpointsByPlatformApplicationRequest request = new ListEndpointsByPlatformApplicationRequest()
        {
            PlatformApplicationArn = GlobalConfig.Secrets.platformApplicationArn
        };
        var result = await _client.ListEndpointsByPlatformApplicationAsync(request);

        var devices = findDevicesSubscribed(teamId);

        foreach (Endpoint endpoint in result.Endpoints)
        {
            if (endpoint.Attributes.GetValueOrDefault("Enabled").Equals("true", StringComparison.OrdinalIgnoreCase))
            {
                EndpointUserData userData = readUserData(endpoint.Attributes.GetValueOrDefault("CustomUserData"));
                if (devices.Contains(userData.uniqueUserId))
                {
                    endpoints.Add(endpoint.EndpointArn);
                }
            }
        }
        return(endpoints);
    }