From 49a27dbeb3bf6afab7ce8ffe504ae93de281574d Mon Sep 17 00:00:00 2001 From: Lexi Date: Mon, 4 Sep 2023 13:15:28 -0400 Subject: [PATCH] feat: use markdown for URLs in Discord publications (#1684) --- .../Distributors/DiscordDistributor.cs | 13 +++++++-- .../ExternalMediaPublisher.cs | 28 +++++++++++++------ .../Services/ExternalMediaPublisher/Post.cs | 7 +++++ .../Pages/Account/ConfirmEmail.cshtml.cs | 1 + TASVideos/Pages/Account/Register.cshtml.cs | 1 + TASVideos/Pages/Forum/Posts/Create.cshtml.cs | 2 ++ TASVideos/Pages/Forum/Posts/Edit.cshtml.cs | 3 ++ TASVideos/Pages/Forum/Topics/Create.cshtml.cs | 1 + TASVideos/Pages/Forum/Topics/Index.cshtml.cs | 1 + TASVideos/Pages/Forum/Topics/Merge.cshtml.cs | 1 + TASVideos/Pages/Forum/Topics/Move.cshtml.cs | 1 + TASVideos/Pages/Forum/Topics/Split.cshtml.cs | 1 + TASVideos/Pages/Games/Edit.cshtml.cs | 18 ++++++++++-- TASVideos/Pages/Games/Rewire.cshtml.cs | 6 +++- .../Publications/AdditionalMovies.cshtml.cs | 2 ++ .../Pages/Publications/Catalog.cshtml.cs | 1 + TASVideos/Pages/Publications/Edit.cshtml.cs | 1 + .../Pages/Publications/EditClass.cshtml.cs | 1 + .../Pages/Publications/EditFiles.cshtml.cs | 2 ++ .../Pages/Publications/EditUrls.cshtml.cs | 2 ++ .../Pages/Publications/PrimaryMovie.cshtml.cs | 1 + TASVideos/Pages/Roles/AddEdit.cshtml.cs | 5 +++- TASVideos/Pages/Submissions/Catalog.cshtml.cs | 1 + .../DeprecateMovieFormats.cshtml.cs | 1 + TASVideos/Pages/Submissions/Edit.cshtml.cs | 5 ++++ TASVideos/Pages/UserFiles/Index.cshtml.cs | 3 ++ TASVideos/Pages/UserFiles/Upload.cshtml.cs | 1 + TASVideos/Pages/Users/Edit.cshtml.cs | 2 ++ TASVideos/Pages/Users/EditEmail.cshtml.cs | 6 +++- TASVideos/Pages/Wiki/DeletedPages.cshtml.cs | 3 ++ TASVideos/Pages/Wiki/Edit.cshtml.cs | 1 + TASVideos/Pages/Wiki/Move.cshtml.cs | 1 + 32 files changed, 107 insertions(+), 16 deletions(-) diff --git a/TASVideos.Core/Services/ExternalMediaPublisher/Distributors/DiscordDistributor.cs b/TASVideos.Core/Services/ExternalMediaPublisher/Distributors/DiscordDistributor.cs index 8f0b3155f..090ae6985 100644 --- a/TASVideos.Core/Services/ExternalMediaPublisher/Distributors/DiscordDistributor.cs +++ b/TASVideos.Core/Services/ExternalMediaPublisher/Distributors/DiscordDistributor.cs @@ -81,8 +81,17 @@ private class DiscordMessage public DiscordMessage(IPostable post) { var body = string.IsNullOrWhiteSpace(post.Body) ? "" : $" ({post.Body})"; - var link = string.IsNullOrWhiteSpace(post.Link) ? "" : post.Type == PostType.Announcement ? $" {post.Link}" : $" <{post.Link}>"; - Content = $"{post.Title}{body}{link}"; + if (string.IsNullOrWhiteSpace(post.Link)) + { + Content = $"{post.Title}{body}"; + } + else + { + var link = post.Type == PostType.Announcement ? post.Link : $"<{post.Link}>"; + Content = string.IsNullOrWhiteSpace(post.FormattedTitle) + ? $"{post.Title}{body} {link}" + : $"{string.Format(post.FormattedTitle, link)}{body}"; + } } [JsonPropertyName("content")] diff --git a/TASVideos.Core/Services/ExternalMediaPublisher/ExternalMediaPublisher.cs b/TASVideos.Core/Services/ExternalMediaPublisher/ExternalMediaPublisher.cs index 8b7b51602..67d0f2db2 100644 --- a/TASVideos.Core/Services/ExternalMediaPublisher/ExternalMediaPublisher.cs +++ b/TASVideos.Core/Services/ExternalMediaPublisher/ExternalMediaPublisher.cs @@ -41,7 +41,7 @@ public string ToAbsolute(string relativeLink) public static class ExternalMediaPublisherExtensions { - public static async Task SendUserFile(this ExternalMediaPublisher publisher, bool unlisted, string title, string relativeLink, string body) + public static async Task SendUserFile(this ExternalMediaPublisher publisher, bool unlisted, string title, string formattedTitle, string relativeLink, string body) { await publisher.Send(new Post { @@ -51,6 +51,7 @@ await publisher.Send(new Post : PostType.General, Group = PostGroups.UserFiles, Title = title, + FormattedTitle = formattedTitle, Body = body, Link = publisher.ToAbsolute(relativeLink) }); @@ -64,12 +65,13 @@ await publisher.Send(new Post Type = PostType.Announcement, Group = PostGroups.Submission, Title = $"New Submission! Go and see {title}", + FormattedTitle = $"New Submission! Go and see [{title}]({{0}})", Body = "", Link = publisher.ToAbsolute(relativeLink) }); } - public static async Task SendSubmissionEdit(this ExternalMediaPublisher publisher, string title, string body, string relativeLink) + public static async Task SendSubmissionEdit(this ExternalMediaPublisher publisher, string title, string formattedTitle, string body, string relativeLink) { await publisher.Send(new Post { @@ -77,6 +79,7 @@ await publisher.Send(new Post Type = PostType.General, Group = PostGroups.Submission, Title = title, + FormattedTitle = formattedTitle, Body = body, Link = publisher.ToAbsolute(relativeLink) }); @@ -90,6 +93,7 @@ await publisher.Send(new Post Type = PostType.Announcement, Group = PostGroups.Submission, Title = $"New movie published! Go and see {title}", + FormattedTitle = $"New movie published! Go and see [{title}]({{0}})", Body = "", Link = publisher.ToAbsolute(relativeLink) }); @@ -103,6 +107,7 @@ await publisher.Send(new Post Type = PostType.Announcement, Group = PostGroups.Publication, Title = "Publication Removed", + FormattedTitle = "[Publication]({0}) Removed", Body = reason, Link = publisher.ToAbsolute($"{id}M") }); @@ -116,11 +121,12 @@ await publisher.Send(new Post Type = PostType.Announcement, Group = PostGroups.Submission, Title = "Submission Removed", + FormattedTitle = "[Submission]({0}) Removed", Link = publisher.ToAbsolute($"{id}S") }); } - public static async Task SendPublicationEdit(this ExternalMediaPublisher publisher, string title, string body, string relativeLink) + public static async Task SendPublicationEdit(this ExternalMediaPublisher publisher, string title, string formattedTitle, string body, string relativeLink) { await publisher.Send(new Post { @@ -128,12 +134,13 @@ await publisher.Send(new Post Type = PostType.General, Group = PostGroups.Publication, Title = title, + FormattedTitle = formattedTitle, Body = body, Link = publisher.ToAbsolute(relativeLink) }); } - public static async Task AnnounceForum(this ExternalMediaPublisher publisher, string title, string body, string relativeLink) + public static async Task AnnounceForum(this ExternalMediaPublisher publisher, string title, string formattedTitle, string body, string relativeLink) { await publisher.Send(new Post { @@ -141,12 +148,13 @@ await publisher.Send(new Post Type = PostType.Announcement, Group = PostGroups.Forum, Title = title, + FormattedTitle = formattedTitle, Body = body, Link = publisher.ToAbsolute(relativeLink) }); } - public static async Task SendForum(this ExternalMediaPublisher publisher, bool restricted, string title, string body, string relativeLink) + public static async Task SendForum(this ExternalMediaPublisher publisher, bool restricted, string title, string formattedTitle, string body, string relativeLink) { await publisher.Send(new Post { @@ -155,12 +163,13 @@ await publisher.Send(new Post : PostType.General, Group = PostGroups.Forum, Title = title, + FormattedTitle = formattedTitle, Body = body, Link = publisher.ToAbsolute(relativeLink) }); } - public static async Task SendGeneralWiki(this ExternalMediaPublisher publisher, string title, string body, string relativeLink) + public static async Task SendGeneralWiki(this ExternalMediaPublisher publisher, string title, string formattedTitle, string body, string relativeLink) { await publisher.Send(new Post { @@ -168,12 +177,13 @@ await publisher.Send(new Post Type = PostType.General, Group = PostGroups.Wiki, Title = title, + FormattedTitle = formattedTitle, Body = body, Link = publisher.ToAbsolute(relativeLink) }); } - public static async Task SendUserManagement(this ExternalMediaPublisher publisher, string title, string body, string relativeLink) + public static async Task SendUserManagement(this ExternalMediaPublisher publisher, string title, string formattedTitle, string body, string relativeLink) { await publisher.Send(new Post { @@ -181,18 +191,20 @@ await publisher.Send(new Post Type = PostType.Administrative, Group = PostGroups.UserManagement, Title = title, + FormattedTitle = formattedTitle, Body = body, Link = publisher.ToAbsolute(relativeLink) }); } - public static async Task SendGameManagement(this ExternalMediaPublisher publisher, string title, string body, string relativeLink) + public static async Task SendGameManagement(this ExternalMediaPublisher publisher, string title, string formattedTitle, string body, string relativeLink) { await publisher.Send(new Post { Type = PostType.General, Group = PostGroups.Game, Title = title, + FormattedTitle = formattedTitle, Body = body, Link = publisher.ToAbsolute(relativeLink) }); diff --git a/TASVideos.Core/Services/ExternalMediaPublisher/Post.cs b/TASVideos.Core/Services/ExternalMediaPublisher/Post.cs index f06640025..c8f6d38d5 100644 --- a/TASVideos.Core/Services/ExternalMediaPublisher/Post.cs +++ b/TASVideos.Core/Services/ExternalMediaPublisher/Post.cs @@ -15,6 +15,12 @@ public interface IPostable /// Gets the post title /// string Title { get; } + + /// + /// Gets the post title with markdown formatting. + /// Optionally may include "{0}" to be replaced with the . + /// + string FormattedTitle { get; } /// /// Gets a link that will direct a user to the resource or to more detailed information @@ -51,6 +57,7 @@ public class Post : IPostable { public string Announcement { get; set; } = ""; public string Title { get; init; } = ""; + public string FormattedTitle { get; init; } = ""; public string Link { get; init; } = ""; public string Body { get; init; } = ""; public string Group { get; init; } = ""; diff --git a/TASVideos/Pages/Account/ConfirmEmail.cshtml.cs b/TASVideos/Pages/Account/ConfirmEmail.cshtml.cs index d5a136ba0..beb00ca00 100644 --- a/TASVideos/Pages/Account/ConfirmEmail.cshtml.cs +++ b/TASVideos/Pages/Account/ConfirmEmail.cshtml.cs @@ -58,6 +58,7 @@ public async Task OnGet(string? userId, string? code) await _signInManager.SignInAsync(user, isPersistent: false); await _publisher.SendUserManagement( $"User {user.UserName} activated", + $"User [{user.UserName}]({{0}}) activated", "", $"Users/Profile/{Uri.EscapeDataString(user.UserName)}"); await _userMaintenanceLogger.Log(user.Id, $"User activated from {IpAddress}"); diff --git a/TASVideos/Pages/Account/Register.cshtml.cs b/TASVideos/Pages/Account/Register.cshtml.cs index 4ccb4799a..b84735ed7 100644 --- a/TASVideos/Pages/Account/Register.cshtml.cs +++ b/TASVideos/Pages/Account/Register.cshtml.cs @@ -128,6 +128,7 @@ public async Task OnPost() await _signInManager.SignInAsync(user, isPersistent: false); await _publisher.SendUserManagement( $"New User registered! {user.UserName}", + $"New User registered! [{user.UserName}]({{0}})", "", $"Users/Profile/{Uri.EscapeDataString(user.UserName)}"); await _userMaintenanceLogger.Log(user.Id, $"New registration from {IpAddress}"); diff --git a/TASVideos/Pages/Forum/Posts/Create.cshtml.cs b/TASVideos/Pages/Forum/Posts/Create.cshtml.cs index d2095abf3..d87fb39aa 100644 --- a/TASVideos/Pages/Forum/Posts/Create.cshtml.cs +++ b/TASVideos/Pages/Forum/Posts/Create.cshtml.cs @@ -192,6 +192,7 @@ public async Task OnPost() { await _publisher.AnnounceForum( $"News Post by {user.UserName}{mood}", + $"[News Post]({{0}}) by {user.UserName}{mood}", $"{topic.Forum.ShortName}: {topic.Title}{subject}", $"Forum/Posts/{id}"); } @@ -200,6 +201,7 @@ await _publisher.AnnounceForum( await _publisher.SendForum( topic.Forum.Restricted, $"New Post by {user.UserName}{mood}", + $"[New Post]({{0}}) by {user.UserName}{mood}", $"{topic.Forum.ShortName}: {topic.Title}{subject}", $"Forum/Posts/{id}"); } diff --git a/TASVideos/Pages/Forum/Posts/Edit.cshtml.cs b/TASVideos/Pages/Forum/Posts/Edit.cshtml.cs index 6dd8156ce..fd300126f 100644 --- a/TASVideos/Pages/Forum/Posts/Edit.cshtml.cs +++ b/TASVideos/Pages/Forum/Posts/Edit.cshtml.cs @@ -175,6 +175,7 @@ public async Task OnPost() await _publisher.SendForum( forumPost.Topic!.Forum!.Restricted, $"Post edited by {User.Name()}", + $"[Post]({{0}}) edited by {User.Name()}", $"{forumPost.Topic.Forum.ShortName}: {forumPost.Topic.Title}", $"Forum/Posts/{Id}"); } @@ -233,6 +234,7 @@ public async Task OnPostDelete() await _publisher.SendForum( post.Topic!.Forum!.Restricted, $"{(topicDeleted ? "Topic" : "Post")} DELETED by {User.Name()}", + $"[{(topicDeleted ? "Topic" : "Post")} DELETED]({{0}}) by {User.Name()}", $"{post.Topic!.Forum!.ShortName}: {post.Topic.Title}", topicDeleted ? "" : $"Forum/Topics/{post.Topic.Id}"); } @@ -293,6 +295,7 @@ public async Task OnPostSpam() await _publisher.SendForum( false, $"{(topicDeleted ? "Topic" : "Post")} DELETED as SPAM, and user {post.Poster!.UserName} banned by {User.Name()}", + $"[{(topicDeleted ? "Topic" : "Post")} DELETED as SPAM]({{0}}), and user {post.Poster!.UserName} banned by {User.Name()}", $"{oldForumShortName}: {oldTopicTitle}", topicDeleted ? "" : $"Forum/Topics/{oldTopicId}"); } diff --git a/TASVideos/Pages/Forum/Topics/Create.cshtml.cs b/TASVideos/Pages/Forum/Topics/Create.cshtml.cs index 5c10deaf8..969cdf3d6 100644 --- a/TASVideos/Pages/Forum/Topics/Create.cshtml.cs +++ b/TASVideos/Pages/Forum/Topics/Create.cshtml.cs @@ -150,6 +150,7 @@ await _forumService.CreatePoll( await _publisher.SendForum( forum.Restricted, $"New Topic by {User.Name()}", + $"[New Topic]({{0}}) by {User.Name()}", $"{forum.ShortName}: {Topic.Title}", $"Forum/Topics/{topic.Id}"); diff --git a/TASVideos/Pages/Forum/Topics/Index.cshtml.cs b/TASVideos/Pages/Forum/Topics/Index.cshtml.cs index 6630eb0c2..de2f2eb2f 100644 --- a/TASVideos/Pages/Forum/Topics/Index.cshtml.cs +++ b/TASVideos/Pages/Forum/Topics/Index.cshtml.cs @@ -291,6 +291,7 @@ public async Task OnPostLock(string topicTitle, bool locked) await _publisher.SendForum( topic.Forum!.Restricted, $"Topic {lockedState} by {User.Name()}", + $"[Topic]({{0}}) {lockedState} by {User.Name()}", $"{topic.Forum.ShortName}: {topic.Title}", $"Forum/Topics/{Id}"); } diff --git a/TASVideos/Pages/Forum/Topics/Merge.cshtml.cs b/TASVideos/Pages/Forum/Topics/Merge.cshtml.cs index 375dc4f8b..bcdda4195 100644 --- a/TASVideos/Pages/Forum/Topics/Merge.cshtml.cs +++ b/TASVideos/Pages/Forum/Topics/Merge.cshtml.cs @@ -119,6 +119,7 @@ public async Task OnPost() await _publisher.SendForum( originalTopic.Forum!.Restricted || destinationTopic.Forum!.Restricted, $"Topics MERGED by {User.Name()}", + $"[Topics MERGED]({{0}}) by {User.Name()}", $@"""{originalTopic.Title}"" into ""{destinationTopic.Title}""", $"Forum/Topics/{destinationTopic.Id}"); } diff --git a/TASVideos/Pages/Forum/Topics/Move.cshtml.cs b/TASVideos/Pages/Forum/Topics/Move.cshtml.cs index 17029f156..10fb16614 100644 --- a/TASVideos/Pages/Forum/Topics/Move.cshtml.cs +++ b/TASVideos/Pages/Forum/Topics/Move.cshtml.cs @@ -109,6 +109,7 @@ public async Task OnPost() await _publisher.SendForum( topicWasRestricted || forum.Restricted, $"Topic MOVED by {User.Name()}", + $"[Topic]({{0}}) MOVED by {User.Name()}", $@"""{Topic.TopicTitle}"" from {Topic.ForumName} to {forum.Name}", $"Forum/Topics/{Id}"); diff --git a/TASVideos/Pages/Forum/Topics/Split.cshtml.cs b/TASVideos/Pages/Forum/Topics/Split.cshtml.cs index a60eb65fe..6b81d977f 100644 --- a/TASVideos/Pages/Forum/Topics/Split.cshtml.cs +++ b/TASVideos/Pages/Forum/Topics/Split.cshtml.cs @@ -130,6 +130,7 @@ public async Task OnPost() await _publisher.SendForum( destinationForum.Restricted || topic.Forum!.Restricted, $"Topic SPLIT by {User.Name()}", + $"[Topic]({{0}}) SPLIT by {User.Name()}", $@"""{newTopic.Title}"" from ""{Topic.Title}""", $"Forum/Topics/{newTopic.Id}"); diff --git a/TASVideos/Pages/Games/Edit.cshtml.cs b/TASVideos/Pages/Games/Edit.cshtml.cs index bacf4a09d..4c2e8ffea 100644 --- a/TASVideos/Pages/Games/Edit.cshtml.cs +++ b/TASVideos/Pages/Games/Edit.cshtml.cs @@ -133,7 +133,11 @@ public async Task OnPost() var saveResult = await ConcurrentSave(_db, saveMessage, $"Unable to update Game {Id}"); if (saveResult && !Game.MinorEdit) { - await _publisher.SendGameManagement($"{saveMessage} by {User.Name()}", "", $"{Id}G"); + await _publisher.SendGameManagement( + $"{saveMessage} by {User.Name()}", + $"Game [{game.DisplayName}]({{0}}) updated by {User.Name()}", + "", + $"{Id}G"); } } else @@ -152,7 +156,11 @@ public async Task OnPost() var saveResult = await ConcurrentSave(_db, saveMessage, "Unable to create game"); if (saveResult && !Game.MinorEdit) { - await _publisher.SendGameManagement($"{saveMessage} by {User.Name()}", "", $"{game.Id}G"); + await _publisher.SendGameManagement( + $"{saveMessage} by {User.Name()}", + $"Game [{game.DisplayName}]({{0}}) created by {User.Name()}", + "", + $"{game.Id}G"); } } @@ -195,7 +203,11 @@ public async Task OnPostDelete() var saveResult = await ConcurrentSave(_db, saveMessage, $"Unable to delete Game {Id}"); if (saveResult) { - await _publisher.SendGameManagement($"{saveMessage} by {User.Name()}", "", $"{Id}G"); + await _publisher.SendGameManagement( + $"{saveMessage} by {User.Name()}", + "", + "", + ""); } return BasePageRedirect("List"); diff --git a/TASVideos/Pages/Games/Rewire.cshtml.cs b/TASVideos/Pages/Games/Rewire.cshtml.cs index 913227043..446ba638d 100644 --- a/TASVideos/Pages/Games/Rewire.cshtml.cs +++ b/TASVideos/Pages/Games/Rewire.cshtml.cs @@ -122,7 +122,11 @@ public async Task OnPost() var result = await ConcurrentSave(_db, $"Rewired Game {FromGameId} into Game {IntoGameId}", $"Unable to rewire Game {FromGameId} into Game {IntoGameId}"); if (result) { - await _publisher.SendGameManagement($"{IntoGameId}G edited by {User.Name()}", $"Rewired {FromGameId}G into {IntoGameId}G", $"{IntoGameId}G"); + await _publisher.SendGameManagement( + $"{IntoGameId}G edited by {User.Name()}", + $"[{IntoGameId}G]({{0}}) edited by {User.Name()}", + $"Rewired {FromGameId}G into {IntoGameId}G", + $"{IntoGameId}G"); } } } diff --git a/TASVideos/Pages/Publications/AdditionalMovies.cshtml.cs b/TASVideos/Pages/Publications/AdditionalMovies.cshtml.cs index 5ee37b781..920dfef6f 100644 --- a/TASVideos/Pages/Publications/AdditionalMovies.cshtml.cs +++ b/TASVideos/Pages/Publications/AdditionalMovies.cshtml.cs @@ -122,6 +122,7 @@ public async Task OnPost() { await _publisher.SendPublicationEdit( $"{Id}M edited by {User.Name()}", + $"[{Id}M]({{0}}) edited by {User.Name()}", $"{log} | {PublicationTitle}", $"{Id}M"); } @@ -146,6 +147,7 @@ public async Task OnPostDelete(int publicationFileId) { await _publisher.SendPublicationEdit( $"{Id}M edited by {User.Name()}", + $"[{Id}M]({{0}}) edited by {User.Name()}", $"{log}", $"{Id}M"); } diff --git a/TASVideos/Pages/Publications/Catalog.cshtml.cs b/TASVideos/Pages/Publications/Catalog.cshtml.cs index 2335bbd93..9392834ee 100644 --- a/TASVideos/Pages/Publications/Catalog.cshtml.cs +++ b/TASVideos/Pages/Publications/Catalog.cshtml.cs @@ -175,6 +175,7 @@ public async Task OnPost() { await _publisher.SendGameManagement( $"{Id}M Catalog edited by {User.Name()}", + $"[{Id}M]({{0}}) Catalog edited by {User.Name()}", $"{string.Join(", ", externalMessages)} | {publication.Title}", $"{Id}M"); } diff --git a/TASVideos/Pages/Publications/Edit.cshtml.cs b/TASVideos/Pages/Publications/Edit.cshtml.cs index f623dffe6..663cb7452 100644 --- a/TASVideos/Pages/Publications/Edit.cshtml.cs +++ b/TASVideos/Pages/Publications/Edit.cshtml.cs @@ -271,6 +271,7 @@ await _youtubeSync.SyncYouTubeVideo(new YoutubeVideo( { await _publisher.SendPublicationEdit( $"{Id}M edited by {User.Name()}", + $"[{Id}M]({{0}}) edited by {User.Name()}", $"{string.Join(", ", externalMessages)} | {publication.Title}", $"{Id}M"); } diff --git a/TASVideos/Pages/Publications/EditClass.cshtml.cs b/TASVideos/Pages/Publications/EditClass.cshtml.cs index 43885b705..5500bec66 100644 --- a/TASVideos/Pages/Publications/EditClass.cshtml.cs +++ b/TASVideos/Pages/Publications/EditClass.cshtml.cs @@ -96,6 +96,7 @@ public async Task OnPost() { await _publisher.SendPublicationEdit( $"{log} by {User.Name()}", + $"[{Id}M]({{0}}) Class changed from {originalClass} to {publicationClass.Name} by {User.Name()}", Title, $"{Id}M"); } diff --git a/TASVideos/Pages/Publications/EditFiles.cshtml.cs b/TASVideos/Pages/Publications/EditFiles.cshtml.cs index 3d9806c30..975568d7d 100644 --- a/TASVideos/Pages/Publications/EditFiles.cshtml.cs +++ b/TASVideos/Pages/Publications/EditFiles.cshtml.cs @@ -82,6 +82,7 @@ public async Task OnPost() await _publicationMaintenanceLogger.Log(Id, User.GetUserId(), log); await _publisher.SendPublicationEdit( $"{Id}M edited by {User.Name()}", + $"[{Id}M]({{0}}) edited by {User.Name()}", $"{log} | {Title}", $"{Id}M"); @@ -99,6 +100,7 @@ public async Task OnPostDelete(int publicationFileId) await _publicationMaintenanceLogger.Log(Id, User.GetUserId(), log); await _publisher.SendPublicationEdit( $"{Id}M edited by {User.Name()}", + $"[{Id}M]({{0}}) edited by {User.Name()}", $"{log}", $"{Id}M"); } diff --git a/TASVideos/Pages/Publications/EditUrls.cshtml.cs b/TASVideos/Pages/Publications/EditUrls.cshtml.cs index b9be3b267..33212fcb3 100644 --- a/TASVideos/Pages/Publications/EditUrls.cshtml.cs +++ b/TASVideos/Pages/Publications/EditUrls.cshtml.cs @@ -141,6 +141,7 @@ public async Task OnPost() { await _publisher.SendPublicationEdit( $"{Id}M edited by {User.Name()}", + $"[{Id}M]({{0}}) edited by {User.Name()}", $"Added {UrlType} url | {Title}", $"{Id}M"); @@ -178,6 +179,7 @@ public async Task OnPostDelete(int publicationUrlId) { await _publisher.SendPublicationEdit( $"{Id}M edited by {User.Name()}", + $"[{Id}M]({{0}}) edited by {User.Name()}", $"Deleted {url.Type} url", $"{Id}M"); diff --git a/TASVideos/Pages/Publications/PrimaryMovie.cshtml.cs b/TASVideos/Pages/Publications/PrimaryMovie.cshtml.cs index 2065c110e..fb63e1db3 100644 --- a/TASVideos/Pages/Publications/PrimaryMovie.cshtml.cs +++ b/TASVideos/Pages/Publications/PrimaryMovie.cshtml.cs @@ -92,6 +92,7 @@ public async Task OnPost() await _publicationMaintenanceLogger.Log(Id, User.GetUserId(), log); await _publisher.SendPublicationEdit( $"{Id}M edited by {User.Name()}", + $"[{Id}M]({{0}}) edited by {User.Name()}", $"{log} | {PublicationTitle}", $"{Id}M"); } diff --git a/TASVideos/Pages/Roles/AddEdit.cshtml.cs b/TASVideos/Pages/Roles/AddEdit.cshtml.cs index e71392021..3e3b84140 100644 --- a/TASVideos/Pages/Roles/AddEdit.cshtml.cs +++ b/TASVideos/Pages/Roles/AddEdit.cshtml.cs @@ -145,7 +145,8 @@ public async Task OnPostDelete() await _publisher.SendUserManagement( $"Role {Id} deleted by {User.Name()}", "", - "Roles/List"); + "", + ""); } return BasePageRedirect("List"); @@ -179,6 +180,7 @@ private async Task AddUpdateRole(RoleEditModel model) await _publisher.SendUserManagement( $"Role {model.Name} updated by {User.Name()}", + $"Role [{model.Name}]({{0}}) updated by {User.Name()}", "", $"Roles/{model.Name}"); } @@ -188,6 +190,7 @@ await _publisher.SendUserManagement( _db.Roles.Attach(role); await _publisher.SendUserManagement( $"New Role {model.Name} added by {User.Name()}", + $"New Role [{model.Name}]({{0}}) added by {User.Name()}", "", $"Roles/{model.Name}"); } diff --git a/TASVideos/Pages/Submissions/Catalog.cshtml.cs b/TASVideos/Pages/Submissions/Catalog.cshtml.cs index 75558f965..7c76ea3fd 100644 --- a/TASVideos/Pages/Submissions/Catalog.cshtml.cs +++ b/TASVideos/Pages/Submissions/Catalog.cshtml.cs @@ -192,6 +192,7 @@ public async Task OnPost() { await _publisher.SendGameManagement( $"{Id}S Catalog edited by {User.Name()}", + $"[{Id}S]({{0}}) Catalog edited by {User.Name()}", $"{string.Join(", ", externalMessages)} | {submission.Title}", $"{Id}S"); } diff --git a/TASVideos/Pages/Submissions/DeprecateMovieFormats.cshtml.cs b/TASVideos/Pages/Submissions/DeprecateMovieFormats.cshtml.cs index fe97a9146..8213a66f1 100644 --- a/TASVideos/Pages/Submissions/DeprecateMovieFormats.cshtml.cs +++ b/TASVideos/Pages/Submissions/DeprecateMovieFormats.cshtml.cs @@ -54,6 +54,7 @@ private async Task SendAnnouncement(string extension, bool deprecate) { await _publisher.SendSubmissionEdit( $"{extension} deprecation status set to {deprecate} by {User.Name()}", + $"[{extension}]({{0}}) deprecation status set to {deprecate} by {User.Name()}", "", ""); } diff --git a/TASVideos/Pages/Submissions/Edit.cshtml.cs b/TASVideos/Pages/Submissions/Edit.cshtml.cs index 4f3bc942b..51f148ee7 100644 --- a/TASVideos/Pages/Submissions/Edit.cshtml.cs +++ b/TASVideos/Pages/Submissions/Edit.cshtml.cs @@ -388,6 +388,7 @@ or SubmissionStatus.Accepted if (!Submission.MinorEdit || statusHasChanged) // always publish submission status changes to media { string title; + string formattedTitle; if (statusHasChanged) { string statusStr = Submission.Status.EnumDisplayName(); @@ -421,14 +422,17 @@ or SubmissionStatus.PublicationUnderway } title = $"Submission {statusStr} by {userName}"; + formattedTitle = $"[Submission]({{0}}) {statusStr} by {userName}"; } else { title = $"Submission edited by {userName}"; + formattedTitle = $"[Submission]({{0}}) edited by {userName}"; } await _publisher.SendSubmissionEdit( title, + formattedTitle, submission.Title, $"{Id}S"); } @@ -497,6 +501,7 @@ await _wikiPages.Add(new WikiCreateRequest string statusPrefix = newStatus == SubmissionStatus.JudgingUnderWay ? "" : "set to "; await _publisher.SendSubmissionEdit( $"Submission {statusPrefix}{newStatus.EnumDisplayName()} by {User.Name()}", + $"[Submission]({{0}}) {statusPrefix}{newStatus.EnumDisplayName()} by {User.Name()}", $"{submission.Title}", $"{Id}S"); } diff --git a/TASVideos/Pages/UserFiles/Index.cshtml.cs b/TASVideos/Pages/UserFiles/Index.cshtml.cs index d726374be..a994bb172 100644 --- a/TASVideos/Pages/UserFiles/Index.cshtml.cs +++ b/TASVideos/Pages/UserFiles/Index.cshtml.cs @@ -102,6 +102,7 @@ public async Task OnPostComment(long fileId, string comment) await _publisher.SendUserFile( userFile.Hidden, $@"New user file comment by {User.Name()}", + $@"New [user file]({{0}}) comment by {User.Name()}", $"UserFiles/Info/{fileId}", $"{userFile.Title}"); } @@ -129,6 +130,7 @@ public async Task OnPostEditComment(long commentId, string commen await _publisher.SendUserFile( fileComment.UserFile!.Hidden, $"User file comment edited by {User.Name()}", + $@"[User file]({{0}}) comment edited by {User.Name()}", $"UserFiles/Info/{fileComment.UserFile.Id}", $"{fileComment.UserFile!.Title}"); } @@ -156,6 +158,7 @@ public async Task OnPostDeleteComment(long commentId) await _publisher.SendUserFile( fileComment.UserFile!.Hidden, $"User file comment DELETED by {User.Name()}", + $"[User file]({{0}}) comment DELETED by {User.Name()}", $"UserFiles/Info/{fileComment.UserFile.Id}", $"{fileComment.UserFile!.Title}"); } diff --git a/TASVideos/Pages/UserFiles/Upload.cshtml.cs b/TASVideos/Pages/UserFiles/Upload.cshtml.cs index 686426562..0fb5f8da0 100644 --- a/TASVideos/Pages/UserFiles/Upload.cshtml.cs +++ b/TASVideos/Pages/UserFiles/Upload.cshtml.cs @@ -98,6 +98,7 @@ public async Task OnPost() await _publisher.SendUserFile( UserFile.Hidden, $"New user file uploaded by {User.Name()}", + $"New [user file]({{0}}) uploaded by {User.Name()}", $"/UserFiles/Info/{id}", $"{UserFile.Title}"); diff --git a/TASVideos/Pages/Users/Edit.cshtml.cs b/TASVideos/Pages/Users/Edit.cshtml.cs index 1e4b251d7..caab1cba6 100644 --- a/TASVideos/Pages/Users/Edit.cshtml.cs +++ b/TASVideos/Pages/Users/Edit.cshtml.cs @@ -129,6 +129,7 @@ public async Task OnPost() string message = $"Username {userNameChange} changed to {user.UserName} by {User.Name()}"; await _publisher.SendUserManagement( message, + $"Username {userNameChange} changed to [{user.UserName}]({{0}}) by {User.Name()}", "", $"Users/Profile/{Uri.EscapeDataString(user.UserName!)}"); await _userMaintenanceLogger.Log(user.Id, message, User.GetUserId()); @@ -170,6 +171,7 @@ await _publisher.SendUserManagement( await _publisher.SendUserManagement( $"User {user.UserName} edited by {User.Name()}", + $"User [{user.UserName}]({{0}}) edited by {User.Name()}", message, $"Users/Profile/{Uri.EscapeDataString(user.UserName!)}"); await _userMaintenanceLogger.Log(user.Id, message, User.GetUserId()); diff --git a/TASVideos/Pages/Users/EditEmail.cshtml.cs b/TASVideos/Pages/Users/EditEmail.cshtml.cs index 53549d2ec..d2906ffb3 100644 --- a/TASVideos/Pages/Users/EditEmail.cshtml.cs +++ b/TASVideos/Pages/Users/EditEmail.cshtml.cs @@ -88,7 +88,11 @@ public async Task OnPost() { var message = $"User {user.UserName} email changed by {User.Name()}"; await _userMaintenanceLogger.Log(user.Id, message, User.GetUserId()); - await _publisher.SendUserManagement(message, "", $"Users/Profile/{Uri.EscapeDataString(user.UserName!)}"); + await _publisher.SendUserManagement( + message, + $"User [{user.UserName}]({{0}}) email changed by {User.Name()}", + "", + $"Users/Profile/{Uri.EscapeDataString(user.UserName!)}"); SuccessStatusMessage($"User {user.UserName} email changed by {User.Name()}"); } diff --git a/TASVideos/Pages/Wiki/DeletedPages.cshtml.cs b/TASVideos/Pages/Wiki/DeletedPages.cshtml.cs index cc9deeb55..64c599edb 100644 --- a/TASVideos/Pages/Wiki/DeletedPages.cshtml.cs +++ b/TASVideos/Pages/Wiki/DeletedPages.cshtml.cs @@ -59,6 +59,7 @@ public async Task OnPostDeletePage(string path) await _publisher.SendGeneralWiki( $"Page {path} DELETED by {User.Name()}", + "", $"{result} revisions", ""); } @@ -84,6 +85,7 @@ public async Task OnPostDeleteRevision(string path, int revision) await _publisher.SendGeneralWiki( $"Revision {revision} of {path} DELETED by {User.Name()}", "", + "", ""); return BaseRedirect("/" + path); @@ -111,6 +113,7 @@ public async Task OnPostUndelete(string path) await _publisher.SendGeneralWiki( $"Page {path} UNDELETED by {User.Name()}", + $"Page [{path}]({{0}}) UNDELETED by {User.Name()}", "", WikiHelper.EscapeUserName(path)); diff --git a/TASVideos/Pages/Wiki/Edit.cshtml.cs b/TASVideos/Pages/Wiki/Edit.cshtml.cs index 0fb9d2f40..a9bf61ae5 100644 --- a/TASVideos/Pages/Wiki/Edit.cshtml.cs +++ b/TASVideos/Pages/Wiki/Edit.cshtml.cs @@ -157,6 +157,7 @@ private async Task Announce(IWikiPage page) { await _publisher.SendGeneralWiki( $"Page {Path} {(page.Revision > 1 ? "edited" : "created")} by {User.Name()}", + $"Page [{Path}]({{0}}) {(page.Revision > 1 ? "edited" : "created")} by {User.Name()}", $"{page.RevisionMessage}", WikiHelper.EscapeUserName(Path!)); } diff --git a/TASVideos/Pages/Wiki/Move.cshtml.cs b/TASVideos/Pages/Wiki/Move.cshtml.cs index f5977cb04..051ce4b51 100644 --- a/TASVideos/Pages/Wiki/Move.cshtml.cs +++ b/TASVideos/Pages/Wiki/Move.cshtml.cs @@ -75,6 +75,7 @@ public async Task OnPost() await _publisher.SendGeneralWiki( $"Page {Move.OriginalPageName} moved to {Move.DestinationPageName} by {User.Name()}", + $"Page {Move.OriginalPageName} moved to [{Move.DestinationPageName}]({{0}}) by {User.Name()}", "", WikiHelper.EscapeUserName(Move.DestinationPageName));