mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 14:05:46 +01:00
feat: support for FEP fb2a (new-style account metadata)
This commit is contained in:
@@ -42,6 +42,9 @@ ActivityPub._constants = Object.freeze({
|
|||||||
acceptableActorTypes: new Set(['Application', 'Group', 'Organization', 'Person', 'Service']),
|
acceptableActorTypes: new Set(['Application', 'Group', 'Organization', 'Person', 'Service']),
|
||||||
requiredActorProps: ['inbox', 'outbox'],
|
requiredActorProps: ['inbox', 'outbox'],
|
||||||
acceptedProtocols: ['https', ...(process.env.CI === 'true' ? ['http'] : [])],
|
acceptedProtocols: ['https', ...(process.env.CI === 'true' ? ['http'] : [])],
|
||||||
|
acceptable: {
|
||||||
|
customFields: new Set(['PropertyValue', 'Link', 'Note']),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
ActivityPub._cache = requestCache;
|
ActivityPub._cache = requestCache;
|
||||||
|
|
||||||
|
|||||||
@@ -71,10 +71,31 @@ Mocks.profile = async (actors, hostMap) => {
|
|||||||
// Add custom fields into user hash
|
// Add custom fields into user hash
|
||||||
const customFields = actor.attachment && Array.isArray(actor.attachment) && actor.attachment.length ?
|
const customFields = actor.attachment && Array.isArray(actor.attachment) && actor.attachment.length ?
|
||||||
actor.attachment
|
actor.attachment
|
||||||
.filter(attachment => attachment.type === 'PropertyValue')
|
.filter(attachment => activitypub._constants.acceptable.customFields.has(attachment.type))
|
||||||
.reduce((map, { name, value }) => {
|
.reduce((map, { type, name, value, href, content }) => {
|
||||||
|
// Defer to new style (per FEP fb2a)
|
||||||
|
if (map.has(name) && type === 'PropertyValue') {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
// Strip html from received values (for security)
|
// Strip html from received values (for security)
|
||||||
|
switch (type) {
|
||||||
|
case 'Note': {
|
||||||
|
value = utils.stripHTMLTags(content);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'Link': {
|
||||||
|
value = utils.stripHTMLTags(href);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'PropertyValue': {
|
||||||
value = utils.stripHTMLTags(value);
|
value = utils.stripHTMLTags(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return map.set(name, value);
|
return map.set(name, value);
|
||||||
}, new Map()) :
|
}, new Map()) :
|
||||||
undefined;
|
undefined;
|
||||||
@@ -205,8 +226,23 @@ Mocks.actors.user = async (uid) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const attachment = [];
|
const attachment = [];
|
||||||
fields.forEach(({ name, value }) => {
|
fields.forEach(({ type, name, value }) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
|
if (type === 'input-link') {
|
||||||
|
attachment.push({
|
||||||
|
type: 'Link',
|
||||||
|
name,
|
||||||
|
href: value,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
attachment.push({
|
||||||
|
type: 'Note',
|
||||||
|
name,
|
||||||
|
content: value,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Backwards compatibility
|
||||||
attachment.push({
|
attachment.push({
|
||||||
type: 'PropertyValue',
|
type: 'PropertyValue',
|
||||||
name,
|
name,
|
||||||
|
|||||||
Reference in New Issue
Block a user