Ejemplo n.º 1
0
        public async Task HandleAsync(RegisterApnsExternalUserDeviceCommand message, CancellationToken cancellationToken)
        {
            string normalizedDeviceToken      = message.DeviceToken.Replace(" ", "");
            ApnsExternalUserDeviceToken token = await repository.FirstOrDefaultAsync <ApnsExternalUserDeviceToken>(
                x => x.DeviceToken == normalizedDeviceToken &&
                x.AppId == message.AppId);

            if (token != null)
            {
                if (token.ExternalUserId == message.UserId)
                {
                    return;
                }

                repository.Remove(token);
            }

            // TODO restrict AppIds (a configurable list?)

            token = new ApnsExternalUserDeviceToken(Guid.NewGuid(), message.UserId,
                                                    normalizedDeviceToken.Replace(" ", ""), message.AppId);
            repository.Add(token);

            Logger.Debug($"Added external APNS external user device token for user ID {message.UserId}");
        }
Ejemplo n.º 2
0
        public async Task HandleAsync(DeregisterApnsExternalUserDeviceCommand message, CancellationToken cancellationToken)
        {
            string normalizedDeviceToken      = message.DeviceToken.Replace(" ", "");
            ApnsExternalUserDeviceToken token = await repository.FirstOrDefaultAsync <ApnsExternalUserDeviceToken>(
                x => x.DeviceToken == normalizedDeviceToken &&
                x.AppId == message.AppId);

            if (token != null)
            {
                repository.Remove(token);
            }
        }