private string GetChannelPostText(Comment comment) { var course = courseManager.GetCourse(comment.CourseId); var slide = course.FindSlideById(comment.SlideId); if (slide == null) return ""; var slideTitle = $"{MakeNestedQuotes(course.Title)}: {MakeNestedQuotes(slide.Title)}"; var url = "https://ulearn.me/Course/" + comment.CourseId + "/" + slide.Url + "#comment-" + comment.Id; var text = $"*{EscapeMarkdown(comment.Author.VisibleName)} â «{EscapeMarkdown(slideTitle)}»*\n{EscapeMarkdown(comment.Text.Trim())}\n\n{EscapeMarkdown(url)}"; return text; }
public async Task PostToChannel(Comment comment) { try { if (string.IsNullOrWhiteSpace(token)) return; var api = new Telegram.Bot.TelegramBotClient(token); var text = GetChannelPostText(comment); await api.SendTextMessageAsync(channel, text, parseMode: ParseMode.Markdown, disableWebPagePreview: true); } catch (Exception e) { log.Error(e); ErrorLog.GetDefault(HttpContext.Current).Log(new Error(e)); } }
public int GetCommentLikesCount(Comment comment) { return db.CommentLikes.Count(x => x.CommentId == comment.Id); }
public IEnumerable<ApplicationUser> GetCommentLikers(Comment comment) { return GetCommentLikes(comment).Select(x => x.User); }
public IEnumerable<CommentLike> GetCommentLikes(Comment comment) { return db.CommentLikes.Where(x => x.CommentId == comment.Id); }
private bool CanEditAndDeleteComment(IPrincipal user, Comment comment) { return user.HasAccessFor(comment.CourseId, CourseRole.Instructor) || user.Identity.GetUserId() == comment.AuthorId; }