예제 #1
0
        private async Task SendPushNotificationToChannelMembersAsync(string senderId, Guid channelId)
        {
            var includedTags = new List <string>
            {
                PushNotificationsTagTemplates.GetChatChannelTag(channelId.ToString())
            };

            var membersWithDisabledGroupNotifications = await _notificationSettingsService.GetSaasUserIdsWithDisabledGroupNotificationsAsync();

            var membersWithDisabledChannelNotifications = await _channelMemberService.GetSaasUserIdsWithDisabledChannelNotificationsAsync(channelId);

            var excludedTags = membersWithDisabledChannelNotifications.Select(x => PushNotificationsTagTemplates.GetMemberSubscriptionTag(x.ToString())).ToList();

            excludedTags.AddRange(membersWithDisabledGroupNotifications.Select(x => PushNotificationsTagTemplates.GetMemberSubscriptionTag(x.ToString())).ToList());
            // exclude sender
            excludedTags.Add(PushNotificationsTagTemplates.GetMemberSubscriptionTag(senderId));

            await _pushNotificationService.SendForTagAsync(new NewMessagePush { ChannelId = channelId }, includedTags, excludedTags);
        }