Example #1
0
        private async Task PushCipherAsync(Cipher cipher, PushType type, IEnumerable <Guid> collectionIds)
        {
            if (cipher.OrganizationId.HasValue)
            {
                var message = new SyncCipherPushNotification
                {
                    Id             = cipher.Id,
                    OrganizationId = cipher.OrganizationId,
                    RevisionDate   = cipher.RevisionDate,
                    CollectionIds  = collectionIds,
                };

                await SendMessageAsync(type, message, true);
            }
            else if (cipher.UserId.HasValue)
            {
                var message = new SyncCipherPushNotification
                {
                    Id           = cipher.Id,
                    UserId       = cipher.UserId,
                    RevisionDate = cipher.RevisionDate,
                };

                await SendMessageAsync(type, message, true);
            }
        }
Example #2
0
        private async Task PushCipherAsync(Cipher cipher, PushType type)
        {
            if (!cipher.UserId.HasValue)
            {
                // No push for org ciphers at the moment.
                return;
            }

            var message = new SyncCipherPushNotification
            {
                Type           = type,
                Id             = cipher.Id,
                UserId         = cipher.UserId,
                OrganizationId = cipher.OrganizationId,
                RevisionDate   = cipher.RevisionDate,
                Aps            = new PushNotification.AppleData {
                    ContentAvailable = 1
                }
            };

            var excludedTokens = new List <string>();

            if (!string.IsNullOrWhiteSpace(_currentContext.DeviceIdentifier))
            {
                excludedTokens.Add(_currentContext.DeviceIdentifier);
            }

            await PushToAllUserDevicesAsync(cipher.UserId.Value, JObject.FromObject(message), excludedTokens);
        }
        private async Task PushCipherAsync(Cipher cipher, PushType type, IEnumerable <Guid> collectionIds)
        {
            if (cipher.OrganizationId.HasValue)
            {
                // We cannot send org pushes since access logic is much more complicated than just the fact that they belong
                // to the organization. Potentially we could blindly send to just users that have the access all permission
                // device registration needs to be more granular to handle that appropriately. A more brute force approach could
                // me to send "full sync" push to all org users, but that has the potential to DDOS the API in bursts.

                // await SendPayloadToOrganizationAsync(cipher.OrganizationId.Value, type, message, true);
            }
            else if (cipher.UserId.HasValue)
            {
                var message = new SyncCipherPushNotification
                {
                    Id             = cipher.Id,
                    UserId         = cipher.UserId,
                    OrganizationId = cipher.OrganizationId,
                    RevisionDate   = cipher.RevisionDate,
                    CollectionIds  = collectionIds,
                };

                await SendPayloadToUserAsync(cipher.UserId.Value, type, message, true);
            }
        }
Example #4
0
        private async Task PushCipherAsync(Cipher cipher, PushType type)
        {
            var message = new SyncCipherPushNotification
            {
                Type = type,
                Id = cipher.Id,
                UserId = cipher.UserId,
                RevisionDate = cipher.RevisionDate,
                Aps = new PushNotification.AppleData { ContentAvailable = 1 }
            };

            var excludedTokens = new List<string>();
            if(!string.IsNullOrWhiteSpace(_currentContext.DeviceIdentifier))
            {
                excludedTokens.Add(_currentContext.DeviceIdentifier);
            }

            await PushToAllUserDevicesAsync(cipher.UserId, JObject.FromObject(message), excludedTokens);
        }