🐛 Trying to fix bugs...
This commit is contained in:
parent
b8c15bde1a
commit
6965744d5a
@ -84,6 +84,7 @@ public class AccountContact : ModelBase
|
|||||||
public Instant? VerifiedAt { get; set; }
|
public Instant? VerifiedAt { get; set; }
|
||||||
[MaxLength(1024)] public string Content { get; set; } = string.Empty;
|
[MaxLength(1024)] public string Content { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public Guid AccountId { get; set; }
|
||||||
[JsonIgnore] public Account Account { get; set; } = null!;
|
[JsonIgnore] public Account Account { get; set; } = null!;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,6 +101,7 @@ public class AccountAuthFactor : ModelBase
|
|||||||
public AccountAuthFactorType Type { get; set; }
|
public AccountAuthFactorType Type { get; set; }
|
||||||
[MaxLength(8196)] public string? Secret { get; set; } = null;
|
[MaxLength(8196)] public string? Secret { get; set; } = null;
|
||||||
|
|
||||||
|
public Guid AccountId { get; set; }
|
||||||
[JsonIgnore] public Account Account { get; set; } = null!;
|
[JsonIgnore] public Account Account { get; set; } = null!;
|
||||||
|
|
||||||
public AccountAuthFactor HashSecret(int cost = 12)
|
public AccountAuthFactor HashSecret(int cost = 12)
|
||||||
|
@ -264,22 +264,29 @@ public class NotificationService
|
|||||||
if (_apns == null)
|
if (_apns == null)
|
||||||
throw new InvalidOperationException("The apple notification push service is not initialized.");
|
throw new InvalidOperationException("The apple notification push service is not initialized.");
|
||||||
|
|
||||||
await _apns.SendAsync(new Dictionary<string, object>
|
var alertDict = new Dictionary<string, object>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(notification.Title))
|
||||||
|
alertDict["title"] = notification.Title;
|
||||||
|
if (!string.IsNullOrEmpty(notification.Subtitle))
|
||||||
|
alertDict["subtitle"] = notification.Subtitle;
|
||||||
|
if (!string.IsNullOrEmpty(notification.Content))
|
||||||
|
alertDict["body"] = notification.Content;
|
||||||
|
|
||||||
|
var payload = new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
["topic"] = notification.Topic,
|
||||||
|
["aps"] = new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
["topic"] = notification.Topic,
|
["alert"] = alertDict
|
||||||
["aps"] = new Dictionary<string, object>
|
|
||||||
{
|
|
||||||
["alert"] = new Dictionary<string, object>
|
|
||||||
{
|
|
||||||
["title"] = notification.Title ?? string.Empty,
|
|
||||||
["subtitle"] = notification.Subtitle ?? string.Empty,
|
|
||||||
["body"] = notification.Content ?? string.Empty
|
|
||||||
}
|
|
||||||
},
|
|
||||||
["sound"] = (notification.Priority > 0 ? "default" : null) ?? string.Empty,
|
|
||||||
["mutable-content"] = 1,
|
|
||||||
["meta"] = notification.Meta ?? new Dictionary<string, object>()
|
|
||||||
},
|
},
|
||||||
|
["sound"] = (notification.Priority > 0 ? "default" : null) ?? string.Empty,
|
||||||
|
["mutable-content"] = 1,
|
||||||
|
["meta"] = notification.Meta ?? new Dictionary<string, object>()
|
||||||
|
};
|
||||||
|
|
||||||
|
await _apns.SendAsync(
|
||||||
|
payload,
|
||||||
deviceToken: subscription.DeviceToken,
|
deviceToken: subscription.DeviceToken,
|
||||||
apnsId: notification.Id.ToString(),
|
apnsId: notification.Id.ToString(),
|
||||||
apnsPriority: notification.Priority,
|
apnsPriority: notification.Priority,
|
||||||
|
@ -18,7 +18,6 @@ public class ActivityReaderService(AppDatabase db, PostService ps)
|
|||||||
if (postsId.Count > 0)
|
if (postsId.Count > 0)
|
||||||
{
|
{
|
||||||
var posts = await db.Posts.Where(e => postsId.Contains(e.Id))
|
var posts = await db.Posts.Where(e => postsId.Contains(e.Id))
|
||||||
.Include(e => e.Publisher)
|
|
||||||
.Include(e => e.ThreadedPost)
|
.Include(e => e.ThreadedPost)
|
||||||
.Include(e => e.ForwardedPost)
|
.Include(e => e.ForwardedPost)
|
||||||
.Include(e => e.Attachments)
|
.Include(e => e.Attachments)
|
||||||
@ -27,6 +26,7 @@ public class ActivityReaderService(AppDatabase db, PostService ps)
|
|||||||
.FilterWithVisibility(currentUser, userFriends)
|
.FilterWithVisibility(currentUser, userFriends)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
posts = PostService.TruncatePostContent(posts);
|
posts = PostService.TruncatePostContent(posts);
|
||||||
|
posts = await ps.LoadPublishers(posts);
|
||||||
|
|
||||||
var reactionMaps = await ps.GetPostReactionMapBatch(postsId);
|
var reactionMaps = await ps.GetPostReactionMapBatch(postsId);
|
||||||
foreach (var post in posts)
|
foreach (var post in posts)
|
||||||
|
@ -54,7 +54,9 @@ public class Post : ModelBase
|
|||||||
|
|
||||||
[JsonIgnore] public NpgsqlTsVector SearchVector { get; set; } = null!;
|
[JsonIgnore] public NpgsqlTsVector SearchVector { get; set; } = null!;
|
||||||
|
|
||||||
|
public Guid PublisherId { get; set; }
|
||||||
public Publisher.Publisher Publisher { get; set; } = null!;
|
public Publisher.Publisher Publisher { get; set; } = null!;
|
||||||
|
|
||||||
public ICollection<PostReaction> Reactions { get; set; } = new List<PostReaction>();
|
public ICollection<PostReaction> Reactions { get; set; } = new List<PostReaction>();
|
||||||
public ICollection<PostTag> Tags { get; set; } = new List<PostTag>();
|
public ICollection<PostTag> Tags { get; set; } = new List<PostTag>();
|
||||||
public ICollection<PostCategory> Categories { get; set; } = new List<PostCategory>();
|
public ICollection<PostCategory> Categories { get; set; } = new List<PostCategory>();
|
||||||
|
@ -275,13 +275,12 @@ public class PostService(
|
|||||||
public async Task<List<Post>> LoadPublishers(List<Post> posts)
|
public async Task<List<Post>> LoadPublishers(List<Post> posts)
|
||||||
{
|
{
|
||||||
var publisherIds = posts
|
var publisherIds = posts
|
||||||
.Where(e => e.Publisher.AccountId != null)
|
|
||||||
.SelectMany<Post, Guid?>(e =>
|
.SelectMany<Post, Guid?>(e =>
|
||||||
[
|
[
|
||||||
e.Publisher.Id,
|
e.PublisherId,
|
||||||
e.RepliedPost?.Publisher.Id,
|
e.RepliedPost?.PublisherId,
|
||||||
e.ForwardedPost?.Publisher.Id,
|
e.ForwardedPost?.PublisherId,
|
||||||
e.ThreadedPost?.Publisher.Id
|
e.ThreadedPost?.PublisherId
|
||||||
])
|
])
|
||||||
.Where(e => e != null)
|
.Where(e => e != null)
|
||||||
.Distinct()
|
.Distinct()
|
||||||
@ -289,24 +288,24 @@ public class PostService(
|
|||||||
if (publisherIds.Count == 0) return posts;
|
if (publisherIds.Count == 0) return posts;
|
||||||
|
|
||||||
var publishers = await db.Publishers
|
var publishers = await db.Publishers
|
||||||
.Where(e => e.AccountId != null && publisherIds.Contains(e.AccountId.Value))
|
.Where(e => publisherIds.Contains(e.Id))
|
||||||
.ToDictionaryAsync(e => e.AccountId!.Value);
|
.ToDictionaryAsync(e => e.Id);
|
||||||
|
|
||||||
foreach (var post in posts)
|
foreach (var post in posts)
|
||||||
{
|
{
|
||||||
if (publishers.TryGetValue(post.Publisher.Id, out var publisher))
|
if (publishers.TryGetValue(post.PublisherId, out var publisher))
|
||||||
post.Publisher = publisher;
|
post.Publisher = publisher;
|
||||||
|
|
||||||
if (post.RepliedPost?.Publisher.Id != null &&
|
if (post.RepliedPost?.PublisherId != null &&
|
||||||
publishers.TryGetValue(post.RepliedPost.Publisher.Id, out var repliedPublisher))
|
publishers.TryGetValue(post.RepliedPost.PublisherId, out var repliedPublisher))
|
||||||
post.RepliedPost.Publisher = repliedPublisher;
|
post.RepliedPost.Publisher = repliedPublisher;
|
||||||
|
|
||||||
if (post.ForwardedPost?.Publisher.Id != null &&
|
if (post.ForwardedPost?.PublisherId != null &&
|
||||||
publishers.TryGetValue(post.ForwardedPost.Publisher.Id, out var forwardedPublisher))
|
publishers.TryGetValue(post.ForwardedPost.PublisherId, out var forwardedPublisher))
|
||||||
post.ForwardedPost.Publisher = forwardedPublisher;
|
post.ForwardedPost.Publisher = forwardedPublisher;
|
||||||
|
|
||||||
if (post.ThreadedPost?.Publisher.Id != null &&
|
if (post.ThreadedPost?.PublisherId != null &&
|
||||||
publishers.TryGetValue(post.ThreadedPost.Publisher.Id, out var threadedPublisher))
|
publishers.TryGetValue(post.ThreadedPost.PublisherId, out var threadedPublisher))
|
||||||
post.ThreadedPost.Publisher = threadedPublisher;
|
post.ThreadedPost.Publisher = threadedPublisher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user