private async Task <Dictionary <Topic, bool> > GetEmailTopicsAsync( CancellationToken ct) { var result = new Dictionary <Topic, bool>(); var topics = await topicStore.QueryAsync(App.Id, TopicQuery, ct); // Only handled topics where emails are explicitly allowed. var topicsWithEmail = topics.Where(x => x.Channels.GetOrDefault(Providers.Email) == TopicChannel.Allowed); if (!topicsWithEmail.Any()) { return(result); } var subscriptions = await subscriptionStore.QueryAsync(App.Id, new SubscriptionQuery { UserId = UserId }, ct); foreach (var topic in topicsWithEmail) { var subscription = subscriptions.FirstOrDefault(x => x.TopicPrefix == topic.Path); if (subscription?.TopicSettings?.GetOrDefault(Providers.Email)?.Send == ChannelSend.Send) { result[topic] = true; } } return(result); }
public async Task <IActionResult> GetTopics(string?language = null) { var topics = await topicStore.QueryAsync(App.Id, new TopicQuery { Scope = TopicQueryScope.Explicit }, HttpContext.RequestAborted); var response = topics.Select(x => UserTopicDto.FromDomainObject(x, language, App.Language)); return(Ok(response)); }
public async Task <IActionResult> GetTopics(string appId, [FromQuery] TopicQueryDto q) { var topics = await topicStore.QueryAsync(appId, q.ToQuery(true), HttpContext.RequestAborted); var response = new ListResponseDto <TopicDto>(); response.Items.AddRange(topics.Select(TopicDto.FromDomainObject)); response.Total = topics.Total; return(Ok(response)); }