server: implement FEP-e232 style quotes #318
Loading…
Reference in a new issue
No description provided.
Delete branch "federation-quote"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This implements (yet another) way of federating quotes (in&out) as laid out in FEP-e232.
Took some code from a previous PR to Misskey, rewrote some other parts.
extractQuoteUrl()
@ -19,0 +28,4 @@
[
'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
'application/activity+json'
].includes(link.mediaType?.toLowerCase())
i'd instead do
toArray(tags).filter(hasRel)
because the link relation is what is doing all the semantic heavy-liftingThis part is to implement the FEP because it says that this media type is required.
@ -19,0 +38,4 @@
toArray(link.rel)
.includes('https://misskey-hub.net/ns#_misskey_quote')
}
quotes.sort((a, b) => {
as above: replace this sort with a second filter that only runs if no tags have a rel=quote
Since the FEP says the media type is required and we want to require the
rel
as well, I've changed it to filter by both in one go. I'll also accept any URI that was accepted as a JSON-LD property before, in hopes of not having to adjust this rel array.@ -19,0 +47,4 @@
if (quotes.length === 0) return null;
// If there is more than one quote, we just pick the first/a random one.
is this a valid assumption? should any Link with a correct mediaType be considered a quote? should you only consider the first object link, or should you maybe consider object links that are at the end of
content
?@ -280,2 +280,4 @@
}
export interface ILink extends IObject {
type: 'Link';
type
may not be alwaysLink
. it may be an extension or subclass ofLink
. a Link is just a node that hashref
(and optionallyrel
,mediaType
,name
,hreflang
,height
, width,
preview`)also i'm not sure if
IObject
as an interface follows the activitypub Object definition, but if it does, then note thatObject
andLink
are actually disjoint -- an Object is not a Link, and a Link is not an Object. for example, a Link does not require anid
.essentially i'd use the following interface definition instead:
although it's okay to leave out the properties you don't need i suppose
@ -293,3 +300,11 @@ export const isLike = (object: IObject): object is ILike => getApType(object) ==
export const isAnnounce = (object: IObject): object is IAnnounce => getApType(object) === 'Announce';
export const isBlock = (object: IObject): object is IBlock => getApType(object) === 'Block';
export const isFlag = (object: IObject): object is IFlag => getApType(object) === 'Flag';
export const isLink = (object: IObject): object is ILink => getApType(object) === 'Link'
remove
getApType(object) === 'Link'