public void CheckComment(Comment comment, IEntryLinkFactory entryLinkFactory, IRepositoryContext<User> ctx) {

			var userMatches = Regex.Match(comment.Message, @"@(\w+)");

			if (!userMatches.Success)
				return;

			var userNames = userMatches.Groups.Cast<Group>().Skip(1).Select(g => g.Value).ToArray();

			var users = ctx.Query().Where(u => u.Active && userNames.Contains(u.Name)).ToArray();

			if (!users.Any())
				return;

			var commentMsg = comment.Message.Truncate(200);
			var msg = string.Format("{0} mentioned you in a comment for {1}\n\n{2}", comment.AuthorName, MarkdownHelper.CreateMarkdownLink(entryLinkFactory.GetFullEntryUrl(comment.Entry), comment.Entry.DefaultName), commentMsg);

			foreach (var user in users) {

				var notification = new UserMessage(user, "Mentioned in a comment", msg, false);
				ctx.OfType<UserMessage>().Save(notification);

			}

		}
 public UnifiedCommentContract(Comment comment, ContentLanguagePreference languagePreference)
     : base(comment)
 {
     Entry = new EntryRefWithNameContract(comment.Entry, languagePreference);
     ArtistString = GetArtistString(comment.Entry, languagePreference);
     SongThumbUrl = GetSongThumbUrl(comment.Entry);
 }
Example #3
0
        public CommentContract(Comment comment)
        {
            ParamIs.NotNull(() => comment);

            Author = (comment.Author != null ? new UserBaseContract(comment.Author) : null);
            AuthorName = comment.AuthorName;
            Created = comment.Created;
            Id = comment.Id;
            Message = comment.Message;
        }
		public CommentForApiContract(Comment comment, IUserIconFactory iconFactory) {
			
			ParamIs.NotNull(() => comment);

			Author = comment.Author != null ? new UserWithIconContract(comment.Author, iconFactory) : null;
			AuthorName = comment.AuthorName;
			Created = comment.Created;
			Id = comment.Id;
			Message = comment.Message;

		}