diff --git a/ActivityStore.cs b/ActivityStore.cs index a917112..661a8df 100644 --- a/ActivityStore.cs +++ b/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; public enum ActivityStoreType { Inbox, @@ -51,7 +50,7 @@ public class ActivityStore { /// /// The object to create /// The create Activity, with the object inside. - 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 { /// A boolean indicating whether delivery tasks should be run (default true) /// The newly inserted activity public Activity InsertActivity(Activity newActivity, bool runSideEffects = true, bool runDelivery = true) { - List recipients = runDelivery ? ExtractRecipients(newActivity) : new List(); 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 recipients = runDelivery ? ExtractRecipients(newActivity) : new List(); + 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; } - ///// - ///// Inserts an activity into the data store - ///// - ///// The Activity to create - ///// A boolean indicating whether side effects should be run (default true) - ///// A boolean indicating whether delivery tasks should be run (default true) - ///// The newly inserted activity - //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 recipients = runDelivery ? ExtractRecipients(newActivity) : new List(); - // newActivity.Bto = newActivity.Bcc = null; - - // _activities[id] = newActivity; - - // if (runDelivery) RunDelivery(newActivity, recipients); - - // return newActivity; - //} - /// /// 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 { /// True on successful validation /// Thown if the activity is invalid 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)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 { 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(); + } } diff --git a/BaseActivity.cs b/BaseActivity.cs deleted file mode 100644 index 1309451..0000000 --- a/BaseActivity.cs +++ /dev/null @@ -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, IObject { - - protected BaseActivity(OneOf _) : 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; } - - /// - /// 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. - /// - public IEnumerable? Actor { - get => Match(a => a.Actor, ia => ia.Actor); - set => Switch(a => a.Actor = value, ia => ia.Actor = value); - } - - /// - /// 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. - /// - public IEnumerable? 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")); - } - - /// - /// 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. - /// - public IEnumerable? Target { - get => Match(a => a.Target, ia => ia.Target); - set => Switch(a => a.Target = value, ia => ia.Target = value); - } - - /// - /// 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. - /// - public IEnumerable? Result { - get => Match(a => a.Result, ia => ia.Result); - set => Switch(a => a.Result = value, ia => ia.Result = value); - } - - /// - /// 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". - /// - public IEnumerable? Origin { - get => Match(a => a.Origin, ia => ia.Origin); - set => Switch(a => a.Origin = value, ia => ia.Origin = value); - } - - /// - /// Identifies one or more objects used (or to be used) in the completion of an Activity. - /// - public IEnumerable? Instrument { - get => Match(a => a.Instrument, ia => ia.Instrument); - set => Switch(a => a.Instrument = value, ia => ia.Instrument = value); - } - - /// - /// - /// - public IEnumerable? Attachment { - get => Match(a => a.Attachment, ia => ia.Attachment); - set => Switch(a => a.Attachment = value, ia => ia.Attachment = value); - } - public IEnumerable? AttributedTo { - get => Match(a => a.AttributedTo, ia => ia.AttributedTo); - set => Switch(a => a.AttributedTo = value, ia => ia.AttributedTo = value); - } - public IEnumerable? Audience { - get => Match(a => a.Audience, ia => ia.Audience); - set => Switch(a => a.Audience = value, ia => ia.Audience = value); - } - public IEnumerable? Bcc { - get => Match(a => a.Bcc, ia => ia.Bcc); - set => Switch(a => a.Bcc = value, ia => ia.Bcc = value); - } - public IEnumerable? Bto { - get => Match(a => a.Bto, ia => ia.Bto); - set => Switch(a => a.Bto = value, ia => ia.Bto = value); - } - public IEnumerable? Cc { - get => Match(a => a.Cc, ia => ia.Cc); - set => Switch(a => a.Cc = value, ia => ia.Cc = value); - } - public IEnumerable? Context { - get => Match(a => a.Context, ia => ia.Context); - set => Switch(a => a.Context = value, ia => ia.Context = value); - } - public IEnumerable? Generator { - get => Match(a => a.Generator, ia => ia.Generator); - set => Switch(a => a.Generator = value, ia => ia.Generator = value); - } - public IEnumerable? Icon { - get => Match(a => a.Icon, ia => ia.Icon); - set => Switch(a => a.Icon = value, ia => ia.Icon = value); - } - public IEnumerable? Image { - get => Match(a => a.Image, ia => ia.Image); - set => Switch(a => a.Image = value, ia => ia.Image = value); - } - public IEnumerable? InReplyTo { - get => Match(a => a.InReplyTo, ia => ia.InReplyTo); - set => Switch(a => a.InReplyTo = value, ia => ia.InReplyTo = value); - } - public IEnumerable? 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? Tag { - get => Match(a => a.Tag, ia => ia.Tag); - set => Switch(a => a.Tag = value, ia => ia.Tag = value); - } - public IEnumerable? To { - get => Match(a => a.To, ia => ia.To); - set => Switch(a => a.To = value, ia => ia.To = value); - } - public IEnumerable? Url { - get => Match(a => a.Url, ia => ia.Url); - set => Switch(a => a.Url = value, ia => ia.Url = value); - } - public IEnumerable? Content { - get => Match(a => a.Content, ia => ia.Content); - set => Switch(a => a.Content = value, ia => ia.Content = value); - } - public IEnumerable>? ContentMap { - get => Match(a => a.ContentMap, ia => ia.ContentMap); - set => Switch(a => a.ContentMap = value, ia => ia.ContentMap = value); - } - public IEnumerable>? 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? Summary { - get => Match(a => a.Summary, ia => ia.Summary); - set => Switch(a => a.Summary = value, ia => ia.Summary = value); - } - public IEnumerable>? 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? 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? JsonLDContext { - get => Match(a => a.JsonLDContext, ia => ia.JsonLDContext); - set => Switch(a => a.JsonLDContext = value, ia => ia.JsonLDContext = value); - } - public IEnumerable? 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? Name { - get => Match(a => a.Name, ia => ia.Name); - set => Switch(a => a.Name = value, ia => ia.Name = value); - } - public IEnumerable? Preview { - get => Match(a => a.Preview, ia => ia.Preview); - set => Switch(a => a.Preview = value, ia => ia.Preview = value); - } -} diff --git a/Controllers/OutboxController.cs b/Controllers/OutboxController.cs index 36ad81c..eae282d 100644 --- a/Controllers/OutboxController.cs +++ b/Controllers/OutboxController.cs @@ -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 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); } diff --git a/DynamicObjectFactory.cs b/DynamicObjectFactory.cs deleted file mode 100644 index bf86e41..0000000 --- a/DynamicObjectFactory.cs +++ /dev/null @@ -1,654 +0,0 @@ -//namespace ActivityPub; - - -///// -///// A class to create ActivityPub Objects/Activities/etc from an incoming dynamic object -///// -//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? NewListOrLink(dynamic that) where T : KristofferStrube.ActivityStreams.Object, new() { -// if (that == null) return null; - -// if (that is string) return (ListOrLink)new Uri((string)that); -// if (that is Uri) return (ListOrLink)that; - -// if (that is IEnumerable) -// return (ListOrLink)(that as IEnumerable).Select(x => NewObjectOrLink(x)).Cast>().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(that.To); -// self.Bto = NewListOrLink(that.Bto); -// self.Cc = NewListOrLink(that.Cc); -// self.Bcc = NewListOrLink(that.Bcc); -// self.MediaType = that.MediaType; -// self.Duration = that.Duration; -// self.Likes = NewListOrLink(that.Likes); -// self.Shares = NewListOrLink(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? NewEndpointsOrUri(dynamic that) { -// if (that == null) return null; - -// if (that is string) return (OneOf)new Uri((string)that); -// if (that is Uri) return (OneOf)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(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(that.OneOf); -// self.AnyOf = NewListOrLink(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; -// } - -//} diff --git a/Models/Activity.cs b/Models/Activity.cs deleted file mode 100644 index 207d09d..0000000 --- a/Models/Activity.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace ActivityPub; - - /// - /// https://www.w3.org/ns/activitystreams#Activity - /// -public class Activity : IntransitiveActivity { - - /// - /// Default Constructor - /// - public Activity() : base() => this.Type = "Activity"; - - /// - /// https://www.w3.org/ns/activitystreams#Object - /// - public ObjectOrLink? Object { get; set; } -} \ No newline at end of file diff --git a/Models/Activity/Accept.cs b/Models/Activity/Accept.cs deleted file mode 100644 index 3f3651c..0000000 --- a/Models/Activity/Accept.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Accept -/// -public class Accept : Activity { - - /// - /// Default Constructor - /// - public Accept() : base() => this.Type = "Accept"; -} diff --git a/Models/Activity/Add.cs b/Models/Activity/Add.cs deleted file mode 100644 index d447227..0000000 --- a/Models/Activity/Add.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Add -/// -public class Add : Activity { - - /// - /// Default Constructor - /// - public Add() : base() => this.Type = "Add"; -} diff --git a/Models/Activity/Announce.cs b/Models/Activity/Announce.cs deleted file mode 100644 index 8ce3e37..0000000 --- a/Models/Activity/Announce.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Announce -/// -public class Announce : Activity { - - /// - /// Default Constructor - /// - public Announce() : base() => this.Type = "Announce"; -} diff --git a/Models/Activity/Block.cs b/Models/Activity/Block.cs deleted file mode 100644 index 1311e8f..0000000 --- a/Models/Activity/Block.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Block -/// -public class Block : Ignore { - - /// - /// Default Constructor - /// - public Block() : base() => this.Type = "Block"; -} diff --git a/Models/Activity/Create.cs b/Models/Activity/Create.cs deleted file mode 100644 index 88e51cb..0000000 --- a/Models/Activity/Create.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Create -/// -public class Create : Activity { - - /// - /// Default Constructor - /// - public Create() : base() => this.Type = "Create"; -} diff --git a/Models/Activity/Delete.cs b/Models/Activity/Delete.cs deleted file mode 100644 index 6d301d9..0000000 --- a/Models/Activity/Delete.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Delete -/// -public class Delete : Activity { - - /// - /// Default Constructor - /// - public Delete() : base() => this.Type = "Delete"; -} diff --git a/Models/Activity/Dislike.cs b/Models/Activity/Dislike.cs deleted file mode 100644 index 866c9cf..0000000 --- a/Models/Activity/Dislike.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Dislike -/// -public class Dislike : Activity { - - /// - /// Default Constructor - /// - public Dislike() : base() => this.Type = "Dislike"; -} diff --git a/Models/Activity/Flag.cs b/Models/Activity/Flag.cs deleted file mode 100644 index 79feece..0000000 --- a/Models/Activity/Flag.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Flag -/// -public class Flag : Activity { - - /// - /// Default Constructor - /// - public Flag() : base() => this.Type = "Flag"; -} diff --git a/Models/Activity/Follow.cs b/Models/Activity/Follow.cs deleted file mode 100644 index 00a3372..0000000 --- a/Models/Activity/Follow.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Follow -/// -public class Follow : Activity { - - /// - /// Default Constructor - /// - public Follow() : base() => this.Type = "Follow"; -} diff --git a/Models/Activity/Ignore.cs b/Models/Activity/Ignore.cs deleted file mode 100644 index b2c4a7d..0000000 --- a/Models/Activity/Ignore.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Ignore -/// -public class Ignore : Activity { - - /// - /// Default Constructor - /// - public Ignore() : base() => this.Type = "Ignore"; -} diff --git a/Models/Activity/Intransitive/Arrive.cs b/Models/Activity/Intransitive/Arrive.cs deleted file mode 100644 index e234023..0000000 --- a/Models/Activity/Intransitive/Arrive.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Arrive -/// -public class Arrive : IntransitiveActivity { - - /// - /// Default Constructor - /// - public Arrive() : base() => this.Type = "Arrive"; -} diff --git a/Models/Activity/Intransitive/Question.cs b/Models/Activity/Intransitive/Question.cs deleted file mode 100644 index d97ba77..0000000 --- a/Models/Activity/Intransitive/Question.cs +++ /dev/null @@ -1,29 +0,0 @@ -using OneOf; - -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Question -/// -public class Question : IntransitiveActivity { - - /// - /// Default Constructor - /// - public Question() : base() => this.Type = "Question"; - - /// - /// https://www.w3.org/ns/activitystreams#oneOf - /// - public ListOrLink OneOf { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#anyOf - /// - public ListOrLink AnyOf { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#closed - /// - public OneOf Closed { get; set; } -} diff --git a/Models/Activity/Intransitive/Travel.cs b/Models/Activity/Intransitive/Travel.cs deleted file mode 100644 index 647dee9..0000000 --- a/Models/Activity/Intransitive/Travel.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Travel -/// -public class Travel : IntransitiveActivity { - - /// - /// Default Constructor - /// - public Travel() : base() => this.Type = "Travel"; -} diff --git a/Models/Activity/Invite.cs b/Models/Activity/Invite.cs deleted file mode 100644 index fd0b0e0..0000000 --- a/Models/Activity/Invite.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Invite -/// -public class Invite : Offer { - - /// - /// Default Constructor - /// - public Invite() : base() => this.Type = "Invite"; -} diff --git a/Models/Activity/Join.cs b/Models/Activity/Join.cs deleted file mode 100644 index 9439e8c..0000000 --- a/Models/Activity/Join.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Join -/// -public class Join : Activity { - - /// - /// Default Constructor - /// - public Join() : base() => this.Type = "Join"; -} diff --git a/Models/Activity/Leave.cs b/Models/Activity/Leave.cs deleted file mode 100644 index 65370fc..0000000 --- a/Models/Activity/Leave.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Leave -/// -public class Leave : Activity { - - /// - /// Default Constructor - /// - public Leave() : base() => this.Type = "Leave"; -} diff --git a/Models/Activity/Like.cs b/Models/Activity/Like.cs deleted file mode 100644 index 999e9c4..0000000 --- a/Models/Activity/Like.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Like -/// -public class Like : Activity { - - /// - /// Default Constructor - /// - public Like() : base() => this.Type = "Like"; -} diff --git a/Models/Activity/Listen.cs b/Models/Activity/Listen.cs deleted file mode 100644 index a6a1399..0000000 --- a/Models/Activity/Listen.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Listen -/// -public class Listen : Activity { - - /// - /// Default Constructor - /// - public Listen() : base() => this.Type = "Listen"; -} diff --git a/Models/Activity/Move.cs b/Models/Activity/Move.cs deleted file mode 100644 index 76b24f1..0000000 --- a/Models/Activity/Move.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Move -/// -public class Move : Activity { - - /// - /// Default Constructor - /// - public Move() : base() => this.Type = "Move"; -} diff --git a/Models/Activity/Offer.cs b/Models/Activity/Offer.cs deleted file mode 100644 index d657241..0000000 --- a/Models/Activity/Offer.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Offer -/// -public class Offer : Activity { - - /// - /// Default Constructor - /// - public Offer() : base() => this.Type = "Offer"; -} diff --git a/Models/Activity/Read.cs b/Models/Activity/Read.cs deleted file mode 100644 index 29b8c84..0000000 --- a/Models/Activity/Read.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Read -/// -public class Read : Activity { - - /// - /// Default Constructor - /// - public Read() : base() => this.Type = "Read"; -} diff --git a/Models/Activity/Reject.cs b/Models/Activity/Reject.cs deleted file mode 100644 index e3cc760..0000000 --- a/Models/Activity/Reject.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Reject -/// -public class Reject : Activity { - - /// - /// Default Constructor - /// - public Reject() : base() => this.Type = "Reject"; -} diff --git a/Models/Activity/Remove.cs b/Models/Activity/Remove.cs deleted file mode 100644 index 0a2aec0..0000000 --- a/Models/Activity/Remove.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Remove -/// -public class Remove : Activity { - - /// - /// Default Constructor - /// - public Remove() : base() => this.Type = "Remove"; -} diff --git a/Models/Activity/TentativeAccept.cs b/Models/Activity/TentativeAccept.cs deleted file mode 100644 index e55519c..0000000 --- a/Models/Activity/TentativeAccept.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#TentativeAccept -/// -public class TentativeAccept : Accept { - - /// - /// Default Constructor - /// - public TentativeAccept() : base() => this.Type = "TentaativeAccept"; -} diff --git a/Models/Activity/TentativeReject.cs b/Models/Activity/TentativeReject.cs deleted file mode 100644 index 5f2a356..0000000 --- a/Models/Activity/TentativeReject.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#TentativeReject -/// -public class TentativeReject : Reject { - - /// - /// Default Constructor - /// - public TentativeReject() : base() => this.Type = "TentativeReject"; -} diff --git a/Models/Activity/Undo.cs b/Models/Activity/Undo.cs deleted file mode 100644 index c463c74..0000000 --- a/Models/Activity/Undo.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Undo -/// -public class Undo : Activity { - - /// - /// Default Constructor - /// - public Undo() : base() => this.Type = "Undo"; -} diff --git a/Models/Activity/Update.cs b/Models/Activity/Update.cs deleted file mode 100644 index cabb33b..0000000 --- a/Models/Activity/Update.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Update -/// -public class Update : Activity { - - /// - /// Default Constructor - /// - public Update() : base() => this.Type = "Update"; -} diff --git a/Models/Activity/View.cs b/Models/Activity/View.cs deleted file mode 100644 index de67ce2..0000000 --- a/Models/Activity/View.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#View -/// -public class View : Activity { - - /// - /// Default Constructor - /// - public View() : base() => this.Type = "View"; -} diff --git a/Models/Actor.cs b/Models/Actor.cs deleted file mode 100644 index b712ef5..0000000 --- a/Models/Actor.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/TR/activitypub/#actor-objects -/// -public class Actor : Object { - - /// - /// Default Constructor - /// - 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? Streams { get; set; } - public string? PreferredUsername { get; set; } - public OneOf.OneOf? Endpoints { get; set; } -} diff --git a/Models/Actor/Application.cs b/Models/Actor/Application.cs deleted file mode 100644 index 0d53e4a..0000000 --- a/Models/Actor/Application.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Application -/// -public class Application : Actor { - - /// - /// Default Constructor - /// - public Application() : base() => this.Type = "Application"; -} diff --git a/Models/Actor/Group.cs b/Models/Actor/Group.cs deleted file mode 100644 index 18cf133..0000000 --- a/Models/Actor/Group.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Group -/// -public class Group : Actor { - - /// - /// Default Constructor - /// - public Group() : base() => this.Type = "Group"; -} diff --git a/Models/Actor/Organization.cs b/Models/Actor/Organization.cs deleted file mode 100644 index 8eeeba1..0000000 --- a/Models/Actor/Organization.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Organization -/// -public class Organization : Actor { - - /// - /// Default Constructor - /// - public Organization() : base() => this.Type = "Organization"; -} diff --git a/Models/Actor/Person.cs b/Models/Actor/Person.cs deleted file mode 100644 index 70fbf24..0000000 --- a/Models/Actor/Person.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Person -/// -public class Person : Actor { - - /// - /// Default Constructor - /// - public Person() : base() => this.Type = "Person"; -} diff --git a/Models/Actor/Service.cs b/Models/Actor/Service.cs deleted file mode 100644 index a931761..0000000 --- a/Models/Actor/Service.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Service -/// -public class Service : Actor { - - /// - /// Default Constructor - /// - public Service() : base() => this.Type = "Service"; -} diff --git a/Models/Collection.cs b/Models/Collection.cs deleted file mode 100644 index 4437cc1..0000000 --- a/Models/Collection.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace ActivityPub; - -// https://www.w3.org/ns/activitystreams#Collection -public class Collection : Object { - - /// - /// Default Constructor - /// - public Collection() : base() => this.Type = "Collection"; - - /// - /// https://www.w3.org/ns/activitystreams#totalItems - /// - public uint? TotalItems { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#current - /// - public CollectionPageOrLink? Current { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#first - /// - public CollectionPageOrLink? First { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#last - /// - public CollectionPageOrLink? Last { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#items - /// - public CollectionPageOrLink? Items { get; set; } -} \ No newline at end of file diff --git a/Models/CollectionPage.cs b/Models/CollectionPage.cs deleted file mode 100644 index 49e3b48..0000000 --- a/Models/CollectionPage.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#CollectionPage -/// -public class CollectionPage : Collection { - - /// - /// Default Constructor - /// - 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; } -} \ No newline at end of file diff --git a/Models/Endpoints.cs b/Models/Endpoints.cs deleted file mode 100644 index 2f9628d..0000000 --- a/Models/Endpoints.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/TR/activitypub/#endpoints -/// -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; } -} - diff --git a/Models/IntransitiveActivity.cs b/Models/IntransitiveActivity.cs deleted file mode 100644 index 26672ae..0000000 --- a/Models/IntransitiveActivity.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#IntransitiveActivity -/// -public class IntransitiveActivity : Object { - - /// - /// Default Constructor - /// - public IntransitiveActivity() : base() => this.Type = "IntransitiveActivity"; - - /// - /// https://www.w3.org/ns/activitystreams#actor - /// - public ObjectOrLink? Actor { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#target - /// - public ObjectOrLink? Target { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#result - /// - public ObjectOrLink? Result { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#origin - /// - public ObjectOrLink? Origin { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#instrument - /// - public ObjectOrLink? Instrument { get; set; } - -} \ No newline at end of file diff --git a/Models/Link.cs b/Models/Link.cs deleted file mode 100644 index 75c2e39..0000000 --- a/Models/Link.cs +++ /dev/null @@ -1,63 +0,0 @@ -using OneOf; - -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Link -/// -public class Link { - /// - /// Default Constructor - /// - public Link() => this.Type = "Link"; - - /// - /// https://www.w3.org/TR/activitypub/#obj-id - /// - public Uri? Id { get; set; } - - /// - /// https://www.w3.org/TR/activitystreams-vocabulary/#dfn-type - /// - public string Type { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#href - /// - public Uri? Href { get => this.Id; set => this.Id = value; } - - /// - /// https://www.w3.org/ns/activitystreams#rel - /// - public string? Rel { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#mediaType - /// - public string? MediaType { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#name - /// - public string? Name { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#hreflang - /// - public string? Hreflang { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#height - /// - public uint? Height { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#width - /// - public uint? Width { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#preview - /// - public ObjectOrLink? Preview { get; set; } -} \ No newline at end of file diff --git a/Models/Links/Mention.cs b/Models/Links/Mention.cs deleted file mode 100644 index c287365..0000000 --- a/Models/Links/Mention.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Mention -/// -public class Mention : Link { - - /// - /// Default Constructor - /// - public Mention() : base() => this.Type = "Mention"; - -} \ No newline at end of file diff --git a/Models/Object.cs b/Models/Object.cs deleted file mode 100644 index 2fe7d08..0000000 --- a/Models/Object.cs +++ /dev/null @@ -1,181 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Object -/// -public class Object { - /// - /// Default contructor - /// - public Object() => this.Type = "Object"; - - /// - /// https://www.w3.org/TR/activitypub/#obj-id - /// - public Uri? Id { get; set; } - - /// - /// https://www.w3.org/TR/activitystreams-vocabulary/#dfn-type - /// - public string Type { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#attachment - /// - public ObjectOrLink? Attachment { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#attributedTo - /// - public ObjectOrLink? AttributedTo { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#audience - /// - public ObjectOrLink? Audience { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#content - /// - public string? Content { get; set; } - - /// - /// https://www.w3.org/TR/activitypub/#source-property - /// - public ObjectOrLink? Source { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#context - /// - public ObjectOrLink? Context { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#name - /// - public string? Name { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#endTime - /// - public DateTimeOffset? EndTime { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#generator - /// - public ObjectOrLink? Generator { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#icon - /// - public GenericObjectOrLink? Icon { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#Image - /// - public Image? Image { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#inReplyTo - /// - public ObjectOrLink? InReplyTo { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#location - /// - public ObjectOrLink? Location { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#preview - /// - public ObjectOrLink? Preview { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#published - /// - public DateTimeOffset? Published { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#replies - /// - public Collection? Replies { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#startTime - /// - public DateTimeOffset? StartTime { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#summary - /// - public string? Summary { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#tag - /// - public ObjectOrLink? Tag { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#updated - /// - public DateTimeOffset? Updated { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#url - /// - public LinkOrUri? Url { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#to - /// - public ListOrLink? To { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#bto - /// - public ListOrLink? Bto { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#cc - /// - public ListOrLink? Cc { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#bcc - /// - public ListOrLink? Bcc { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#mediaType - /// - public string? MediaType { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#duration - /// - public string? Duration { get; set; } - - /// - /// https://www.w3.org/TR/activitypub/#likes - /// - public ListOrLink? Likes { get; set; } - - /// - /// https://www.w3.org/TR/activitypub/#shares - /// - public ListOrLink? 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); - //} -} \ No newline at end of file diff --git a/Models/Objects/Article.cs b/Models/Objects/Article.cs deleted file mode 100644 index f2d834d..0000000 --- a/Models/Objects/Article.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Article -/// -public class Article : Object { - - /// - /// Default Constructor - /// - public Article() : base() => this.Type = "Article"; - -} \ No newline at end of file diff --git a/Models/Objects/Audio.cs b/Models/Objects/Audio.cs deleted file mode 100644 index c8fa0ac..0000000 --- a/Models/Objects/Audio.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Audio -/// -public class Audio : Document { - - /// - /// Default Constructor - /// - public Audio() : base() => this.Type = "Audio"; - -} \ No newline at end of file diff --git a/Models/Objects/Document.cs b/Models/Objects/Document.cs deleted file mode 100644 index cac11ca..0000000 --- a/Models/Objects/Document.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Document -/// -public class Document : Object { - - /// - /// Default Constructor - /// - public Document() : base() => this.Type = "Document"; - -} \ No newline at end of file diff --git a/Models/Objects/Event.cs b/Models/Objects/Event.cs deleted file mode 100644 index 63101ea..0000000 --- a/Models/Objects/Event.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Event -/// -public class Event : Object { - - /// - /// Default Constructor - /// - public Event() : base() => this.Type = "Event"; - -} \ No newline at end of file diff --git a/Models/Objects/Image.cs b/Models/Objects/Image.cs deleted file mode 100644 index 9942469..0000000 --- a/Models/Objects/Image.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Image -/// -public class Image : Document { - - /// - /// Default Constructor - /// - public Image() : base() => this.Type = "Image"; - -} \ No newline at end of file diff --git a/Models/Objects/Note.cs b/Models/Objects/Note.cs deleted file mode 100644 index defa60a..0000000 --- a/Models/Objects/Note.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Note -/// -public class Note : Object { - - /// - /// Default Constructor - /// - public Note() : base() => this.Type = "Note"; - -} - diff --git a/Models/Objects/Page.cs b/Models/Objects/Page.cs deleted file mode 100644 index fb4753f..0000000 --- a/Models/Objects/Page.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Page -/// -public class Page : Document { - - /// - /// Default Constructor - /// - public Page() : base() => this.Type = "Page"; - -} \ No newline at end of file diff --git a/Models/Objects/Place.cs b/Models/Objects/Place.cs deleted file mode 100644 index 46d199e..0000000 --- a/Models/Objects/Place.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Place -/// -public class Place : Object { - - /// - /// Default Constructor - /// - public Place() : base() => this.Type = "Place"; - - /// - /// https://www.w3.org/ns/activitystreams#accuracy - /// - public float? Accuracy { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#altitude - /// - public float? Altitude { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#latitude - /// - public float? Latitude { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#longitude - /// - public float? Longitude { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#radius - /// - public float? Radius { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#units - /// - public string? Units { get; set; } -} \ No newline at end of file diff --git a/Models/Objects/Profile.cs b/Models/Objects/Profile.cs deleted file mode 100644 index e7e40eb..0000000 --- a/Models/Objects/Profile.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Profile -/// -public class Profile : Object { - - /// - /// Default Constructor - /// - public Profile() : base() => this.Type = "Profile"; - - /// - /// https://www.w3.org/ns/activitystreams#describes - /// - public ObjectOrLink? Describes { get; set; } -} \ No newline at end of file diff --git a/Models/Objects/Relationship.cs b/Models/Objects/Relationship.cs deleted file mode 100644 index 4313fa4..0000000 --- a/Models/Objects/Relationship.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Relationship -/// -public class Relationship : Object { - - /// - /// Default Constructor - /// - public Relationship() : base() => this.Type = "Relationship"; - - /// - /// https://www.w3.org/ns/activitystreams#subject - /// - public ObjectOrLink? Subject { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#Object - /// - public ObjectOrLink? Object { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#Relationship - /// - // 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; } -} \ No newline at end of file diff --git a/Models/Objects/Tombstone.cs b/Models/Objects/Tombstone.cs deleted file mode 100644 index f26b4a3..0000000 --- a/Models/Objects/Tombstone.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Tombstone -/// -public class Tombstone : Object { - - /// - /// Default Constructor - /// - public Tombstone() : base() => this.Type = "Tombstone"; - - /// - /// https://www.w3.org/ns/activitystreams#formerType - /// - public string? FormerType { get; set; } - - /// - /// https://www.w3.org/ns/activitystreams#deleted - /// - public DateTimeOffset? Deleted { get; set; } -} \ No newline at end of file diff --git a/Models/Objects/Video.cs b/Models/Objects/Video.cs deleted file mode 100644 index 91854a0..0000000 --- a/Models/Objects/Video.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#Video -/// -public class Video : Document { - - /// - /// Default Constructor - /// - public Video() : base() => this.Type = "Video"; - -} \ No newline at end of file diff --git a/Models/OrderedCollection.cs b/Models/OrderedCollection.cs deleted file mode 100644 index c86c45d..0000000 --- a/Models/OrderedCollection.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#OrderedCollection -/// -public class OrderedCollection : Collection { - - /// - /// Default Constructor - /// - public OrderedCollection() : base() => this.Type = "OrderedCollection"; -} \ No newline at end of file diff --git a/Models/OrderedCollectionPage.cs b/Models/OrderedCollectionPage.cs deleted file mode 100644 index 27275cf..0000000 --- a/Models/OrderedCollectionPage.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace ActivityPub; - -/// -/// https://www.w3.org/ns/activitystreams#OrderedCollectionPage -/// -public class OrderedCollectionPage : CollectionPage { - - /// - /// Default Constructor - /// - public OrderedCollectionPage() : base() => this.Type = "OrderedCollectionPage"; - - /// - /// https://www.w3.org/ns/activitystreams#startIndex - /// - public uint StartIndex { get; set; } -} \ No newline at end of file diff --git a/ObjectStore.cs b/ObjectStore.cs index 42a0417..a6859d8 100644 --- a/ObjectStore.cs +++ b/ObjectStore.cs @@ -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> _objects = new(); + private static Dictionary> _objects = new(); private IUrlHelper Url { get; set; } /// @@ -36,7 +38,7 @@ public class ObjectStore { /// The new Object to be stored /// (with updated properties such as Id, Bto and Bcc removed, etc.) /// - 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 { /// /// The Id to find /// The object with the corresponding id, or null if not found - public KristofferStrube.ActivityStreams.Object? GetObjectById(string id) { - foreach (Dictionary list in _objects.Values) { - foreach (KeyValuePair kvp in list) { + public Object? GetObjectById(string id) { + foreach (Dictionary list in _objects.Values) { + foreach (KeyValuePair kvp in list) { if (kvp.Key == id) return kvp.Value; } } @@ -70,7 +72,7 @@ public class ObjectStore { /// The type /// /// - 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 { /// /// The type of object to retrieve /// A list of objects of the specified type - public List GetObjectsByType(string type) { + public List GetObjectsByType(string type) { type = Types.Normalize(type); - return _objects[type]?.Values.ToList() ?? new List(); + return _objects[type]?.Values.ToList() ?? new List(); } } diff --git a/Program.cs b/Program.cs index efbb7b2..fa8ff4d 100644 --- a/Program.cs +++ b/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()); - //options.JsonSerializerOptions.Converters.Add(new OneOrMultipleConverter()); - //options.JsonSerializerOptions.Converters.Add(new OneOrMultipleConverter()); - //options.JsonSerializerOptions.Converters.Add(new OneOrMultipleConverter>()); }); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle diff --git a/Repositories/ActivityPubContext.cs b/Repositories/ActivityPubContext.cs new file mode 100644 index 0000000..3a23096 --- /dev/null +++ b/Repositories/ActivityPubContext.cs @@ -0,0 +1,74 @@ +using KristofferStrube.ActivityStreams; +using Microsoft.EntityFrameworkCore; +using System.Net.Mail; +using Object = KristofferStrube.ActivityStreams.Object; + +namespace ActivityPub.Repositories; + +/// +/// Database Context for ActivityPub objects (using EF and SQLite) +/// +public class ActivityPubContext : DbContext { + + /// + /// The table to store Activities + /// + public DbSet Activities { get; set; } + + /// + /// The table to store Objects + /// + public DbSet Objects { get; set; } + + /// + /// The path to the sqlite database file + /// + public string DbPath { get; } + + /// + /// Default constructor + /// + public ActivityPubContext() { + var folder = Environment.SpecialFolder.LocalApplicationData; + var path = Environment.GetFolderPath(folder); + DbPath = System.IO.Path.Join(path, "activitypub.db"); + } + + /// + /// The following configures EF to create a Sqlite database file in the + /// special "local" folder for your platform. + /// + /// + protected override void OnConfiguring(DbContextOptionsBuilder options) { + options.UseSqlite($"Data Source={DbPath}"); + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) { + modelBuilder.Entity().HasMany(_ => _.Actor as IEnumerable); + modelBuilder.Entity().HasMany(_ => _.Object as IEnumerable); + modelBuilder.Entity().HasMany(_ => _.Target as IEnumerable); + modelBuilder.Entity().HasMany(_ => _.Result as IEnumerable); + modelBuilder.Entity().HasMany(_ => _.Origin as IEnumerable); + modelBuilder.Entity().HasMany(_ => _.Instrument as IEnumerable); + + + modelBuilder.Entity().HasMany(_ => _.Attachment as IEnumerable); + modelBuilder.Entity().HasMany(_ => _.AttributedTo as IEnumerable); + modelBuilder.Entity().HasMany(_ => _.Audience as IEnumerable); + modelBuilder.Entity().HasMany(_ => _.Bcc as IEnumerable); + modelBuilder.Entity().HasMany(_ => _.Bto as IEnumerable); + modelBuilder.Entity().HasMany(_ => _.Cc as IEnumerable); + modelBuilder.Entity().HasMany(_ => _.Context as IEnumerable); + modelBuilder.Entity().HasMany(_ => _.Generator as IEnumerable); + modelBuilder.Entity().HasMany(_ => _.Icon as IEnumerable); + modelBuilder.Entity().HasMany(_ => _.Image as IEnumerable); + modelBuilder.Entity().HasMany(_ => _.InReplyTo as IEnumerable); + modelBuilder.Entity().HasMany(_ => _.Location as IEnumerable); + modelBuilder.Entity().HasMany(_ => _.Tag as IEnumerable); + modelBuilder.Entity().HasMany(_ => _.To as IEnumerable); + modelBuilder.Entity().HasMany(_ => _.Url as IEnumerable); + modelBuilder.Entity().Ignore(_ => _.ExtensionData); + //modelBuilder.Entity().HasMany(_ => _.Content as IList); + + } +} diff --git a/ap.net.csproj b/ap.net.csproj index b291907..c7e5343 100644 --- a/ap.net.csproj +++ b/ap.net.csproj @@ -15,8 +15,13 @@ - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive +