コード例 #1
0
        public override void Execute()
        {
            Logger.Instance.Debug($"handling unlike of comment {reqParams.comment_id}");
            //add like count in comment
            var comment = Comments.GetByCommentId(reqParams.comment_id);

            comment.like_count--;
            Comments.UpdateLikeCount(comment.comment_id, comment.like_count);

            var rowcount = CoreLikes.RemoveCommentLike(reqParams.comment_id, userId);

            if (rowcount > 0)
            {
                Logger.Instance.Debug($"Removed {rowcount} rows of like");
            }
        }
コード例 #2
0
        public override void Execute()
        {
            Logger.Instance.Debug($"handling like of comment {reqParams.comment_id}");
            //add like count in comment
            this.comment = Comments.GetByCommentId(reqParams.comment_id);
            comment.like_count++;
            Comments.UpdateLikeCount(comment.comment_id, comment.like_count);
            CoreLike like = new CoreLike()
            {
                creation_date = DateTime.Now,
                poster_id     = userId,
                poster_type   = "user",
                reaction      = "like",
                resource_id   = comment.comment_id,
                resource_type = "activity_comment"
            };
            var likeId = CoreLikes.Add(like);

            Logger.Instance.Debug($"like id = {likeId}");
            SendNotifications();
        }
コード例 #3
0
ファイル: CommentInfo.cs プロジェクト: sharons74/koobeca
        public CommentInfo(Comment comment, ulong viewerId, bool?isLike = false, List <Comment> children = null, bool isReply = false)
        {
            Logger.Instance.Debug($"building comment info for comment {comment.comment_id}");
            var user = Users.GetById(comment.poster_id);

            action_id            = comment.resource_id;
            comment_id           = comment.comment_id;
            image                = comment.GetParam <string>("image");
            image_normal         = comment.GetParam <string>("image_normal");
            image_profile        = comment.GetParam <string>("image_profile");
            image_icon           = comment.GetParam <string>("image_icon");
            content_url          = comment.GetParam <string>("content_url");
            author_image         = comment.GetParam <string>("author_image");
            author_image_normal  = comment.GetParam <string>("author_image_normal");
            author_image_profile = comment.GetParam <string>("author_image_profile");
            author_image_icon    = comment.GetParam <string>("author_image_icon");
            author_title         = user.displayname;
            comment_body         = Encoding.UTF8.GetString(comment.body);
            user_id              = comment.poster_id;
            userTag              = string.Empty;
            //    //@params;
            comment_date = comment.creation_date.ToString("yyyy-MM-dd HH:mm:ss");
            attachment   = CommentAttachment.Create(comment, action_id);

            attachment_type = comment.attachment_type;
            attachment_id   = (ulong)comment.attachment_id;

            //build gutter menu
            List <CommentMenuItem> menu = new List <CommentMenuItem>();

            if (viewerId == comment.poster_id)
            {
                menu.Add(new CommentMenuItem("comment_delete", comment));
                menu.Add(new CommentMenuItem("comment_edit", comment));
            }
            menu.Add(new CommentMenuItem("comment_copy", comment));
            menu.Add(new CommentMenuItem("comment_cancel", comment));
            gutterMenu = menu.ToArray();

            if (!isReply)
            {
                if (children != null)
                {
                    List <CommentInfo> subCumments = new List <CommentInfo>();
                    children.ForEach(c => subCumments.Add(new CommentInfo(c, viewerId, null, null, true)));
                    reply_on_comment = subCumments.OrderByDescending(c => c.comment_id).ToArray();
                    reply_count      = reply_on_comment.Length;
                }
                reply = new CommentMenuItem("reply", comment);
            }

            this.isReply = isReply?0:1;

            if (!isLike.HasValue)
            {
                //find if user already like this commewnt
                isLike = Likes.GetByResourceAndPoster(comment.comment_id, "activity_comment", (uint)user_id, "user") != null;
            }


            if (isLike == true)
            {
                like = new CommentMenuItem("unlike", comment);
            }
            else
            {
                like = new CommentMenuItem("like", comment);
            }

            like_count = (uint)CoreLikes.CountByResource(comment.comment_id, "activity_comment").Count();
        }