From 84a8dc73964af5c4396fd44e611511a693bb8752 Mon Sep 17 00:00:00 2001 From: SiRanWeb Date: Sun, 30 Oct 2022 18:22:44 +0300 Subject: [PATCH] Add Mention types and fix Link --- src/common/common.types.ts | 1 + src/models/link/Link.model.ts | 10 ++++++++++ src/models/mention/Mention.model.ts | 16 ++++++++++++++++ src/models/mention/Mention.types.ts | 3 +++ 4 files changed, 30 insertions(+) create mode 100644 src/models/mention/Mention.model.ts create mode 100644 src/models/mention/Mention.types.ts diff --git a/src/common/common.types.ts b/src/common/common.types.ts index 23c93f6..1012ab0 100644 --- a/src/common/common.types.ts +++ b/src/common/common.types.ts @@ -22,6 +22,7 @@ export enum ASModelType { Tombstone = 'Tombstone', Profile = 'Profile', Link = 'Link', + Mention = 'Mention', } // TODO: implement diff --git a/src/models/link/Link.model.ts b/src/models/link/Link.model.ts index c6a982a..28c538e 100644 --- a/src/models/link/Link.model.ts +++ b/src/models/link/Link.model.ts @@ -2,6 +2,16 @@ import {ASBase} from "../asBase/ASBase.model"; import { LinkFields } from "./Link.types"; import {ASModelType} from "../../common/common.types"; +/** + * A Link is an indirect, qualified reference to a resource identified by a URL. + * The fundamental model for links is established by [RFC5988]. Many of the properties + * defined by the Activity Vocabulary allow values that are either instances of Object + * or Link. When a Link is used, it establishes a qualified relation connecting the + * subject (the containing object) to the resource identified by the href. Properties + * of the Link are properties of the reference as opposed to properties of the resource. + * + * {@link https://www.w3.org/ns/activitystreams#Link Docs} + */ export class Link extends ASBase{ constructor(fields: LinkFields) { super({ diff --git a/src/models/mention/Mention.model.ts b/src/models/mention/Mention.model.ts new file mode 100644 index 0000000..a46f7b6 --- /dev/null +++ b/src/models/mention/Mention.model.ts @@ -0,0 +1,16 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {MentionFields} from "./Mention.types"; +import {ASModelType} from "../../common/common.types"; +/** + * A specialized Link that represents an @mention. + * + * {@link https://www.w3.org/ns/activitystreams#Mention Docs} + */ +export class Mention extends ASBase{ + constructor(fields: MentionFields) { + super({ + type: ASModelType.Mention, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/mention/Mention.types.ts b/src/models/mention/Mention.types.ts new file mode 100644 index 0000000..c25e146 --- /dev/null +++ b/src/models/mention/Mention.types.ts @@ -0,0 +1,3 @@ +import {LinkFields} from "../link/Link.types"; + +export interface MentionFields extends LinkFields {}