✨ Actor data will include instance data
This commit is contained in:
@@ -32,8 +32,8 @@ public class SnFediverseActor : ModelBase
|
||||
public bool IsDiscoverable { get; set; } = true;
|
||||
|
||||
public Guid InstanceId { get; set; }
|
||||
public SnFediverseInstance Instance { get; set; } = null!;
|
||||
|
||||
[JsonIgnore] public SnFediverseInstance Instance { get; set; } = null!;
|
||||
[JsonIgnore] public ICollection<SnFediverseContent> Contents { get; set; } = [];
|
||||
[JsonIgnore] public ICollection<SnFediverseActivity> Activities { get; set; } = [];
|
||||
[JsonIgnore] public ICollection<SnFediverseRelationship> FollowingRelationships { get; set; } = [];
|
||||
|
||||
@@ -11,35 +11,19 @@ public class SnFediverseInstance : ModelBase
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
[MaxLength(256)]
|
||||
public string Domain { get; set; } = null!;
|
||||
|
||||
[MaxLength(512)]
|
||||
public string? Name { get; set; }
|
||||
|
||||
[MaxLength(4096)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
[MaxLength(2048)]
|
||||
public string? Software { get; set; }
|
||||
|
||||
[MaxLength(2048)]
|
||||
public string? Version { get; set; }
|
||||
|
||||
[Column(TypeName = "jsonb")]
|
||||
public Dictionary<string, object>? Metadata { get; set; }
|
||||
[MaxLength(256)] public string Domain { get; set; } = null!;
|
||||
[MaxLength(512)] public string? Name { get; set; }
|
||||
[MaxLength(4096)] public string? Description { get; set; }
|
||||
[MaxLength(2048)] public string? Software { get; set; }
|
||||
[MaxLength(2048)] public string? Version { get; set; }
|
||||
[Column(TypeName = "jsonb")] public Dictionary<string, object>? Metadata { get; set; }
|
||||
|
||||
public bool IsBlocked { get; set; } = false;
|
||||
public bool IsSilenced { get; set; } = false;
|
||||
|
||||
[MaxLength(2048)]
|
||||
public string? BlockReason { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public ICollection<SnFediverseActor> Actors { get; set; } = [];
|
||||
|
||||
[JsonIgnore]
|
||||
public ICollection<SnFediverseContent> Contents { get; set; } = [];
|
||||
[MaxLength(2048)] public string? BlockReason { get; set; }
|
||||
[JsonIgnore] public ICollection<SnFediverseActor> Actors { get; set; } = [];
|
||||
[JsonIgnore] public ICollection<SnFediverseContent> Contents { get; set; } = [];
|
||||
|
||||
public Instant? LastFetchedAt { get; set; }
|
||||
public Instant? LastActivityAt { get; set; }
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using DysonNetwork.Shared.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml.Linq;
|
||||
@@ -39,6 +38,7 @@ public partial class ActivityPubDiscoveryService(
|
||||
)
|
||||
{
|
||||
var localResults = await db.FediverseActors
|
||||
.Include(a => a.Instance)
|
||||
.Where(a =>
|
||||
a.Username.Contains(query) ||
|
||||
a.DisplayName != null && a.DisplayName.Contains(query))
|
||||
@@ -210,10 +210,15 @@ public partial class ActivityPubDiscoveryService(
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<SnFediverseActor?> StoreActorAsync(string actorUri, string username, string domain,
|
||||
string? webfingerAvatarUrl)
|
||||
private async Task<SnFediverseActor?> StoreActorAsync(
|
||||
string actorUri,
|
||||
string username,
|
||||
string domain,
|
||||
string? webfingerAvatarUrl
|
||||
)
|
||||
{
|
||||
var existingActor = await db.FediverseActors
|
||||
.Include(a => a.Instance)
|
||||
.FirstOrDefaultAsync(a => a.Uri == actorUri);
|
||||
|
||||
if (existingActor != null)
|
||||
@@ -250,9 +255,10 @@ public partial class ActivityPubDiscoveryService(
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
logger.LogInformation("Successfully stored actor from Webfinger: {Username}@{Domain}", username, domain);
|
||||
|
||||
|
||||
await FetchActorDataAsync(actor);
|
||||
|
||||
actor.Instance = instance;
|
||||
return actor;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -289,7 +295,7 @@ public partial class ActivityPubDiscoveryService(
|
||||
return;
|
||||
}
|
||||
|
||||
actor.Type = actorData.GetValueOrDefault("type")?.ToString();
|
||||
actor.Type = actorData.GetValueOrDefault("type")?.ToString() ?? "Person";
|
||||
actor.DisplayName = actorData.GetValueOrDefault("name")?.ToString();
|
||||
actor.Bio = actorData.GetValueOrDefault("summary")?.ToString();
|
||||
actor.InboxUri = actorData.GetValueOrDefault("inbox")?.ToString();
|
||||
|
||||
@@ -108,6 +108,7 @@ public class ActivityPubFollowController(
|
||||
|
||||
var actors = await db.FediverseRelationships
|
||||
.Include(r => r.TargetActor)
|
||||
.ThenInclude(a => a.Instance)
|
||||
.Where(r =>
|
||||
r.IsLocalActor &&
|
||||
r.LocalPublisherId == publisher.Id &&
|
||||
@@ -140,6 +141,7 @@ public class ActivityPubFollowController(
|
||||
|
||||
var actors = await db.FediverseRelationships
|
||||
.Include(r => r.Actor)
|
||||
.ThenInclude(a => a.Instance)
|
||||
.Where(r =>
|
||||
!r.IsLocalActor &&
|
||||
r.LocalPublisherId == publisher.Id &&
|
||||
|
||||
Reference in New Issue
Block a user