private async Task <bool> CanAddRemoveLikeAsync(Guid entityId, IntranetEntityTypeEnum entityType) { if (entityType.Is(IntranetEntityTypeEnum.Social, IntranetEntityTypeEnum.News, IntranetEntityTypeEnum.Events)) { var member = await _intranetMemberService.GetCurrentMemberAsync(); var activityGroupId = _groupActivityService.GetGroupId(entityId); if (activityGroupId.HasValue) { var group = _groupService.Get(activityGroupId.Value); if (group == null || group.IsHidden) { return(false); } } if (activityGroupId.HasValue && !member.GroupIds.Contains(activityGroupId.Value)) { return(false); } } else if (entityType.Is(IntranetEntityTypeEnum.Comment)) { var comment = await _commentsService.GetAsync(entityId); var activityType = _activityTypeHelper.GetActivityType(comment.ActivityId); return(await CanAddRemoveLikeAsync(comment.ActivityId, (IntranetEntityTypeEnum)activityType)); } return(true); }
private async Task ResolveMentionsAsync(CommentModel comment, IntranetEntityTypeEnum activityType) { var mentionIds = _mentionService.GetMentions(comment.Text).ToList(); var isActivity = activityType.Is(IntranetEntityTypeEnum.Events, IntranetEntityTypeEnum.News, IntranetEntityTypeEnum.Social); if (mentionIds.Any()) { UintraLinkModel url; if (isActivity) { url = await _commentLinkHelper.GetDetailsUrlWithCommentAsync(comment.ActivityId, comment.Id); } else { var content = _nodeModelService.AsEnumerable().FirstOrDefault(x => x.Key == comment.ActivityId); url = _commentLinkHelper.GetDetailsUrlWithComment(content, comment.Id); } _mentionService.ProcessMention(new MentionModel { MentionedSourceId = comment.Id, CreatorId = await _intranetMemberService.GetCurrentMemberIdAsync(), MentionedUserIds = mentionIds, Title = comment.Text.StripMentionHtml().TrimByWordEnd(50), Url = url, ActivityType = CommunicationTypeEnum.CommunicationSettings }); } }