Exemple #1
0
        public async Task <ActionResult> PutAnnouncementAsync([FromBody] AnnouncementRecord record)
        {
            if (record == null)
            {
                return(BadRequest("Error parsing Record"));
            }
            if (record.Id == Guid.Empty)
            {
                return(BadRequest("Error parsing Record.Id"));
            }

            var existingRecord = await _announcementService.FindOneAsync(record.Id);

            if (existingRecord == null)
            {
                return(NotFound($"No record found with it {record.Id}"));
            }

            record.Touch();

            await _announcementService.ReplaceOneAsync(record);

            await _eventMediator.PushSyncRequestAsync();

            return(NoContent());
        }
Exemple #2
0
 public Task PushAnnouncementNotificationAsync(AnnouncementRecord announcement)
 {
     return(Task.WhenAll(
                SendPushNotificationAsync(new
     {
         data = new
         {
             Event = "Announcement",
             Title = announcement.Title.RemoveMarkdown(),
             Text = announcement.Content.RemoveMarkdown(),
             RelatedId = announcement.Id
         },
         to = $"/topics/{_configuration.TargetTopicAndroid}"
     }),
                SendPushNotificationAsync(new
     {
         data = new
         {
             @event = "announcement",
             announcement_id = announcement.Id,
         },
         notification = new {
             title = announcement.Title.RemoveMarkdown(),
             body = announcement.Content.RemoveMarkdown(),
             sound = "notification_default.caf"
         },
         content_available = true,
         priority = "high",
         to = $"/topics/{_configuration.TargetTopicIos}"
     })
                ));
 }
Exemple #3
0
        public async Task PushAnnouncementNotificationAsync(AnnouncementRecord announcement)
        {
            await _wnsChannelManager.PushAnnouncementNotificationAsync(announcement);

            if (announcement.ValidFromDateTimeUtc <= DateTime.UtcNow)
            {
                await _firebaseChannelManager.PushAnnouncementNotificationAsync(announcement);
            }
        }
        public async Task PushAnnouncementNotificationAsync(AnnouncementRecord announcement)
        {
            var message = new
            {
                Event   = "NewAnnouncement",
                Content = announcement
            };

            var recipients = await GetAllRecipientsAsyncByTopic(_configuration.TargetTopic);

            await SendRawAsync(recipients, JsonConvert.SerializeObject(message));
        }
Exemple #5
0
        public async Task <ActionResult> PostAnnouncementAsync([FromBody] AnnouncementRecord record)
        {
            record.Touch();
            record.NewId();

            await _announcementService.InsertOneAsync(record);

            await _eventMediator.PushSyncRequestAsync();

            await _eventMediator.PushAnnouncementNotificationAsync(record);

            return(Ok());
        }