:drunk: Write shit code trying to split up the Auth (WIP)
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using DysonNetwork.Sphere.Account;
|
||||
using DysonNetwork.Common.Models;
|
||||
using DysonNetwork.Common.Services;
|
||||
using DysonNetwork.Sphere.Connection.WebReader;
|
||||
using DysonNetwork.Sphere.Localization;
|
||||
using DysonNetwork.Sphere.Publisher;
|
||||
@ -23,7 +24,7 @@ public partial class PostService(
|
||||
{
|
||||
private const string PostFileUsageIdentifier = "post";
|
||||
|
||||
private static List<Post> TruncatePostContent(List<Post> input)
|
||||
private static List<Common.Models.Post> TruncatePostContent(List<Common.Models.Post> input)
|
||||
{
|
||||
const int maxLength = 256;
|
||||
const int embedMaxLength = 80;
|
||||
@ -53,7 +54,7 @@ public partial class PostService(
|
||||
return input;
|
||||
}
|
||||
|
||||
public (string title, string content) ChopPostForNotification(Post post)
|
||||
public (string title, string content) ChopPostForNotification(Common.Models.Post post)
|
||||
{
|
||||
var content = !string.IsNullOrEmpty(post.Description)
|
||||
? post.Description?.Length >= 40 ? post.Description[..37] + "..." : post.Description
|
||||
@ -68,9 +69,9 @@ public partial class PostService(
|
||||
return (title, content);
|
||||
}
|
||||
|
||||
public async Task<Post> PostAsync(
|
||||
public async Task<Common.Models.Post> PostAsync(
|
||||
Account.Account user,
|
||||
Post post,
|
||||
Common.Models.Post post,
|
||||
List<string>? attachments = null,
|
||||
List<string>? tags = null,
|
||||
List<string>? categories = null
|
||||
@ -191,8 +192,8 @@ public partial class PostService(
|
||||
return post;
|
||||
}
|
||||
|
||||
public async Task<Post> UpdatePostAsync(
|
||||
Post post,
|
||||
public async Task<Common.Models.Post> UpdatePostAsync(
|
||||
Common.Models.Post post,
|
||||
List<string>? attachments = null,
|
||||
List<string>? tags = null,
|
||||
List<string>? categories = null,
|
||||
@ -269,7 +270,7 @@ public partial class PostService(
|
||||
[GeneratedRegex(@"https?://[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]")]
|
||||
private static partial Regex GetLinkRegex();
|
||||
|
||||
public async Task<Post> PreviewPostLinkAsync(Post item)
|
||||
public async Task<Common.Models.Post> PreviewPostLinkAsync(Common.Models.Post item)
|
||||
{
|
||||
if (item.Type != PostType.Moment || string.IsNullOrEmpty(item.Content)) return item;
|
||||
|
||||
@ -328,7 +329,7 @@ public partial class PostService(
|
||||
/// This method is designed to be called from a background task
|
||||
/// </summary>
|
||||
/// <param name="post">The post to process link previews for</param>
|
||||
private async Task ProcessPostLinkPreviewAsync(Post post)
|
||||
private async Task ProcessPostLinkPreviewAsync(Common.Models.Post post)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -367,7 +368,7 @@ public partial class PostService(
|
||||
}
|
||||
}
|
||||
|
||||
public async Task DeletePostAsync(Post post)
|
||||
public async Task DeletePostAsync(Common.Models.Post post)
|
||||
{
|
||||
var postResourceId = $"post:{post.Id}";
|
||||
|
||||
@ -389,7 +390,7 @@ public partial class PostService(
|
||||
/// <param name="isSelfReact">Indicate this reaction is by the original post himself</param>
|
||||
/// <param name="sender">The account that creates this reaction</param>
|
||||
public async Task<bool> ModifyPostVotes(
|
||||
Post post,
|
||||
Common.Models.Post post,
|
||||
PostReaction reaction,
|
||||
Account.Account sender,
|
||||
bool isRemoving,
|
||||
@ -528,10 +529,10 @@ public partial class PostService(
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<List<Post>> LoadPublishers(List<Post> posts)
|
||||
public async Task<List<Common.Models.Post>> LoadPublishers(List<Common.Models.Post> posts)
|
||||
{
|
||||
var publisherIds = posts
|
||||
.SelectMany<Post, Guid?>(e =>
|
||||
.SelectMany<Common.Models.Post, Guid?>(e =>
|
||||
[
|
||||
e.PublisherId,
|
||||
e.RepliedPost?.PublisherId,
|
||||
@ -563,7 +564,7 @@ public partial class PostService(
|
||||
return posts;
|
||||
}
|
||||
|
||||
public async Task<List<Post>> LoadInteractive(List<Post> posts, Account.Account? currentUser = null)
|
||||
public async Task<List<Common.Models.Post>> LoadInteractive(List<Common.Models.Post> posts, Account.Account? currentUser = null)
|
||||
{
|
||||
if (posts.Count == 0) return posts;
|
||||
|
||||
@ -605,7 +606,7 @@ public partial class PostService(
|
||||
);
|
||||
}
|
||||
|
||||
public async Task<List<Post>> LoadPostInfo(List<Post> posts, Account.Account? currentUser = null,
|
||||
public async Task<List<Common.Models.Post>> LoadPostInfo(List<Common.Models.Post> posts, Account.Account? currentUser = null,
|
||||
bool truncate = false)
|
||||
{
|
||||
if (posts.Count == 0) return posts;
|
||||
@ -619,7 +620,7 @@ public partial class PostService(
|
||||
return posts;
|
||||
}
|
||||
|
||||
public async Task<Post> LoadPostInfo(Post post, Account.Account? currentUser = null, bool truncate = false)
|
||||
public async Task<Common.Models.Post> LoadPostInfo(Common.Models.Post post, Account.Account? currentUser = null, bool truncate = false)
|
||||
{
|
||||
// Convert single post to list, process it, then return the single post
|
||||
var posts = await LoadPostInfo([post], currentUser, truncate);
|
||||
@ -629,8 +630,8 @@ public partial class PostService(
|
||||
|
||||
public static class PostQueryExtensions
|
||||
{
|
||||
public static IQueryable<Post> FilterWithVisibility(
|
||||
this IQueryable<Post> source,
|
||||
public static IQueryable<Common.Models.Post> FilterWithVisibility(
|
||||
this IQueryable<Common.Models.Post> source,
|
||||
Account.Account? currentUser,
|
||||
List<Guid> userFriends,
|
||||
List<Publisher.Publisher> publishers,
|
||||
|
Reference in New Issue
Block a user