Added dbcontext and reference model deps
Reference KristofferStrube.ActivityStreams for models. His models are very similar to mine, if I put the work in I was planning to for the JSON converters and stuff. Why duplicate efforts when I can just submit PRs to the existing nuget package?
This commit is contained in:
parent
7c84fbc4c5
commit
2f152a656e
64 changed files with 256 additions and 2047 deletions
252
ActivityStore.cs
252
ActivityStore.cs
|
@ -1,11 +1,10 @@
|
|||
using ActivityPub.Utils;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.ComponentModel;
|
||||
using KristofferStrube.ActivityStreams;
|
||||
using OneOf;
|
||||
|
||||
using Object = KristofferStrube.ActivityStreams.Object;
|
||||
|
||||
namespace ActivityPub;
|
||||
using Activity = OneOf<Activity, IntransitiveActiviy>;
|
||||
|
||||
public enum ActivityStoreType {
|
||||
Inbox,
|
||||
|
@ -51,7 +50,7 @@ public class ActivityStore {
|
|||
/// </summary>
|
||||
/// <param name="newObject">The object to create</param>
|
||||
/// <returns>The create Activity, with the object inside.</returns>
|
||||
public Create WrapObjectInCreate(KristofferStrube.ActivityStreams.Object newObject) {
|
||||
public Create WrapObjectInCreate(IObject newObject) {
|
||||
Create newActivity = new Create() { // new create activity
|
||||
Actor = newObject.AttributedTo,
|
||||
To = newObject.To,
|
||||
|
@ -95,14 +94,13 @@ public class ActivityStore {
|
|||
/// <param name="runDelivery">A boolean indicating whether delivery tasks should be run (default true)</param>
|
||||
/// <returns>The newly inserted activity</returns>
|
||||
public Activity InsertActivity(Activity newActivity, bool runSideEffects = true, bool runDelivery = true) {
|
||||
List<Uri> recipients = runDelivery ? ExtractRecipients(newActivity) : new List<Uri>();
|
||||
|
||||
string id = NewId;
|
||||
string uriId = this.Url.AbsoluteRouteUrl(ActivityStoreType == ActivityStoreType.Inbox ? "GetInboxById" : "GetOutboxById", new { id }).ToLower();
|
||||
newActivity.Switch(
|
||||
_ => { _.Id = uriId; _.Bto = _.Bcc = null; },
|
||||
_ => { _.Id = uriId; _.Bto = _.Bcc = null; }
|
||||
);
|
||||
List<Uri> recipients = runDelivery ? ExtractRecipients(newActivity) : new List<Uri>();
|
||||
newActivity.Id = uriId;
|
||||
newActivity.Bto = newActivity.Bcc = null;
|
||||
|
||||
if (runSideEffects) newActivity = RunSideEffect(newActivity);
|
||||
|
||||
_activities[id] = newActivity;
|
||||
|
@ -112,28 +110,6 @@ public class ActivityStore {
|
|||
return newActivity;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Inserts an activity into the data store
|
||||
///// </summary>
|
||||
///// <param name="newActivity">The Activity to create</param>
|
||||
///// <param name="runSideEffects">A boolean indicating whether side effects should be run (default true)</param>
|
||||
///// <param name="runDelivery">A boolean indicating whether delivery tasks should be run (default true)</param>
|
||||
///// <returns>The newly inserted activity</returns>
|
||||
//public Activity InsertActivity(IntransitiveActiviy newActivity, bool runSideEffects = true, bool runDelivery = true) {
|
||||
// string id = NewId;
|
||||
// newActivity.Id = this.Url.AbsoluteRouteUrl(ActivityStoreType == ActivityStoreType.Inbox ? "GetInboxById" : "GetOutboxById", new { id }).ToLower();
|
||||
// if (runSideEffects) newActivity = RunSideEffect(newActivity);
|
||||
|
||||
// List<Uri> recipients = runDelivery ? ExtractRecipients(newActivity) : new List<Uri>();
|
||||
// newActivity.Bto = newActivity.Bcc = null;
|
||||
|
||||
// _activities[id] = newActivity;
|
||||
|
||||
// if (runDelivery) RunDelivery(newActivity, recipients);
|
||||
|
||||
// return newActivity;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Extract a list of recipients for an activity.
|
||||
/// clients must be aware that the server will only forward new Activities to addressees in the to, bto, cc, bcc, and audience fields.
|
||||
|
@ -168,74 +144,166 @@ public class ActivityStore {
|
|||
/// <returns>True on successful validation</returns>
|
||||
/// <exception cref="ArgumentException">Thown if the activity is invalid</exception>
|
||||
public bool ValidateActivity(Activity newActivity) {
|
||||
string? type = newActivity.Match(
|
||||
_ => _.Type?.FirstOrDefault(),
|
||||
_ => _.Type?.FirstOrDefault()
|
||||
);
|
||||
switch (type) {
|
||||
case "Create":
|
||||
case "Update":
|
||||
case "Delete":
|
||||
case "Follow":
|
||||
case "Add":
|
||||
case "Remove":
|
||||
case "Like":
|
||||
case "Dislike":
|
||||
case "Block":
|
||||
|
||||
if (!newActivity.IsT0 || newActivity.AsT0.Object == null) throw new ArgumentException($"'{type}' Activities require an 'Object' property");
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
if (!(newActivity is IntransitiveActivity) && newActivity.Object?.FirstOrDefault() == null)
|
||||
throw new ArgumentException($"'{newActivity.Type?.FirstOrDefault()}' Activities require an 'Object' property");
|
||||
return true;
|
||||
}
|
||||
|
||||
private Activity RunSideEffect(Activity newActivity) {
|
||||
string? type = newActivity.Match(
|
||||
_ => _.Type?.FirstOrDefault(),
|
||||
_ => _.Type?.FirstOrDefault()
|
||||
);
|
||||
switch (type) {
|
||||
case "Create":
|
||||
KristofferStrube.ActivityStreams.Object? newObject = newActivity.AsT0.Object.FirstOrDefault() as KristofferStrube.ActivityStreams.Object;
|
||||
if (newObject == null) throw new ArgumentException("'Create' Activities require an 'Object' property");
|
||||
newActivity.AsT0.Object = new List<IObjectOrLink> { (IObjectOrLink)ObjectStore.InsertObject(newObject) };
|
||||
break;
|
||||
|
||||
if (newActivity is IntransitiveActivity) {
|
||||
// intransitive activities go here
|
||||
IntransitiveActivity activity = (IntransitiveActivity)newActivity;
|
||||
if (activity is Question) return Question((Question)activity);
|
||||
else if (activity is Arrive) return Arrive((Arrive)activity);
|
||||
else if (activity is Travel) return Travel((Travel)activity);
|
||||
else throw new InvalidOperationException($"Activity type '{activity.Type?.FirstOrDefault()}' is unrecognized");
|
||||
|
||||
case "Update":
|
||||
case "Delete":
|
||||
case "Follow":
|
||||
case "Add":
|
||||
case "Remove":
|
||||
case "Like":
|
||||
case "Dislike":
|
||||
case "Block":
|
||||
case "Undo":
|
||||
|
||||
case "Accept":
|
||||
case "Announce":
|
||||
case "Arrive":
|
||||
case "Flag":
|
||||
case "Ignore":
|
||||
case "Invite":
|
||||
case "Join":
|
||||
case "Leave":
|
||||
case "Listen":
|
||||
case "Move":
|
||||
case "Offer":
|
||||
case "Question":
|
||||
case "Reject":
|
||||
case "Read":
|
||||
case "TentativeReject":
|
||||
case "TentativeAccept":
|
||||
case "Travel":
|
||||
case "View":
|
||||
throw new NotImplementedException();
|
||||
default:
|
||||
throw new InvalidEnumArgumentException($"Invalid Activity Type '{type}'");
|
||||
}
|
||||
else {
|
||||
Activity activity = newActivity;
|
||||
|
||||
return newActivity;
|
||||
if (activity is Create) return Create((Create)activity);
|
||||
else if (activity is Update) return Update((Update)activity);
|
||||
else if (activity is Delete) return Delete((Delete)activity);
|
||||
else if (activity is Follow) return Follow((Follow)activity);
|
||||
else if (activity is Add) return Add((Add)activity);
|
||||
else if (activity is Remove) return Remove((Remove)activity);
|
||||
else if (activity is Like) return Like((Like)activity);
|
||||
else if (activity is Dislike) return Dislike((Dislike)activity);
|
||||
else if (activity is Block) return Block((Block)activity);
|
||||
else if (activity is Undo) return Undo((Undo)activity);
|
||||
else if (activity is Accept) return Accept((Accept)activity);
|
||||
else if (activity is Announce) return Announce((Announce)activity);
|
||||
else if (activity is Flag) return Flag((Flag)activity);
|
||||
else if (activity is Ignore) return Ignore((Ignore)activity);
|
||||
else if (activity is Invite) return Invite((Invite)activity);
|
||||
else if (activity is Join) return Join((Join)activity);
|
||||
else if (activity is Leave) return Leave((Leave)activity);
|
||||
else if (activity is Listen) return Listen((Listen)activity);
|
||||
else if (activity is Move) return Move((Move)activity);
|
||||
else if (activity is Offer) return Offer((Offer)activity);
|
||||
else if (activity is Reject) return Reject((Reject)activity);
|
||||
else if (activity is Read) return Read((Read)activity);
|
||||
else if (activity is TentativeReject) return TentativeReject((TentativeReject)activity);
|
||||
else if (activity is TentativeAccept) return TentativeAccept((TentativeAccept)activity);
|
||||
else if (activity is View) return View((View)activity);
|
||||
else throw new InvalidOperationException($"Activity type '{activity.Type?.FirstOrDefault()}' is unrecognized");
|
||||
}
|
||||
}
|
||||
|
||||
private Create Create(Create activity) {
|
||||
Object? newObject = activity.Object?.FirstOrDefault() as Object;
|
||||
if (newObject == null) throw new ArgumentException("'Create' Activities require an 'Object' property");
|
||||
activity.Object = new List<IObjectOrLink> { ObjectStore.InsertObject(newObject) };
|
||||
return activity;
|
||||
}
|
||||
|
||||
private Update Update(Update activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Delete Delete(Delete activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Follow Follow(Follow activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Add Add(Add activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Remove Remove(Remove activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Like Like(Like activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Dislike Dislike(Dislike activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Block Block(Block activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Undo Undo(Undo activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Accept Accept(Accept activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Announce Announce(Announce activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Flag Flag(Flag activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Ignore Ignore(Ignore activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Invite Invite(Invite activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Join Join(Join activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Leave Leave(Leave activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Listen Listen(Listen activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Move Move(Move activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Offer Offer(Offer activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Reject Reject(Reject activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Read Read(Read activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private TentativeReject TentativeReject(TentativeReject activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private TentativeAccept TentativeAccept(TentativeAccept activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private View View(View activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Question Question(Question activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Arrive Arrive(Arrive activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Travel Travel(Travel activity) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
|
208
BaseActivity.cs
208
BaseActivity.cs
|
@ -1,208 +0,0 @@
|
|||
using KristofferStrube.ActivityStreams;
|
||||
using KristofferStrube.ActivityStreams.JsonConverters;
|
||||
using KristofferStrube.ActivityStreams.JsonLD;
|
||||
using OneOf;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ActivityPub;
|
||||
public class BaseActivity : OneOfBase<Activity, IntransitiveActiviy>, IObject {
|
||||
|
||||
protected BaseActivity(OneOf<Activity, IntransitiveActiviy> _) : base(_) { }
|
||||
|
||||
public static implicit operator BaseActivity(Activity _) => new BaseActivity(_);
|
||||
public static implicit operator BaseActivity(IntransitiveActiviy _) => new BaseActivity(_);
|
||||
|
||||
public static explicit operator Activity(BaseActivity _) => _.Match(a => a, ia => throw new InvalidCastException());
|
||||
public static explicit operator IntransitiveActiviy(BaseActivity _) => _.Match(a => throw new InvalidCastException(), ia => ia);
|
||||
|
||||
public bool IsIntransitive { get => IsT1; }
|
||||
|
||||
/// <summary>
|
||||
/// Describes one or more entities that either performed or are expected to perform the activity. Any single activity can have multiple actors. The actor may be specified using an indirect Link.
|
||||
/// </summary>
|
||||
public IEnumerable<IObjectOrLink>? Actor {
|
||||
get => Match(a => a.Actor, ia => ia.Actor);
|
||||
set => Switch(a => a.Actor = value, ia => ia.Actor = value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Describes an object of any kind. The Object type serves as the base type for most of the other kinds of objects defined in the Activity Vocabulary, including other Core types such as Activity, IntransitiveActivity, Collection and OrderedCollection.
|
||||
/// </summary>
|
||||
public IEnumerable<IObjectOrLink>? Object {
|
||||
get => Match(a => a.Object, ia => throw new InvalidOperationException("Activity is Intransitive"));
|
||||
set => Switch(a => a.Object = value, ia => throw new InvalidOperationException("Activity is Intransitive"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Describes the indirect object, or target, of the activity. The precise meaning of the target is largely dependent on the type of action being described but will often be the object of the English preposition "to". For instance, in the activity "John added a movie to his wishlist", the target of the activity is John's wishlist. An activity can have more than one target.
|
||||
/// </summary>
|
||||
public IEnumerable<IObjectOrLink>? Target {
|
||||
get => Match(a => a.Target, ia => ia.Target);
|
||||
set => Switch(a => a.Target = value, ia => ia.Target = value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Describes the result of the activity. For instance, if a particular action results in the creation of a new resource, the result property can be used to describe that new resource.
|
||||
/// </summary>
|
||||
public IEnumerable<IObjectOrLink>? Result {
|
||||
get => Match(a => a.Result, ia => ia.Result);
|
||||
set => Switch(a => a.Result = value, ia => ia.Result = value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Describes an indirect object of the activity from which the activity is directed. The precise meaning of the origin is the object of the English preposition "from". For instance, in the activity "John moved an item to List B from List A", the origin of the activity is "List A".
|
||||
/// </summary>
|
||||
public IEnumerable<IObjectOrLink>? Origin {
|
||||
get => Match(a => a.Origin, ia => ia.Origin);
|
||||
set => Switch(a => a.Origin = value, ia => ia.Origin = value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Identifies one or more objects used (or to be used) in the completion of an Activity.
|
||||
/// </summary>
|
||||
public IEnumerable<IObjectOrLink>? Instrument {
|
||||
get => Match(a => a.Instrument, ia => ia.Instrument);
|
||||
set => Switch(a => a.Instrument = value, ia => ia.Instrument = value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public IEnumerable<IObjectOrLink>? Attachment {
|
||||
get => Match(a => a.Attachment, ia => ia.Attachment);
|
||||
set => Switch(a => a.Attachment = value, ia => ia.Attachment = value);
|
||||
}
|
||||
public IEnumerable<IObjectOrLink>? AttributedTo {
|
||||
get => Match(a => a.AttributedTo, ia => ia.AttributedTo);
|
||||
set => Switch(a => a.AttributedTo = value, ia => ia.AttributedTo = value);
|
||||
}
|
||||
public IEnumerable<IObjectOrLink>? Audience {
|
||||
get => Match(a => a.Audience, ia => ia.Audience);
|
||||
set => Switch(a => a.Audience = value, ia => ia.Audience = value);
|
||||
}
|
||||
public IEnumerable<IObjectOrLink>? Bcc {
|
||||
get => Match(a => a.Bcc, ia => ia.Bcc);
|
||||
set => Switch(a => a.Bcc = value, ia => ia.Bcc = value);
|
||||
}
|
||||
public IEnumerable<IObjectOrLink>? Bto {
|
||||
get => Match(a => a.Bto, ia => ia.Bto);
|
||||
set => Switch(a => a.Bto = value, ia => ia.Bto = value);
|
||||
}
|
||||
public IEnumerable<IObjectOrLink>? Cc {
|
||||
get => Match(a => a.Cc, ia => ia.Cc);
|
||||
set => Switch(a => a.Cc = value, ia => ia.Cc = value);
|
||||
}
|
||||
public IEnumerable<IObjectOrLink>? Context {
|
||||
get => Match(a => a.Context, ia => ia.Context);
|
||||
set => Switch(a => a.Context = value, ia => ia.Context = value);
|
||||
}
|
||||
public IEnumerable<IObjectOrLink>? Generator {
|
||||
get => Match(a => a.Generator, ia => ia.Generator);
|
||||
set => Switch(a => a.Generator = value, ia => ia.Generator = value);
|
||||
}
|
||||
public IEnumerable<IImageOrLink>? Icon {
|
||||
get => Match(a => a.Icon, ia => ia.Icon);
|
||||
set => Switch(a => a.Icon = value, ia => ia.Icon = value);
|
||||
}
|
||||
public IEnumerable<IImageOrLink>? Image {
|
||||
get => Match(a => a.Image, ia => ia.Image);
|
||||
set => Switch(a => a.Image = value, ia => ia.Image = value);
|
||||
}
|
||||
public IEnumerable<IObjectOrLink>? InReplyTo {
|
||||
get => Match(a => a.InReplyTo, ia => ia.InReplyTo);
|
||||
set => Switch(a => a.InReplyTo = value, ia => ia.InReplyTo = value);
|
||||
}
|
||||
public IEnumerable<IObjectOrLink>? Location {
|
||||
get => Match(a => a.Location, ia => ia.Location);
|
||||
set => Switch(a => a.Location = value, ia => ia.Location = value);
|
||||
}
|
||||
public Collection? Replies {
|
||||
get => Match(a => a.Replies, ia => ia.Replies);
|
||||
set => Switch(a => a.Replies = value, ia => ia.Replies = value);
|
||||
}
|
||||
public IEnumerable<IObjectOrLink>? Tag {
|
||||
get => Match(a => a.Tag, ia => ia.Tag);
|
||||
set => Switch(a => a.Tag = value, ia => ia.Tag = value);
|
||||
}
|
||||
public IEnumerable<IObjectOrLink>? To {
|
||||
get => Match(a => a.To, ia => ia.To);
|
||||
set => Switch(a => a.To = value, ia => ia.To = value);
|
||||
}
|
||||
public IEnumerable<ILink>? Url {
|
||||
get => Match(a => a.Url, ia => ia.Url);
|
||||
set => Switch(a => a.Url = value, ia => ia.Url = value);
|
||||
}
|
||||
public IEnumerable<string>? Content {
|
||||
get => Match(a => a.Content, ia => ia.Content);
|
||||
set => Switch(a => a.Content = value, ia => ia.Content = value);
|
||||
}
|
||||
public IEnumerable<IDictionary<string, string>>? ContentMap {
|
||||
get => Match(a => a.ContentMap, ia => ia.ContentMap);
|
||||
set => Switch(a => a.ContentMap = value, ia => ia.ContentMap = value);
|
||||
}
|
||||
public IEnumerable<IDictionary<string, string>>? NameMap {
|
||||
get => Match(a => a.NameMap, ia => ia.NameMap);
|
||||
set => Switch(a => a.NameMap = value, ia => ia.NameMap = value);
|
||||
}
|
||||
public TimeSpan? Duration {
|
||||
get => Match(a => a.Duration, ia => ia.Duration);
|
||||
set => Switch(a => a.Duration = value, ia => ia.Duration = value);
|
||||
}
|
||||
public DateTime? EndTime {
|
||||
get => Match(a => a.EndTime, ia => ia.EndTime);
|
||||
set => Switch(a => a.EndTime = value, ia => ia.EndTime = value);
|
||||
}
|
||||
public DateTime? Published {
|
||||
get => Match(a => a.Published, ia => ia.Published);
|
||||
set => Switch(a => a.Published = value, ia => ia.Published = value);
|
||||
}
|
||||
public DateTime? StartTime {
|
||||
get => Match(a => a.Published, ia => ia.Published);
|
||||
set => Switch(a => a.Published = value, ia => ia.Published = value);
|
||||
}
|
||||
public IEnumerable<string>? Summary {
|
||||
get => Match(a => a.Summary, ia => ia.Summary);
|
||||
set => Switch(a => a.Summary = value, ia => ia.Summary = value);
|
||||
}
|
||||
public IEnumerable<IDictionary<string, string>>? SummaryMap {
|
||||
get => Match(a => a.SummaryMap, ia => ia.SummaryMap);
|
||||
set => Switch(a => a.SummaryMap = value, ia => ia.SummaryMap = value);
|
||||
}
|
||||
public DateTime? Updated {
|
||||
get => Match(a => a.Updated, ia => ia.Updated);
|
||||
set => Switch(a => a.Updated = value, ia => ia.Updated = value);
|
||||
}
|
||||
public Source? Source {
|
||||
get => Match(a => a.Source, ia => ia.Source);
|
||||
set => Switch(a => a.Source = value, ia => ia.Source = value);
|
||||
}
|
||||
public Dictionary<string, JsonElement>? ExtensionData {
|
||||
get => Match(a => a.ExtensionData, ia => ia.ExtensionData);
|
||||
set => Switch(a => a.ExtensionData = value, ia => ia.ExtensionData = value);
|
||||
}
|
||||
public string? Id {
|
||||
get => Match(a => a.Id, ia => ia.Id);
|
||||
set => Switch(a => a.Id = value, ia => ia.Id = value);
|
||||
}
|
||||
public IEnumerable<ITermDefinition>? JsonLDContext {
|
||||
get => Match(a => a.JsonLDContext, ia => ia.JsonLDContext);
|
||||
set => Switch(a => a.JsonLDContext = value, ia => ia.JsonLDContext = value);
|
||||
}
|
||||
public IEnumerable<string>? Type {
|
||||
get => Match(a => a.Type, ia => ia.Type);
|
||||
set => Switch(a => a.Type = value, ia => ia.Type = value);
|
||||
}
|
||||
public string? MediaType {
|
||||
get => Match(a => a.MediaType, ia => ia.MediaType);
|
||||
set => Switch(a => a.MediaType = value, ia => ia.MediaType = value);
|
||||
}
|
||||
public IEnumerable<string>? Name {
|
||||
get => Match(a => a.Name, ia => ia.Name);
|
||||
set => Switch(a => a.Name = value, ia => ia.Name = value);
|
||||
}
|
||||
public IEnumerable<IObjectOrLink>? Preview {
|
||||
get => Match(a => a.Preview, ia => ia.Preview);
|
||||
set => Switch(a => a.Preview = value, ia => ia.Preview = value);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
using ActivityPub.Utils;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using KristofferStrube;
|
||||
using KristofferStrube.ActivityStreams;
|
||||
using OneOf;
|
||||
|
||||
using Object = KristofferStrube.ActivityStreams.Object;
|
||||
|
||||
namespace ActivityPub.Controllers;
|
||||
|
||||
|
@ -40,13 +40,11 @@ public class OutboxController : ControllerBase {
|
|||
|
||||
ActivityStore Outbox = new(this.Url, ActivityStoreType.Outbox);
|
||||
|
||||
if(newObjectOrLink == null || !(newObjectOrLink is KristofferStrube.ActivityStreams.Object))
|
||||
if(newObjectOrLink == null || !(newObjectOrLink is Object))
|
||||
return this.BadRequest($"No valid Activity or Object found in the request body");
|
||||
|
||||
OneOf<Activity, IntransitiveActiviy> newActivity =
|
||||
(newObjectOrLink is Activity) ? (Activity)newObjectOrLink
|
||||
: (newObjectOrLink is IntransitiveActiviy) ? (IntransitiveActiviy)newObjectOrLink
|
||||
: Outbox.WrapObjectInCreate(newObjectOrLink as KristofferStrube.ActivityStreams.Object);
|
||||
Activity newActivity = (newObjectOrLink is Activity) ? (Activity)newObjectOrLink
|
||||
: Outbox.WrapObjectInCreate(newObjectOrLink as Object);
|
||||
|
||||
//// Validate the activity
|
||||
//try {
|
||||
|
@ -57,6 +55,7 @@ public class OutboxController : ControllerBase {
|
|||
//}
|
||||
|
||||
newActivity = Outbox.InsertActivity(newActivity);
|
||||
|
||||
return Created(newActivity.Id, newActivity);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,654 +0,0 @@
|
|||
//namespace ActivityPub;
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// A class to create ActivityPub Objects/Activities/etc from an incoming dynamic object
|
||||
///// </summary>
|
||||
//public static class DynamicObjectFactory {
|
||||
// public static ObjectOrLink? NewObjectOrLink(dynamic that) {
|
||||
// if (that is string) return (ObjectOrLink) new Uri((string)that);
|
||||
// if (that is Uri) return (ObjectOrLink)that;
|
||||
|
||||
// string type = that.Type;
|
||||
// if (type == null) return null; // TODO: throw exception?
|
||||
// type = Types.Normalize(type);
|
||||
|
||||
// ObjectOrLink newObject;
|
||||
// switch (type) {
|
||||
// // https://www.w3.org/TR/activitystreams-vocabulary/#types
|
||||
// case "Object": return (ObjectOrLink)NewObject(that);
|
||||
// case "Link": return (ObjectOrLink)NewLink(that);
|
||||
// case "Activity": return (ObjectOrLink)NewActivity(that);
|
||||
// case "IntransitiveActivity": return (ObjectOrLink)NewIntransitiveActivity(that);
|
||||
// case "Collection": return (ObjectOrLink)NewCollection(that);
|
||||
// case "OrderedCollection": return (ObjectOrLink)NewOrderedCollection(that);
|
||||
// case "CollectionPage": return (ObjectOrLink)NewCollectionPage(that);
|
||||
// case "OrderedCollectionPage": return (ObjectOrLink)NewOrderedCollectionPage(that);
|
||||
|
||||
// // this is technically not an ActivityStreams type, but it's useful to exist
|
||||
// case "Actor": return (ObjectOrLink)NewActor(that);
|
||||
|
||||
// // https://www.w3.org/TR/activitystreams-vocabulary/#activity-types
|
||||
// case "Accept": return (ObjectOrLink)NewAccept(that);
|
||||
// case "Add": return (ObjectOrLink)NewAdd(that);
|
||||
// case "Announce": return (ObjectOrLink)NewAnnounce(that);
|
||||
// case "Arrive": return (ObjectOrLink)NewArrive(that);
|
||||
// case "Block": return (ObjectOrLink)NewBlock(that);
|
||||
// case "Create": return (ObjectOrLink)NewCreate(that);
|
||||
// case "Delete": return (ObjectOrLink)NewDelete(that);
|
||||
// case "Dislike": return (ObjectOrLink)NewDislike(that);
|
||||
// case "Flag": return (ObjectOrLink)NewFlag(that);
|
||||
// case "Follow": return (ObjectOrLink)NewFollow(that);
|
||||
// case "Ignore": return (ObjectOrLink)NewIgnore(that);
|
||||
// case "Invite": return (ObjectOrLink)NewInvite(that);
|
||||
// case "Join": return (ObjectOrLink)NewJoin(that);
|
||||
// case "Leave": return (ObjectOrLink)NewLeave(that);
|
||||
// case "Like": return (ObjectOrLink)NewLike(that);
|
||||
// case "Listen": return (ObjectOrLink)NewListen(that);
|
||||
// case "Move": return (ObjectOrLink)NewMove(that);
|
||||
// case "Offer": return (ObjectOrLink)NewOffer(that);
|
||||
// case "Question": return (ObjectOrLink)NewQuestion(that);
|
||||
// case "Reject": return (ObjectOrLink)NewReject(that);
|
||||
// case "Read": return (ObjectOrLink)NewRead(that);
|
||||
// case "Remove": return (ObjectOrLink)NewRemove(that);
|
||||
// case "TentativeReject": return (ObjectOrLink)NewTentativeReject(that);
|
||||
// case "TentativeAccept": return (ObjectOrLink)NewTentativeAccept(that);
|
||||
// case "Travel": return (ObjectOrLink)NewTravel(that);
|
||||
// case "Undo": return (ObjectOrLink)NewUndo(that);
|
||||
// case "Update": return (ObjectOrLink)NewUpdate(that);
|
||||
// case "View": return (ObjectOrLink)NewView(that);
|
||||
|
||||
// // https://www.w3.org/TR/activitystreams-vocabulary/#actor-types
|
||||
// case "Application": return (ObjectOrLink)NewApplication(that);
|
||||
// case "Group": return (ObjectOrLink)NewGroup(that);
|
||||
// case "Organization": return (ObjectOrLink)NewOrganization(that);
|
||||
// case "Person": return (ObjectOrLink)NewPerson(that);
|
||||
// case "Service": return (ObjectOrLink)NewService(that);
|
||||
|
||||
// // https://www.w3.org/TR/activitystreams-vocabulary/#object-types
|
||||
// case "Article": return (ObjectOrLink)NewArticle(that);
|
||||
// case "Audio": return (ObjectOrLink)NewAudio(that);
|
||||
// case "Document": return (ObjectOrLink)NewDocument(that);
|
||||
// case "Event": return (ObjectOrLink)NewEvent(that);
|
||||
// case "Image": return (ObjectOrLink)NewImage(that);
|
||||
// case "Note": return (ObjectOrLink)NewNote(that);
|
||||
// case "Page": return (ObjectOrLink)NewPage(that);
|
||||
// case "Place": return (ObjectOrLink)NewPlace(that);
|
||||
// case "Profile": return (ObjectOrLink)NewProfile(that);
|
||||
// case "Relationship": return (ObjectOrLink)NewRelationship(that);
|
||||
// case "Tombstone": return (ObjectOrLink)NewTombstone(that);
|
||||
// case "Video": return (ObjectOrLink)NewVideo(that);
|
||||
// case "Mention": return (ObjectOrLink)NewMention(that);
|
||||
|
||||
// default: return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
// public static ListOrLink<T>? NewListOrLink<T>(dynamic that) where T : KristofferStrube.ActivityStreams.Object, new() {
|
||||
// if (that == null) return null;
|
||||
|
||||
// if (that is string) return (ListOrLink<T>)new Uri((string)that);
|
||||
// if (that is Uri) return (ListOrLink<T>)that;
|
||||
|
||||
// if (that is IEnumerable<dynamic>)
|
||||
// return (ListOrLink<T>)(that as IEnumerable<dynamic>).Select(x => NewObjectOrLink(x)).Cast<GenericObjectOrLink<T>>().ToList();
|
||||
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// public static DateTimeOffset? NewDate(dynamic that) {
|
||||
// DateTimeOffset result;
|
||||
// if(DateTimeOffset.TryParse(that, out result)) { return result; }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// public static Object NewObject(dynamic that, Object? self = null) {
|
||||
// if(self == null) self = new Object();
|
||||
|
||||
// self.Id = new Uri(that.Id);
|
||||
// // self.Type = that.Type; // not necessary
|
||||
// self.Attachment = NewObjectOrLink(that.Attachment);
|
||||
// self.AttributedTo = NewObjectOrLink(that.AttributedTo);
|
||||
// self.Audience = NewObjectOrLink(that.Audience);
|
||||
// self.Content = that.Content;
|
||||
// self.Source = NewObjectOrLink(that.Source);
|
||||
// self.Context = NewObjectOrLink(that.Id);
|
||||
// self.Name = that.Name;
|
||||
// self.EndTime = NewDate(that.EndTime);
|
||||
// self.Generator = NewObjectOrLink(that.Generator);
|
||||
// self.Icon = NewObjectOrLink(that.Icon);
|
||||
// self.Image = NewObjectOrLink(that.Image);
|
||||
// self.InReplyTo = NewObjectOrLink(that.InReplyTo);
|
||||
// self.Location = NewObjectOrLink(that.Location);
|
||||
// self.Preview = NewObjectOrLink(that.Preview);
|
||||
// self.Published = NewDate(that.Published);
|
||||
// self.Replies = NewObjectOrLink(that.Replies);
|
||||
// self.StartTime = NewDate(that.StartTime);
|
||||
// self.Summary = that.Summary;
|
||||
// self.Tag = NewObjectOrLink(that.Tag);
|
||||
// self.Updated = NewDate(that.Id);
|
||||
// self.Url = (that.Url == null || that.Url is Uri) ? that.Url : new Uri(that.Url);
|
||||
// self.To = NewListOrLink<Object>(that.To);
|
||||
// self.Bto = NewListOrLink<Object>(that.Bto);
|
||||
// self.Cc = NewListOrLink<Object>(that.Cc);
|
||||
// self.Bcc = NewListOrLink<Object>(that.Bcc);
|
||||
// self.MediaType = that.MediaType;
|
||||
// self.Duration = that.Duration;
|
||||
// self.Likes = NewListOrLink<Object>(that.Likes);
|
||||
// self.Shares = NewListOrLink<Object>(that.Shares);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Link NewLink(dynamic that, Link? self = null) {
|
||||
// if (self == null) self = new Link();
|
||||
|
||||
// self.Id = new Uri(that.Id);
|
||||
// // self.Type = that.Type; // not necessary
|
||||
|
||||
// self.Rel = that.Rel;
|
||||
// self.MediaType = that.MediaType;
|
||||
// self.Name = that.Name;
|
||||
// self.Hreflang = that.Hreflang;
|
||||
// self.Height = that.Height;
|
||||
// self.Width = that.Width;
|
||||
// self.Preview = NewObjectOrLink(that.Preview);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Mention NewMention(dynamic that, Mention? self = null) {
|
||||
// if(self == null) self = new Mention();
|
||||
|
||||
// self = NewLink(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static IntransitiveActivity NewIntransitiveActivity(dynamic that, IntransitiveActivity? self = null) {
|
||||
// if (self == null) self = new IntransitiveActivity();
|
||||
|
||||
// self = NewObject(that, self);
|
||||
|
||||
// self.Actor = NewObjectOrLink(that.Actor);
|
||||
// self.Target = NewObjectOrLink(that.Target);
|
||||
// self.Result = NewObjectOrLink(that.Result);
|
||||
// self.Origin = NewObjectOrLink(that.Origin);
|
||||
// self.Instrument = NewObjectOrLink(that.Instrument);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Activity NewActivity(dynamic that, Activity? self = null) {
|
||||
// if (self == null) self = new Activity();
|
||||
|
||||
// self = NewIntransitiveActivity(that, self);
|
||||
|
||||
// self.Object = NewObjectOrLink(that.Object);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Collection NewCollection(dynamic that, Collection? self = null) {
|
||||
// if (self == null) self = new Collection();
|
||||
|
||||
// self = NewObject(that, self);
|
||||
|
||||
// self.TotalItems = that.TotalItems;
|
||||
// self.Current = NewObjectOrLink(that.Current);
|
||||
// self.First = NewObjectOrLink(that.First);
|
||||
// self.Last = NewObjectOrLink(that.Last);
|
||||
// self.Items = NewObjectOrLink(that.Items);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Collection NewOrderedCollection(dynamic that, OrderedCollection? self = null) {
|
||||
// if (self == null) self = new OrderedCollection();
|
||||
|
||||
// self = NewCollection(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Collection NewCollectionPage(dynamic that, CollectionPage? self = null) {
|
||||
// if (self == null) self = new CollectionPage();
|
||||
|
||||
// self = NewCollection(that, self);
|
||||
|
||||
// self.PartOf = NewObjectOrLink(that.PartOf);
|
||||
// self.Next = NewObjectOrLink(that.Next);
|
||||
// self.Prev = NewObjectOrLink(that.Prev);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Collection NewOrderedCollectionPage(dynamic that, OrderedCollectionPage? self = null) {
|
||||
// if (self == null) self = new OrderedCollectionPage();
|
||||
|
||||
// self = NewCollectionPage(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static OneOf<Uri, Endpoints>? NewEndpointsOrUri(dynamic that) {
|
||||
// if (that == null) return null;
|
||||
|
||||
// if (that is string) return (OneOf<Uri, Endpoints>)new Uri((string)that);
|
||||
// if (that is Uri) return (OneOf<Uri, Endpoints>)that;
|
||||
|
||||
// return NewEndpoints(that);
|
||||
// }
|
||||
|
||||
// public static Endpoints NewEndpoints(dynamic that, Endpoints? self = null) {
|
||||
// if (self == null) self = new Endpoints();
|
||||
|
||||
// self.ProxyUrl = new Uri(that.ProxyUrl);
|
||||
// self.OauthAuthorizationEndpoint = new Uri(that.OauthAuthorizationEndpoint);
|
||||
// self.OauthTokenEndpoint = new Uri(that.OauthTokenEndpoint);
|
||||
// self.ProvideClientKey = new Uri(that.ProvideClientKey);
|
||||
// self.SignClientKey = new Uri(that.SignClientKey);
|
||||
// self.SharedInbox = new Uri(that.SharedInbox);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Actor NewActor(dynamic that, Actor? self = null) {
|
||||
// if (self == null) self = new Actor();
|
||||
|
||||
// self = NewObject(that, self);
|
||||
|
||||
// self.Inbox = NewObjectOrLink(that.Inbox);
|
||||
// self.Outbox = NewObjectOrLink(that.Outbox);
|
||||
// self.Following = NewObjectOrLink(that.Following);
|
||||
// self.Followers = NewObjectOrLink(that.Followers);
|
||||
// self.Liked = NewObjectOrLink(that.Liked);
|
||||
// self.Streams = NewListOrLink<Collection>(that.Streams);
|
||||
// self.PreferredUsername = that.PreferredUsername;
|
||||
// self.Endpoints = NewEndpointsOrUri(that.Endpoints);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Article NewArticle(dynamic that, Article? self = null) {
|
||||
// if (self == null) self = new Article();
|
||||
|
||||
// self = NewObject(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Document NewDocument(dynamic that, Document? self = null) {
|
||||
// if (self == null) self = new Document();
|
||||
|
||||
// self = NewObject(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Audio NewAudio(dynamic that, Audio? self = null) {
|
||||
// if (self == null) self = new Audio();
|
||||
|
||||
// self = NewDocument(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Event NewEvent(dynamic that, Event? self = null) {
|
||||
// if (self == null) self = new Event();
|
||||
|
||||
// self = NewObject(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Image NewImage(dynamic that, Image? self = null) {
|
||||
// if (self == null) self = new Image();
|
||||
|
||||
// self = NewDocument(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Note NewNote(dynamic that, Note? self = null) {
|
||||
// if (self == null) self = new Note();
|
||||
|
||||
// self = NewObject(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Page NewPage(dynamic that, Page? self = null) {
|
||||
// if (self == null) self = new Page();
|
||||
|
||||
// self = NewDocument(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Place NewPlace(dynamic that, Place? self = null) {
|
||||
// if (self == null) self = new Place();
|
||||
|
||||
// self = NewObject(that, self);
|
||||
// self.Accuracy = that.Accuracy;
|
||||
// self.Altitude = that.Altitude;
|
||||
// self.Latitude = that.Latitude;
|
||||
// self.Longitude = that.Longitude;
|
||||
// self.Radius = that.Radius;
|
||||
// self.Units = that.Units;
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Profile NewProfile(dynamic that, Profile? self = null) {
|
||||
// if (self == null) self = new Profile();
|
||||
|
||||
// self = NewObject(that, self);
|
||||
// self.Describes = NewObjectOrLink(that.Describes);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Relationship NewRelationship(dynamic that, Relationship? self = null) {
|
||||
// if (self == null) self = new Relationship();
|
||||
|
||||
// self = NewObject(that, self);
|
||||
// self.Subject = NewObjectOrLink(that.Subject);
|
||||
// self.Object = NewObjectOrLink(that.Object);
|
||||
// self.relationship = that.relationship;
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Tombstone NewTombstone(dynamic that, Tombstone? self = null) {
|
||||
// if (self == null) self = new Tombstone();
|
||||
|
||||
// self = NewObject(that, self);
|
||||
// self.FormerType = that.FormerType;
|
||||
// self.Deleted = NewDate(that.Deleted);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Video NewVideo(dynamic that, Video? self = null) {
|
||||
// if (self == null) self = new Video();
|
||||
|
||||
// self = NewDocument(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Application NewApplication(dynamic that, Application? self = null) {
|
||||
// if (self == null) self = new Application();
|
||||
|
||||
// self = NewActor(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Group NewGroup(dynamic that, Group? self = null) {
|
||||
// if (self == null) self = new Group();
|
||||
|
||||
// self = NewActor(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Organization NewOrganization(dynamic that, Organization? self = null) {
|
||||
// if (self == null) self = new Organization();
|
||||
|
||||
// self = NewActor(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Person NewPerson(dynamic that, Person? self = null) {
|
||||
// if (self == null) self = new Person();
|
||||
|
||||
// self = NewActor(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Service NewService(dynamic that, Service? self = null) {
|
||||
// if (self == null) self = new Service();
|
||||
|
||||
// self = NewActor(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Block NewBlock(dynamic that, Block? self = null) {
|
||||
// if (self == null) self = new Block();
|
||||
|
||||
// self = NewIgnore(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Invite NewInvite(dynamic that, Invite? self = null) {
|
||||
// if (self == null) self = new Invite();
|
||||
|
||||
// self = NewOffer(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Accept NewAccept(dynamic that, Accept? self = null) {
|
||||
// if (self == null) self = new Accept();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Add NewAdd(dynamic that, Add? self = null) {
|
||||
// if (self == null) self = new Add();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Announce NewAnnounce(dynamic that, Announce? self = null) {
|
||||
// if (self == null) self = new Announce();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Create NewCreate(dynamic that, Create? self = null) {
|
||||
// if (self == null) self = new Create();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Delete NewDelete(dynamic that, Delete? self = null) {
|
||||
// if (self == null) self = new Delete();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Dislike NewDislike(dynamic that, Dislike? self = null) {
|
||||
// if (self == null) self = new Dislike();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Flag NewFlag(dynamic that, Flag? self = null) {
|
||||
// if (self == null) self = new Flag();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Follow NewFollow(dynamic that, Follow? self = null) {
|
||||
// if (self == null) self = new Follow();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Ignore NewIgnore(dynamic that, Ignore? self = null) {
|
||||
// if (self == null) self = new Ignore();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Join NewJoin(dynamic that, Join? self = null) {
|
||||
// if (self == null) self = new Join();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Leave NewLeave(dynamic that, Leave? self = null) {
|
||||
// if (self == null) self = new Leave();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Like NewLike(dynamic that, Like? self = null) {
|
||||
// if (self == null) self = new Like();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Listen NewListen(dynamic that, Listen? self = null) {
|
||||
// if (self == null) self = new Listen();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Move NewMove(dynamic that, Move? self = null) {
|
||||
// if (self == null) self = new Move();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Offer NewOffer(dynamic that, Offer? self = null) {
|
||||
// if (self == null) self = new Offer();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Read NewRead(dynamic that, Read? self = null) {
|
||||
// if (self == null) self = new Read();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Reject NewReject(dynamic that, Reject? self = null) {
|
||||
// if (self == null) self = new Reject();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Remove NewRemove(dynamic that, Remove? self = null) {
|
||||
// if (self == null) self = new Remove();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Undo NewUndo(dynamic that, Undo? self = null) {
|
||||
// if (self == null) self = new Undo();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Update NewUpdate(dynamic that, Update? self = null) {
|
||||
// if (self == null) self = new Update();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static View NewView(dynamic that, View? self = null) {
|
||||
// if (self == null) self = new View();
|
||||
|
||||
// self = NewActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static TentativeAccept NewTentativeAccept(dynamic that, TentativeAccept? self = null) {
|
||||
// if (self == null) self = new TentativeAccept();
|
||||
|
||||
// self = NewAccept(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static TentativeReject NewTentativeReject(dynamic that, TentativeReject? self = null) {
|
||||
// if (self == null) self = new TentativeReject();
|
||||
|
||||
// self = NewReject(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Arrive NewArrive(dynamic that, Arrive? self = null) {
|
||||
// if (self == null) self = new Arrive();
|
||||
|
||||
// self = NewIntransitiveActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Travel NewTravel(dynamic that, Travel? self = null) {
|
||||
// if (self == null) self = new Travel();
|
||||
|
||||
// self = NewIntransitiveActivity(that, self);
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
// public static Question NewQuestion(dynamic that, Question? self = null) {
|
||||
// if (self == null) self = new Question();
|
||||
|
||||
// self = NewIntransitiveActivity(that, self);
|
||||
// self.OneOf = NewListOrLink<Object>(that.OneOf);
|
||||
// self.AnyOf = NewListOrLink<Object>(that.AnyOf);
|
||||
// ObjectOrLink? closed = NewObjectOrLink(that.Closed);
|
||||
// if(closed != null) self.Closed = (Uri)closed;
|
||||
// else {
|
||||
// DateTimeOffset? dateClosed = NewDate(that.Closed);
|
||||
// if (dateClosed.HasValue) self.Closed = dateClosed.Value;
|
||||
// else self.Closed = !!that.closed;
|
||||
// }
|
||||
|
||||
// return self;
|
||||
// }
|
||||
|
||||
//}
|
|
@ -1,17 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Activity
|
||||
/// </summary>
|
||||
public class Activity : IntransitiveActivity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Activity() : base() => this.Type = "Activity";
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Object
|
||||
/// </summary>
|
||||
public ObjectOrLink? Object { get; set; }
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Accept
|
||||
/// </summary>
|
||||
public class Accept : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Accept() : base() => this.Type = "Accept";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Add
|
||||
/// </summary>
|
||||
public class Add : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Add() : base() => this.Type = "Add";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Announce
|
||||
/// </summary>
|
||||
public class Announce : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Announce() : base() => this.Type = "Announce";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Block
|
||||
/// </summary>
|
||||
public class Block : Ignore {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Block() : base() => this.Type = "Block";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Create
|
||||
/// </summary>
|
||||
public class Create : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Create() : base() => this.Type = "Create";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Delete
|
||||
/// </summary>
|
||||
public class Delete : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Delete() : base() => this.Type = "Delete";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Dislike
|
||||
/// </summary>
|
||||
public class Dislike : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Dislike() : base() => this.Type = "Dislike";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Flag
|
||||
/// </summary>
|
||||
public class Flag : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Flag() : base() => this.Type = "Flag";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Follow
|
||||
/// </summary>
|
||||
public class Follow : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Follow() : base() => this.Type = "Follow";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Ignore
|
||||
/// </summary>
|
||||
public class Ignore : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Ignore() : base() => this.Type = "Ignore";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Arrive
|
||||
/// </summary>
|
||||
public class Arrive : IntransitiveActivity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Arrive() : base() => this.Type = "Arrive";
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
using OneOf;
|
||||
|
||||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Question
|
||||
/// </summary>
|
||||
public class Question : IntransitiveActivity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Question() : base() => this.Type = "Question";
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#oneOf
|
||||
/// </summary>
|
||||
public ListOrLink<Object> OneOf { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#anyOf
|
||||
/// </summary>
|
||||
public ListOrLink<Object> AnyOf { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#closed
|
||||
/// </summary>
|
||||
public OneOf<Uri, Object, DateTimeOffset, bool> Closed { get; set; }
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Travel
|
||||
/// </summary>
|
||||
public class Travel : IntransitiveActivity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Travel() : base() => this.Type = "Travel";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Invite
|
||||
/// </summary>
|
||||
public class Invite : Offer {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Invite() : base() => this.Type = "Invite";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Join
|
||||
/// </summary>
|
||||
public class Join : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Join() : base() => this.Type = "Join";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Leave
|
||||
/// </summary>
|
||||
public class Leave : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Leave() : base() => this.Type = "Leave";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Like
|
||||
/// </summary>
|
||||
public class Like : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Like() : base() => this.Type = "Like";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Listen
|
||||
/// </summary>
|
||||
public class Listen : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Listen() : base() => this.Type = "Listen";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Move
|
||||
/// </summary>
|
||||
public class Move : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Move() : base() => this.Type = "Move";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Offer
|
||||
/// </summary>
|
||||
public class Offer : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Offer() : base() => this.Type = "Offer";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Read
|
||||
/// </summary>
|
||||
public class Read : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Read() : base() => this.Type = "Read";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Reject
|
||||
/// </summary>
|
||||
public class Reject : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Reject() : base() => this.Type = "Reject";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Remove
|
||||
/// </summary>
|
||||
public class Remove : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Remove() : base() => this.Type = "Remove";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#TentativeAccept
|
||||
/// </summary>
|
||||
public class TentativeAccept : Accept {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public TentativeAccept() : base() => this.Type = "TentaativeAccept";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#TentativeReject
|
||||
/// </summary>
|
||||
public class TentativeReject : Reject {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public TentativeReject() : base() => this.Type = "TentativeReject";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Undo
|
||||
/// </summary>
|
||||
public class Undo : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Undo() : base() => this.Type = "Undo";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Update
|
||||
/// </summary>
|
||||
public class Update : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Update() : base() => this.Type = "Update";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#View
|
||||
/// </summary>
|
||||
public class View : Activity {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public View() : base() => this.Type = "View";
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/TR/activitypub/#actor-objects
|
||||
/// </summary>
|
||||
public class Actor : Object {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Actor() : base() => this.Type = "Actor";
|
||||
public CollectionOrLink Inbox { get; set; }
|
||||
public CollectionOrLink Outbox { get; set; }
|
||||
public CollectionOrLink Following { get; set; }
|
||||
public CollectionOrLink Followers { get; set; }
|
||||
public CollectionOrLink Liked { get; set; }
|
||||
|
||||
public ListOrLink<Collection>? Streams { get; set; }
|
||||
public string? PreferredUsername { get; set; }
|
||||
public OneOf.OneOf<Uri, Endpoints>? Endpoints { get; set; }
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Application
|
||||
/// </summary>
|
||||
public class Application : Actor {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Application() : base() => this.Type = "Application";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Group
|
||||
/// </summary>
|
||||
public class Group : Actor {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Group() : base() => this.Type = "Group";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Organization
|
||||
/// </summary>
|
||||
public class Organization : Actor {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Organization() : base() => this.Type = "Organization";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Person
|
||||
/// </summary>
|
||||
public class Person : Actor {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Person() : base() => this.Type = "Person";
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Service
|
||||
/// </summary>
|
||||
public class Service : Actor {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Service() : base() => this.Type = "Service";
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
// https://www.w3.org/ns/activitystreams#Collection
|
||||
public class Collection : Object {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Collection() : base() => this.Type = "Collection";
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#totalItems
|
||||
/// </summary>
|
||||
public uint? TotalItems { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#current
|
||||
/// </summary>
|
||||
public CollectionPageOrLink? Current { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#first
|
||||
/// </summary>
|
||||
public CollectionPageOrLink? First { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#last
|
||||
/// </summary>
|
||||
public CollectionPageOrLink? Last { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#items
|
||||
/// </summary>
|
||||
public CollectionPageOrLink? Items { get; set; }
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#CollectionPage
|
||||
/// </summary>
|
||||
public class CollectionPage : Collection {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public CollectionPage() : base() => this.Type = "CollectionPage";
|
||||
// https://www.w3.org/ns/activitystreams#partOf
|
||||
public CollectionOrLink? PartOf { get; set; }
|
||||
|
||||
// https://www.w3.org/ns/activitystreams#next
|
||||
public CollectionPageOrLink? Next { get; set; }
|
||||
|
||||
// https://www.w3.org/ns/activitystreams#prev
|
||||
public CollectionPageOrLink? Prev { get; set; }
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/TR/activitypub/#endpoints
|
||||
/// </summary>
|
||||
public class Endpoints
|
||||
{
|
||||
public Uri? ProxyUrl { get; set; }
|
||||
public Uri? OauthAuthorizationEndpoint { get; set; }
|
||||
public Uri? OauthTokenEndpoint { get; set; }
|
||||
public Uri? ProvideClientKey { get; set; }
|
||||
public Uri? SignClientKey { get; set; }
|
||||
public Uri? SharedInbox { get; set; }
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#IntransitiveActivity
|
||||
/// </summary>
|
||||
public class IntransitiveActivity : Object {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public IntransitiveActivity() : base() => this.Type = "IntransitiveActivity";
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#actor
|
||||
/// </summary>
|
||||
public ObjectOrLink? Actor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#target
|
||||
/// </summary>
|
||||
public ObjectOrLink? Target { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#result
|
||||
/// </summary>
|
||||
public ObjectOrLink? Result { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#origin
|
||||
/// </summary>
|
||||
public ObjectOrLink? Origin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#instrument
|
||||
/// </summary>
|
||||
public ObjectOrLink? Instrument { get; set; }
|
||||
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
using OneOf;
|
||||
|
||||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Link
|
||||
/// </summary>
|
||||
public class Link {
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Link() => this.Type = "Link";
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/TR/activitypub/#obj-id
|
||||
/// </summary>
|
||||
public Uri? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/TR/activitystreams-vocabulary/#dfn-type
|
||||
/// </summary>
|
||||
public string Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#href
|
||||
/// </summary>
|
||||
public Uri? Href { get => this.Id; set => this.Id = value; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#rel
|
||||
/// </summary>
|
||||
public string? Rel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#mediaType
|
||||
/// </summary>
|
||||
public string? MediaType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#name
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#hreflang
|
||||
/// </summary>
|
||||
public string? Hreflang { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#height
|
||||
/// </summary>
|
||||
public uint? Height { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#width
|
||||
/// </summary>
|
||||
public uint? Width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#preview
|
||||
/// </summary>
|
||||
public ObjectOrLink? Preview { get; set; }
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Mention
|
||||
/// </summary>
|
||||
public class Mention : Link {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Mention() : base() => this.Type = "Mention";
|
||||
|
||||
}
|
181
Models/Object.cs
181
Models/Object.cs
|
@ -1,181 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Object
|
||||
/// </summary>
|
||||
public class Object {
|
||||
/// <summary>
|
||||
/// Default contructor
|
||||
/// </summary>
|
||||
public Object() => this.Type = "Object";
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/TR/activitypub/#obj-id
|
||||
/// </summary>
|
||||
public Uri? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/TR/activitystreams-vocabulary/#dfn-type
|
||||
/// </summary>
|
||||
public string Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#attachment
|
||||
/// </summary>
|
||||
public ObjectOrLink? Attachment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#attributedTo
|
||||
/// </summary>
|
||||
public ObjectOrLink? AttributedTo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#audience
|
||||
/// </summary>
|
||||
public ObjectOrLink? Audience { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#content
|
||||
/// </summary>
|
||||
public string? Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/TR/activitypub/#source-property
|
||||
/// </summary>
|
||||
public ObjectOrLink? Source { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#context
|
||||
/// </summary>
|
||||
public ObjectOrLink? Context { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#name
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#endTime
|
||||
/// </summary>
|
||||
public DateTimeOffset? EndTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#generator
|
||||
/// </summary>
|
||||
public ObjectOrLink? Generator { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#icon
|
||||
/// </summary>
|
||||
public GenericObjectOrLink<Image>? Icon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Image
|
||||
/// </summary>
|
||||
public Image? Image { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#inReplyTo
|
||||
/// </summary>
|
||||
public ObjectOrLink? InReplyTo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#location
|
||||
/// </summary>
|
||||
public ObjectOrLink? Location { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#preview
|
||||
/// </summary>
|
||||
public ObjectOrLink? Preview { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#published
|
||||
/// </summary>
|
||||
public DateTimeOffset? Published { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#replies
|
||||
/// </summary>
|
||||
public Collection? Replies { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#startTime
|
||||
/// </summary>
|
||||
public DateTimeOffset? StartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#summary
|
||||
/// </summary>
|
||||
public string? Summary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#tag
|
||||
/// </summary>
|
||||
public ObjectOrLink? Tag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#updated
|
||||
/// </summary>
|
||||
public DateTimeOffset? Updated { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#url
|
||||
/// </summary>
|
||||
public LinkOrUri? Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#to
|
||||
/// </summary>
|
||||
public ListOrLink<Object>? To { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#bto
|
||||
/// </summary>
|
||||
public ListOrLink<Object>? Bto { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#cc
|
||||
/// </summary>
|
||||
public ListOrLink<Object>? Cc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#bcc
|
||||
/// </summary>
|
||||
public ListOrLink<Object>? Bcc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#mediaType
|
||||
/// </summary>
|
||||
public string? MediaType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#duration
|
||||
/// </summary>
|
||||
public string? Duration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/TR/activitypub/#likes
|
||||
/// </summary>
|
||||
public ListOrLink<Object>? Likes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/TR/activitypub/#shares
|
||||
/// </summary>
|
||||
public ListOrLink<Object>? Shares { get; set; }
|
||||
|
||||
//public Object(dynamic that) {
|
||||
// if(that.Id is Uri) this.Id = that.Id;
|
||||
// if(that.Id is string) this.Id = new Uri(that.Id);
|
||||
|
||||
// this.Type = that.Type;
|
||||
//}
|
||||
|
||||
//public static ObjectOrLink? FromDynamic(dynamic that) {
|
||||
// if (that is null) return null;
|
||||
// if (that is Uri) return (ObjectOrLink?)(Uri)that;
|
||||
// if (that is string) return (ObjectOrLink?)new Uri((string)that);
|
||||
// if (that is Object) return (ObjectOrLink?)(Object)that;
|
||||
// return (ObjectOrLink?)new Object(that);
|
||||
//}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Article
|
||||
/// </summary>
|
||||
public class Article : Object {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Article() : base() => this.Type = "Article";
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Audio
|
||||
/// </summary>
|
||||
public class Audio : Document {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Audio() : base() => this.Type = "Audio";
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Document
|
||||
/// </summary>
|
||||
public class Document : Object {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Document() : base() => this.Type = "Document";
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Event
|
||||
/// </summary>
|
||||
public class Event : Object {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Event() : base() => this.Type = "Event";
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Image
|
||||
/// </summary>
|
||||
public class Image : Document {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Image() : base() => this.Type = "Image";
|
||||
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Note
|
||||
/// </summary>
|
||||
public class Note : Object {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Note() : base() => this.Type = "Note";
|
||||
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Page
|
||||
/// </summary>
|
||||
public class Page : Document {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Page() : base() => this.Type = "Page";
|
||||
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Place
|
||||
/// </summary>
|
||||
public class Place : Object {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Place() : base() => this.Type = "Place";
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#accuracy
|
||||
/// </summary>
|
||||
public float? Accuracy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#altitude
|
||||
/// </summary>
|
||||
public float? Altitude { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#latitude
|
||||
/// </summary>
|
||||
public float? Latitude { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#longitude
|
||||
/// </summary>
|
||||
public float? Longitude { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#radius
|
||||
/// </summary>
|
||||
public float? Radius { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#units
|
||||
/// </summary>
|
||||
public string? Units { get; set; }
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Profile
|
||||
/// </summary>
|
||||
public class Profile : Object {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Profile() : base() => this.Type = "Profile";
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#describes
|
||||
/// </summary>
|
||||
public ObjectOrLink? Describes { get; set; }
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Relationship
|
||||
/// </summary>
|
||||
public class Relationship : Object {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Relationship() : base() => this.Type = "Relationship";
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#subject
|
||||
/// </summary>
|
||||
public ObjectOrLink? Subject { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Object
|
||||
/// </summary>
|
||||
public ObjectOrLink? Object { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Relationship
|
||||
/// </summary>
|
||||
// This is the only lowercase property in all the classes
|
||||
// because "Member names cannot be the same as their enclosing type"
|
||||
public string? relationship { get; set; }
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Tombstone
|
||||
/// </summary>
|
||||
public class Tombstone : Object {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Tombstone() : base() => this.Type = "Tombstone";
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#formerType
|
||||
/// </summary>
|
||||
public string? FormerType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#deleted
|
||||
/// </summary>
|
||||
public DateTimeOffset? Deleted { get; set; }
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#Video
|
||||
/// </summary>
|
||||
public class Video : Document {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public Video() : base() => this.Type = "Video";
|
||||
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#OrderedCollection
|
||||
/// </summary>
|
||||
public class OrderedCollection : Collection {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public OrderedCollection() : base() => this.Type = "OrderedCollection";
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
namespace ActivityPub;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#OrderedCollectionPage
|
||||
/// </summary>
|
||||
public class OrderedCollectionPage : CollectionPage {
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor
|
||||
/// </summary>
|
||||
public OrderedCollectionPage() : base() => this.Type = "OrderedCollectionPage";
|
||||
|
||||
/// <summary>
|
||||
/// https://www.w3.org/ns/activitystreams#startIndex
|
||||
/// </summary>
|
||||
public uint StartIndex { get; set; }
|
||||
}
|
|
@ -3,10 +3,12 @@ using ActivityPub.Utils;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using KristofferStrube.ActivityStreams;
|
||||
|
||||
using Object = KristofferStrube.ActivityStreams.Object;
|
||||
|
||||
namespace ActivityPub;
|
||||
|
||||
public class ObjectStore {
|
||||
private static Dictionary<string, Dictionary<string, KristofferStrube.ActivityStreams.Object>> _objects = new();
|
||||
private static Dictionary<string, Dictionary<string, Object>> _objects = new();
|
||||
private IUrlHelper Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -36,7 +38,7 @@ public class ObjectStore {
|
|||
/// The new Object to be stored
|
||||
/// (with updated properties such as Id, Bto and Bcc removed, etc.)
|
||||
/// </returns>
|
||||
public KristofferStrube.ActivityStreams.Object InsertObject(KristofferStrube.ActivityStreams.Object newObject) {
|
||||
public Object InsertObject(Object newObject) {
|
||||
if (newObject.Type == null) throw new ArgumentException("Object must have Type");
|
||||
|
||||
string id = NewId;
|
||||
|
@ -55,9 +57,9 @@ public class ObjectStore {
|
|||
/// </summary>
|
||||
/// <param name="id">The Id to find</param>
|
||||
/// <returns>The object with the corresponding id, or null if not found</returns>
|
||||
public KristofferStrube.ActivityStreams.Object? GetObjectById(string id) {
|
||||
foreach (Dictionary<string, KristofferStrube.ActivityStreams.Object> list in _objects.Values) {
|
||||
foreach (KeyValuePair<string, KristofferStrube.ActivityStreams.Object> kvp in list) {
|
||||
public Object? GetObjectById(string id) {
|
||||
foreach (Dictionary<string, Object> list in _objects.Values) {
|
||||
foreach (KeyValuePair<string, Object> kvp in list) {
|
||||
if (kvp.Key == id) return kvp.Value;
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +72,7 @@ public class ObjectStore {
|
|||
/// <param name="type">The type</param>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public KristofferStrube.ActivityStreams.Object? GetObjectByTypeAndId(string type, string id) {
|
||||
public Object? GetObjectByTypeAndId(string type, string id) {
|
||||
type = Types.Normalize(type);
|
||||
return _objects[type]?[id];
|
||||
}
|
||||
|
@ -80,8 +82,8 @@ public class ObjectStore {
|
|||
/// </summary>
|
||||
/// <param name="type">The type of object to retrieve</param>
|
||||
/// <returns>A list of objects of the specified type</returns>
|
||||
public List<KristofferStrube.ActivityStreams.Object> GetObjectsByType(string type) {
|
||||
public List<Object> GetObjectsByType(string type) {
|
||||
type = Types.Normalize(type);
|
||||
return _objects[type]?.Values.ToList() ?? new List<KristofferStrube.ActivityStreams.Object>();
|
||||
return _objects[type]?.Values.ToList() ?? new List<Object>();
|
||||
}
|
||||
}
|
||||
|
|
17
Program.cs
17
Program.cs
|
@ -1,9 +1,6 @@
|
|||
using Microsoft.OpenApi.Models;
|
||||
using KristofferStrube.ActivityStreams.JsonConverters;
|
||||
using System.Reflection;
|
||||
using System.Text.Json.Serialization;
|
||||
using KristofferStrube.ActivityStreams;
|
||||
using KristofferStrube.ActivityStreams.JsonLD;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
|
@ -12,20 +9,6 @@ var builder = WebApplication.CreateBuilder(args);
|
|||
builder.Services.AddControllers().AddJsonOptions(options =>
|
||||
{
|
||||
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
|
||||
//options.JsonSerializerOptions.Converters.Add(new CollectionOrLinkConverter());
|
||||
//options.JsonSerializerOptions.Converters.Add(new CollectionPageOrLinkConverter());
|
||||
//options.JsonSerializerOptions.Converters.Add(new DateTimeBooleanObjectOrLinkConverter());
|
||||
//options.JsonSerializerOptions.Converters.Add(new EndpointsOrLinkConverter());
|
||||
//options.JsonSerializerOptions.Converters.Add(new ImageOrLinkConverter());
|
||||
//options.JsonSerializerOptions.Converters.Add(new LinkConverter());
|
||||
//options.JsonSerializerOptions.Converters.Add(new ObjectConverter());
|
||||
//options.JsonSerializerOptions.Converters.Add(new ObjectOrLinkConverter());
|
||||
//options.JsonSerializerOptions.Converters.Add(new TermDefinitionConverter());
|
||||
//options.JsonSerializerOptions.Converters.Add(new XMLTimeSpanConverter());
|
||||
//options.JsonSerializerOptions.Converters.Add(new OneOrMultipleConverter<string>());
|
||||
//options.JsonSerializerOptions.Converters.Add(new OneOrMultipleConverter<IObjectOrLink>());
|
||||
//options.JsonSerializerOptions.Converters.Add(new OneOrMultipleConverter<ITermDefinition>());
|
||||
//options.JsonSerializerOptions.Converters.Add(new OneOrMultipleConverter<IDictionary<string, string>>());
|
||||
});
|
||||
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
|
|
74
Repositories/ActivityPubContext.cs
Normal file
74
Repositories/ActivityPubContext.cs
Normal file
|
@ -0,0 +1,74 @@
|
|||
using KristofferStrube.ActivityStreams;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Net.Mail;
|
||||
using Object = KristofferStrube.ActivityStreams.Object;
|
||||
|
||||
namespace ActivityPub.Repositories;
|
||||
|
||||
/// <summary>
|
||||
/// Database Context for ActivityPub objects (using EF and SQLite)
|
||||
/// </summary>
|
||||
public class ActivityPubContext : DbContext {
|
||||
|
||||
/// <summary>
|
||||
/// The table to store Activities
|
||||
/// </summary>
|
||||
public DbSet<Activity> Activities { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The table to store Objects
|
||||
/// </summary>
|
||||
public DbSet<ObjectOrLink> Objects { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The path to the sqlite database file
|
||||
/// </summary>
|
||||
public string DbPath { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public ActivityPubContext() {
|
||||
var folder = Environment.SpecialFolder.LocalApplicationData;
|
||||
var path = Environment.GetFolderPath(folder);
|
||||
DbPath = System.IO.Path.Join(path, "activitypub.db");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The following configures EF to create a Sqlite database file in the
|
||||
/// special "local" folder for your platform.
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder options) {
|
||||
options.UseSqlite($"Data Source={DbPath}");
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder) {
|
||||
modelBuilder.Entity<Activity>().HasMany(_ => _.Actor as IEnumerable<Actor>);
|
||||
modelBuilder.Entity<Activity>().HasMany(_ => _.Object as IEnumerable<ObjectOrLink>);
|
||||
modelBuilder.Entity<Activity>().HasMany(_ => _.Target as IEnumerable<ObjectOrLink>);
|
||||
modelBuilder.Entity<Activity>().HasMany(_ => _.Result as IEnumerable<ObjectOrLink>);
|
||||
modelBuilder.Entity<Activity>().HasMany(_ => _.Origin as IEnumerable<ObjectOrLink>);
|
||||
modelBuilder.Entity<Activity>().HasMany(_ => _.Instrument as IEnumerable<ObjectOrLink>);
|
||||
|
||||
|
||||
modelBuilder.Entity<Object>().HasMany(_ => _.Attachment as IEnumerable<ObjectOrLink>);
|
||||
modelBuilder.Entity<Object>().HasMany(_ => _.AttributedTo as IEnumerable<ObjectOrLink>);
|
||||
modelBuilder.Entity<Object>().HasMany(_ => _.Audience as IEnumerable<ObjectOrLink>);
|
||||
modelBuilder.Entity<Object>().HasMany(_ => _.Bcc as IEnumerable<ObjectOrLink>);
|
||||
modelBuilder.Entity<Object>().HasMany(_ => _.Bto as IEnumerable<ObjectOrLink>);
|
||||
modelBuilder.Entity<Object>().HasMany(_ => _.Cc as IEnumerable<ObjectOrLink>);
|
||||
modelBuilder.Entity<Object>().HasMany(_ => _.Context as IEnumerable<ObjectOrLink>);
|
||||
modelBuilder.Entity<Object>().HasMany(_ => _.Generator as IEnumerable<ObjectOrLink>);
|
||||
modelBuilder.Entity<Object>().HasMany(_ => _.Icon as IEnumerable<Image>);
|
||||
modelBuilder.Entity<Object>().HasMany(_ => _.Image as IEnumerable<Image>);
|
||||
modelBuilder.Entity<Object>().HasMany(_ => _.InReplyTo as IEnumerable<ObjectOrLink>);
|
||||
modelBuilder.Entity<Object>().HasMany(_ => _.Location as IEnumerable<ObjectOrLink>);
|
||||
modelBuilder.Entity<Object>().HasMany(_ => _.Tag as IEnumerable<ObjectOrLink>);
|
||||
modelBuilder.Entity<Object>().HasMany(_ => _.To as IEnumerable<ObjectOrLink>);
|
||||
modelBuilder.Entity<Object>().HasMany(_ => _.Url as IEnumerable<Link>);
|
||||
modelBuilder.Entity<Object>().Ignore(_ => _.ExtensionData);
|
||||
//modelBuilder.Entity<Object>().HasMany(_ => _.Content as IList<string>);
|
||||
|
||||
}
|
||||
}
|
|
@ -15,8 +15,13 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="KristofferStrube.ActivityStreams" Version="0.2.1" />
|
||||
<PackageReference Include="KristofferStrube.ActivityStreams" Version="0.2.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="OneOf" Version="3.0.263" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
</ItemGroup>
|
||||
|
|
Loading…
Reference in a new issue