127 lines
3.1 KiB
C#
127 lines
3.1 KiB
C#
using PrivaPub.Models.ActivityPub.Extra;
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace PrivaPub.Models.ActivityPub
|
|
{
|
|
[JsonSerializable(typeof(ActivityPubObject))]
|
|
public partial class ActivityPubObject
|
|
{
|
|
[JsonPropertyName("@context")]
|
|
public List<object> Context => new()
|
|
{
|
|
"https://www.w3.org/ns/activitystreams",
|
|
"https://{0}/schemas/litepub-0.1.jsonld",
|
|
new ActivityPubContextLanguage()
|
|
};
|
|
|
|
[JsonPropertyName("id")]
|
|
public string Id { get; set; }
|
|
[JsonPropertyName("type")]
|
|
public ObjectType? Type { get; set; }
|
|
|
|
[JsonPropertyName("mediaType")]
|
|
public string MediaType { get; set; }
|
|
|
|
[JsonPropertyName("published")]
|
|
public DateTime? Published { get; set; }
|
|
|
|
[JsonPropertyName("updated")]
|
|
public DateTime? Updated { get; set; }
|
|
|
|
[JsonExtensionData]
|
|
public Dictionary<string, object> OtherData { get; set; }
|
|
|
|
[JsonPropertyName("source")]
|
|
public ActivityPubSource Source { get; set; }
|
|
|
|
//and part of link
|
|
[JsonPropertyName("to")]
|
|
public string[] To { get; set; }
|
|
[JsonPropertyName("cc")]
|
|
public string[] Cc { get; set; }
|
|
[JsonPropertyName("bcc")]
|
|
public string[] Bcc { get; set; }
|
|
[JsonPropertyName("bto")]
|
|
public string[] Bto { get; set; }
|
|
|
|
[JsonPropertyName("audience")]
|
|
public ActivityPubAudience Audience { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public MacroType MacroType => Type switch
|
|
{
|
|
ObjectType.Article or
|
|
ObjectType.Audio or
|
|
ObjectType.Document or
|
|
ObjectType.Event or
|
|
ObjectType.Image or
|
|
ObjectType.Note or
|
|
ObjectType.Page or
|
|
ObjectType.Place or
|
|
ObjectType.Profile or
|
|
ObjectType.Relationship or
|
|
ObjectType.Tombstone or
|
|
ObjectType.Video => MacroType.Object,
|
|
|
|
ObjectType.Mention => MacroType.Link,
|
|
|
|
ObjectType.Application or
|
|
ObjectType.Group or
|
|
ObjectType.Organization or
|
|
ObjectType.Person or
|
|
ObjectType.Service => MacroType.Actor,
|
|
|
|
ObjectType.Accept or
|
|
ObjectType.Add or
|
|
ObjectType.Announce or
|
|
ObjectType.Arrive or
|
|
ObjectType.Block or
|
|
ObjectType.Create or
|
|
ObjectType.Delete or
|
|
ObjectType.Dislike or
|
|
ObjectType.Flag or
|
|
ObjectType.Follow or
|
|
ObjectType.Ignore or
|
|
ObjectType.Invite or
|
|
ObjectType.Join or
|
|
ObjectType.Leave or
|
|
ObjectType.Like or
|
|
ObjectType.Listen or
|
|
ObjectType.Move or
|
|
ObjectType.Offer or
|
|
ObjectType.Question or
|
|
ObjectType.Reject or
|
|
ObjectType.Read or
|
|
ObjectType.Remove or
|
|
ObjectType.TentativeReject or
|
|
ObjectType.TentativeAccept or
|
|
ObjectType.Travel or
|
|
ObjectType.Undo or
|
|
ObjectType.Update or
|
|
ObjectType.View => MacroType.Activity,
|
|
|
|
ObjectType.Collection => MacroType.Collection,
|
|
ObjectType.CollectionPage => MacroType.CollectionPage,
|
|
ObjectType.OrderedCollection => MacroType.OrderedCollection,
|
|
ObjectType.OrderedCollectionPage => MacroType.OrderedCollectionPage,
|
|
|
|
_ => MacroType.Unknown
|
|
};
|
|
}
|
|
|
|
public class ActivityPubContextLanguage
|
|
{
|
|
[JsonPropertyName("@language")]
|
|
public string Language { get; set; } = "und";
|
|
}
|
|
|
|
public class ActivityPubSource
|
|
{
|
|
[JsonPropertyName("content")]
|
|
public string Content { get; set; }
|
|
[JsonPropertyName("mediaType")]
|
|
public string MediaType { get; set; }
|
|
}
|
|
}
|