Пример #1
0
        /// <inheritdoc/>
        public async Task <string> UpdateSelectAnswerMessageAsync(Course course, QBot.Domain.Models.Channel channel, Question question, Answer answer)
        {
            if (string.IsNullOrEmpty(question?.InitialResponseMessageId))
            {
                this.logger.LogWarning("UpdateSelectAnswerMessageAsync:: Skip update select answer as 'InitialResponseMessageId' is not set.");
                return(string.Empty);
            }

            var conversationId  = this.GetConversationId(answer.ChannelId, question.MessageId);
            var deepLink        = this.deepLinkCreator.GetTeamsMessageDeepLink(course.TeamId, channel.Id, question.MessageId, answer.MessageId);
            var attachment      = this.messageFactory.CreateQuestionAnsweredMessage(deepLink);
            var messageActivity = MessageFactory.Attachment(attachment);

            messageActivity.Id      = question.InitialResponseMessageId;
            messageActivity.Summary = this.localizer.GetString("questionIsAnsweredMessage");
            return(await this.PostMessageAsync(conversationId, messageActivity));
        }
Пример #2
0
        /// <inheritdoc/>
        public async Task NotifyAnsweredAcceptedAsync(Course course, QBot.Domain.Models.Channel channel, Question question, Answer answer)
        {
            var topic = new TeamworkActivityTopic
            {
                Source = TeamworkActivityTopicSource.Text,
                Value  = $"{course.Name} > {channel.Name}",
                WebUrl = this.deepLinkCreator.GetTeamsMessageDeepLink(course.TeamId, channel.Id, question.MessageId, answer.MessageId),
            };

            var previewText = new ItemBody
            {
                Content = answer.GetSanitizedMessage(),
            };

            var recipient = new AadUserNotificationRecipient
            {
                UserId = answer.AuthorId,
            };

            await this.SendActivityFeedNotificationAsync(course.TeamAadObjectId, topic, AnswerAcceptedActivityType, previewText, recipient);
        }