Saving
This commit is contained in:
44
PrivaPub/Models/ActivityPub/ActivityPubActivity.cs
Normal file
44
PrivaPub/Models/ActivityPub/ActivityPubActivity.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using PrivaPub.Models.ActivityPub.Extra;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace PrivaPub.Models.ActivityPub
|
||||
{
|
||||
[JsonSerializable(typeof(ActivityPubActivity))]
|
||||
public class ActivityPubActivity : ActivityPubObject
|
||||
{
|
||||
[JsonPropertyName("actor")]
|
||||
public ActivityPubActor Actor { get; set; }
|
||||
|
||||
[JsonPropertyName("object")]
|
||||
public ActivityPubObject Object { get; set; }
|
||||
|
||||
[JsonPropertyName("target")]
|
||||
public ActivityPubObject Target { get; set; }
|
||||
|
||||
[JsonPropertyName("result")]
|
||||
public ActivityPubResult Result { get; set; }
|
||||
|
||||
[JsonPropertyName("origin")]
|
||||
public ActivityPubOrigin Origin { get; set; }
|
||||
|
||||
[JsonPropertyName("instrument")]
|
||||
public ActivityPubInstrument Instrument { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool NeedsObjectForInbox => Type is
|
||||
ObjectType.Create or
|
||||
ObjectType.Update or
|
||||
ObjectType.Delete or
|
||||
ObjectType.Follow or
|
||||
ObjectType.Add or
|
||||
ObjectType.Remove or
|
||||
ObjectType.Like or
|
||||
ObjectType.Block or
|
||||
ObjectType.Undo;
|
||||
[JsonIgnore]
|
||||
public bool NeedsTargetForInbox => Type is
|
||||
ObjectType.Add or
|
||||
ObjectType.Remove;
|
||||
}
|
||||
}
|
79
PrivaPub/Models/ActivityPub/ActivityPubActor.cs
Normal file
79
PrivaPub/Models/ActivityPub/ActivityPubActor.cs
Normal file
@ -0,0 +1,79 @@
|
||||
using PrivaPub.Models.ActivityPub.Extra;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace PrivaPub.Models.ActivityPub
|
||||
{
|
||||
[JsonSerializable(typeof(ActivityPubActor))]
|
||||
public class ActivityPubActor : ActivityPubObject
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public new ObjectType? Type => ObjectType.Person;
|
||||
|
||||
[JsonPropertyName("inbox")]
|
||||
public string Inbox { get; set; }
|
||||
[JsonPropertyName("outbox")]
|
||||
public string Outbox { get; set; }
|
||||
|
||||
[JsonPropertyName("url")]
|
||||
public string ProfileURL { get; set; }
|
||||
[JsonPropertyName("preferredUsername")]
|
||||
public string PreferredUsername { get; set; }
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
[JsonPropertyName("summary")]
|
||||
public string Summary { get; set; }
|
||||
[JsonPropertyName("icon")]
|
||||
public ActivityPubIcon Icon { get; set; }
|
||||
[JsonPropertyName("image")]
|
||||
public ActivityPubIcon Thumbnail { get; set; }
|
||||
|
||||
[JsonPropertyName("manuallyApprovesFollowers")]
|
||||
public bool ManuallyApprovesFollowers { get; set; } = false;
|
||||
[JsonPropertyName("discoverable")]
|
||||
public bool Discoverable { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("publicKey")]
|
||||
public ActivityPubPublicKey PublicKey { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("endpoints")]
|
||||
public ActivityPubActorEndpoints Endpoints { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("attachment")]
|
||||
public IEnumerable<ActivityPubAttachment> Attachment { get; set; } = Enumerable.Empty<ActivityPubAttachment>();
|
||||
|
||||
[JsonPropertyName("tag")]
|
||||
public IEnumerable<string> Tags => Enumerable.Empty<string>();
|
||||
}
|
||||
|
||||
public class ActivityPubAttachment
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public string Type { get; set; }
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
[JsonPropertyName("value")]
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class ActivityPubActorEndpoints
|
||||
{
|
||||
[JsonPropertyName("sharedInbox")]
|
||||
public string SharedInboxURL { get; set; }
|
||||
[JsonPropertyName("oauthAuthorizationEndpoint")]
|
||||
public string OAuthAuthorizationEndpoint { get; set; }
|
||||
|
||||
[JsonExtensionData]
|
||||
public Dictionary<string, object> OtherData { get; set; }
|
||||
}
|
||||
|
||||
public class ActivityPubPublicKey
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
public string Id { get; set; }
|
||||
[JsonPropertyName("owner")]
|
||||
public string Owner { get; set; }
|
||||
[JsonPropertyName("publicKeyPem")]
|
||||
public string PublicKeyPem { get; set; }
|
||||
}
|
||||
}
|
24
PrivaPub/Models/ActivityPub/ActivityPubCollection.cs
Normal file
24
PrivaPub/Models/ActivityPub/ActivityPubCollection.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace PrivaPub.Models.ActivityPub
|
||||
{
|
||||
[JsonSerializable(typeof(ActivityPubCollection))]
|
||||
public class ActivityPubCollection : ActivityPubObject
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public new ObjectType Type => ObjectType.Collection;
|
||||
|
||||
[JsonPropertyName("current")]
|
||||
public string RecentlyUpdatedItem { get; set; }
|
||||
[JsonPropertyName("first")]
|
||||
public string FirstItem { get; set; }
|
||||
[JsonPropertyName("last")]
|
||||
public string LastItem { get; set; }
|
||||
|
||||
[JsonPropertyName("items")]
|
||||
public List<ActivityPubLink> Items { get; set; }
|
||||
|
||||
[JsonPropertyName("totalItems")]
|
||||
public int TotalItems => Items.Count;
|
||||
}
|
||||
}
|
18
PrivaPub/Models/ActivityPub/ActivityPubCollectionPage.cs
Normal file
18
PrivaPub/Models/ActivityPub/ActivityPubCollectionPage.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace PrivaPub.Models.ActivityPub
|
||||
{
|
||||
[JsonSerializable(typeof(ActivityPubCollectionPage))]
|
||||
public class ActivityPubCollectionPage : ActivityPubCollection
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public new ObjectType Type => ObjectType.CollectionPage;
|
||||
|
||||
[JsonPropertyName("partOf")]
|
||||
public string BaseCollectionLink { get; set; }
|
||||
[JsonPropertyName("next")]
|
||||
public string NextCollectionLink { get; set; }
|
||||
[JsonPropertyName("prev")]
|
||||
public string PreviousCollectionLink { get; set; }
|
||||
}
|
||||
}
|
28
PrivaPub/Models/ActivityPub/ActivityPubLink.cs
Normal file
28
PrivaPub/Models/ActivityPub/ActivityPubLink.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace PrivaPub.Models.ActivityPub
|
||||
{
|
||||
[JsonSerializable(typeof(ActivityPubLink))]
|
||||
public class ActivityPubLink : ActivityPubObject
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
public new ObjectType Type { get; set; } = ObjectType.Mention;
|
||||
|
||||
[JsonPropertyName("href")]
|
||||
public string Href { get; set; }
|
||||
[JsonPropertyName("preview")]
|
||||
public string Preview { get; set; }
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
[JsonPropertyName("rel")]
|
||||
public string Relation { get; set; }
|
||||
[JsonPropertyName("hreflang")]
|
||||
public string HrefLang { get; set; }
|
||||
|
||||
[JsonPropertyName("height")]
|
||||
public int Height { get; set; }
|
||||
[JsonPropertyName("width")]
|
||||
public int Width { get; set; }
|
||||
}
|
||||
}
|
126
PrivaPub/Models/ActivityPub/ActivityPubObject.cs
Normal file
126
PrivaPub/Models/ActivityPub/ActivityPubObject.cs
Normal file
@ -0,0 +1,126 @@
|
||||
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; }
|
||||
}
|
||||
}
|
17
PrivaPub/Models/ActivityPub/ActivityPubOrderedCollection.cs
Normal file
17
PrivaPub/Models/ActivityPub/ActivityPubOrderedCollection.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace PrivaPub.Models.ActivityPub
|
||||
{
|
||||
[JsonSerializable(typeof(ActivityPubOrderedCollection))]
|
||||
public class ActivityPubOrderedCollection : ActivityPubCollection
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public new ObjectType Type => ObjectType.OrderedCollection;
|
||||
|
||||
[JsonPropertyName("orderedItems")]
|
||||
public List<ActivityPubLink> OrderedItems { get; set; }
|
||||
|
||||
[JsonPropertyName("totalItems")]
|
||||
public new int TotalItems => OrderedItems?.Count ?? default;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace PrivaPub.Models.ActivityPub
|
||||
{
|
||||
[JsonSerializable(typeof(ActivityPubOrderedCollectionPage))]
|
||||
public class ActivityPubOrderedCollectionPage : ActivityPubCollection
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public new ObjectType Type => ObjectType.OrderedCollectionPage;
|
||||
|
||||
[JsonPropertyName("partOf")]
|
||||
public string BaseCollectionLink { get; set; }
|
||||
[JsonPropertyName("next")]
|
||||
public string NextCollectionLink { get; set; }
|
||||
[JsonPropertyName("prev")]
|
||||
public string PreviousCollectionLink { get; set; }
|
||||
|
||||
[JsonPropertyName("startIndex")]
|
||||
public uint? StartIndex { get; set; }
|
||||
|
||||
[JsonPropertyName("orderedItems")]
|
||||
public List<ActivityPubLink> OrderedItems { get; set; }
|
||||
|
||||
[JsonPropertyName("totalItems")]
|
||||
public new int TotalItems => OrderedItems?.Count ?? default;
|
||||
}
|
||||
}
|
14
PrivaPub/Models/ActivityPub/ActivityPubTombstone.cs
Normal file
14
PrivaPub/Models/ActivityPub/ActivityPubTombstone.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace PrivaPub.Models.ActivityPub
|
||||
{
|
||||
[JsonSerializable(typeof(ActivityPubTombstone))]
|
||||
public class ActivityPubTombstone : ActivityPubObject
|
||||
{
|
||||
[JsonPropertyName("formerType")]
|
||||
public ObjectType FormerType { get; set; } = ObjectType.Unknown;
|
||||
|
||||
[JsonPropertyName("deleted")]
|
||||
public DateTime Deleted { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
}
|
13
PrivaPub/Models/ActivityPub/Extra/ActivityPubAudience.cs
Normal file
13
PrivaPub/Models/ActivityPub/Extra/ActivityPubAudience.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace PrivaPub.Models.ActivityPub.Extra
|
||||
{
|
||||
[JsonSerializable(typeof(ActivityPubPublicKey))]
|
||||
public class ActivityPubAudience
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public string Type { get; set; }
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
19
PrivaPub/Models/ActivityPub/Extra/ActivityPubIcon.cs
Normal file
19
PrivaPub/Models/ActivityPub/Extra/ActivityPubIcon.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace PrivaPub.Models.ActivityPub.Extra
|
||||
{
|
||||
[JsonSerializable(typeof(ActivityPubPublicKey))]
|
||||
public class ActivityPubIcon
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public string Type { get; set; }
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
[JsonPropertyName("url")]
|
||||
public string URL { get; set; }
|
||||
[JsonPropertyName("width")]
|
||||
public int Width { get; set; }
|
||||
[JsonPropertyName("height")]
|
||||
public int Height { get; set; }
|
||||
}
|
||||
}
|
13
PrivaPub/Models/ActivityPub/Extra/ActivityPubInstrument.cs
Normal file
13
PrivaPub/Models/ActivityPub/Extra/ActivityPubInstrument.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace PrivaPub.Models.ActivityPub.Extra
|
||||
{
|
||||
[JsonSerializable(typeof(ActivityPubPublicKey))]
|
||||
public class ActivityPubInstrument
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public string Type { get; set; }
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
13
PrivaPub/Models/ActivityPub/Extra/ActivityPubOrigin.cs
Normal file
13
PrivaPub/Models/ActivityPub/Extra/ActivityPubOrigin.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace PrivaPub.Models.ActivityPub.Extra
|
||||
{
|
||||
[JsonSerializable(typeof(ActivityPubPublicKey))]
|
||||
public class ActivityPubOrigin
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public string Type { get; set; }
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
13
PrivaPub/Models/ActivityPub/Extra/ActivityPubResult.cs
Normal file
13
PrivaPub/Models/ActivityPub/Extra/ActivityPubResult.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace PrivaPub.Models.ActivityPub.Extra
|
||||
{
|
||||
[JsonSerializable(typeof(ActivityPubPublicKey))]
|
||||
public class ActivityPubResult
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public string Type { get; set; }
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
17
PrivaPub/Models/ActivityPub/MacroType.cs
Normal file
17
PrivaPub/Models/ActivityPub/MacroType.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace PrivaPub.Models.ActivityPub
|
||||
{
|
||||
public enum MacroType
|
||||
{
|
||||
Object,
|
||||
Link,
|
||||
Actor,
|
||||
Activity,
|
||||
|
||||
Collection,
|
||||
OrderedCollection,
|
||||
CollectionPage,
|
||||
OrderedCollectionPage,
|
||||
|
||||
Unknown
|
||||
}
|
||||
}
|
63
PrivaPub/Models/ActivityPub/ObjectType.cs
Normal file
63
PrivaPub/Models/ActivityPub/ObjectType.cs
Normal file
@ -0,0 +1,63 @@
|
||||
namespace PrivaPub.Models.ActivityPub
|
||||
{
|
||||
public enum ObjectType
|
||||
{
|
||||
//Object types
|
||||
Article,
|
||||
Audio,
|
||||
Document,
|
||||
Event,
|
||||
Image,
|
||||
Note,
|
||||
Page,
|
||||
Place,
|
||||
Profile,
|
||||
Relationship,
|
||||
Tombstone,
|
||||
Video,
|
||||
//Link types
|
||||
Mention,
|
||||
//Actor
|
||||
Application,
|
||||
Group,
|
||||
Organization,
|
||||
Person,
|
||||
Service,
|
||||
//Activity
|
||||
Accept,
|
||||
Add,
|
||||
Announce,
|
||||
Arrive,
|
||||
Block,
|
||||
Create,
|
||||
Delete,
|
||||
Dislike,
|
||||
Flag,
|
||||
Follow,
|
||||
Ignore,
|
||||
Invite,
|
||||
Join,
|
||||
Leave,
|
||||
Like,
|
||||
Listen,
|
||||
Move,
|
||||
Offer,
|
||||
Question,
|
||||
Reject,
|
||||
Read,
|
||||
Remove,
|
||||
TentativeReject,
|
||||
TentativeAccept,
|
||||
Travel,
|
||||
Undo,
|
||||
Update,
|
||||
View,
|
||||
//Collections
|
||||
Collection,
|
||||
OrderedCollection,
|
||||
CollectionPage,
|
||||
OrderedCollectionPage,
|
||||
//NULL or default
|
||||
Unknown
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user