pub-relay (#6341)
* pub-relay * relay actorをApplicationにする * Disable koa-compress * Homeはリレーに送らない * Disable debug * UI * cleanupなど
This commit is contained in:
14
src/remote/activitypub/renderer/follow-relay.ts
Normal file
14
src/remote/activitypub/renderer/follow-relay.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import config from '../../../config';
|
||||
import { Relay } from '../../../models/entities/relay';
|
||||
import { ILocalUser } from '../../../models/entities/user';
|
||||
|
||||
export function renderFollowRelay(relay: Relay, relayActor: ILocalUser) {
|
||||
const follow = {
|
||||
id: `${config.url}/activities/follow-relay/${relay.id}`,
|
||||
type: 'Follow',
|
||||
actor: `${config.url}/users/${relayActor.id}`,
|
||||
object: 'https://www.w3.org/ns/activitystreams#Public'
|
||||
};
|
||||
|
||||
return follow;
|
||||
}
|
@@ -1,7 +1,12 @@
|
||||
import config from '../../../config';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { IActivity } from '../type';
|
||||
import { LdSignature } from '../misc/ld-signature';
|
||||
import { ILocalUser } from '../../../models/entities/user';
|
||||
import { UserKeypairs } from '../../../models';
|
||||
import { ensure } from '../../../prelude/ensure';
|
||||
|
||||
export const renderActivity = (x: any) => {
|
||||
export const renderActivity = (x: any): IActivity | null => {
|
||||
if (x == null) return null;
|
||||
|
||||
if (x !== null && typeof x === 'object' && x.id == null) {
|
||||
@@ -11,8 +16,46 @@ export const renderActivity = (x: any) => {
|
||||
return Object.assign({
|
||||
'@context': [
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
'https://w3id.org/security/v1',
|
||||
{ Hashtag: 'as:Hashtag' }
|
||||
'https://w3id.org/security/v1'
|
||||
]
|
||||
}, x);
|
||||
};
|
||||
|
||||
export const attachLdSignature = async (activity: any, user: ILocalUser): Promise<IActivity | null> => {
|
||||
if (activity == null) return null;
|
||||
|
||||
const keypair = await UserKeypairs.findOne({
|
||||
userId: user.id
|
||||
}).then(ensure);
|
||||
|
||||
const obj = {
|
||||
// as non-standards
|
||||
manuallyApprovesFollowers: 'as:manuallyApprovesFollowers',
|
||||
sensitive: 'as:sensitive',
|
||||
Hashtag: 'as:Hashtag',
|
||||
quoteUrl: 'as:quoteUrl',
|
||||
// Mastodon
|
||||
toot: 'http://joinmastodon.org/ns#',
|
||||
Emoji: 'toot:Emoji',
|
||||
featured: 'toot:featured',
|
||||
// schema
|
||||
schema: 'http://schema.org#',
|
||||
PropertyValue: 'schema:PropertyValue',
|
||||
value: 'schema:value',
|
||||
// Misskey
|
||||
misskey: `${config.url}/ns#`,
|
||||
'_misskey_content': 'misskey:_misskey_content',
|
||||
'_misskey_quote': 'misskey:_misskey_quote',
|
||||
'_misskey_reaction': 'misskey:_misskey_reaction',
|
||||
'_misskey_votes': 'misskey:_misskey_votes',
|
||||
'_misskey_talk': 'misskey:_misskey_talk',
|
||||
};
|
||||
|
||||
activity['@context'].push(obj);
|
||||
|
||||
const ldSignature = new LdSignature();
|
||||
ldSignature.debug = false;
|
||||
activity = await ldSignature.signRsaSignature2017(activity, keypair.privateKey, `${config.url}/users/${user.id}#main-key`);
|
||||
|
||||
return activity;
|
||||
};
|
||||
|
@@ -13,6 +13,7 @@ import { ensure } from '../../../prelude/ensure';
|
||||
|
||||
export async function renderPerson(user: ILocalUser) {
|
||||
const id = `${config.url}/users/${user.id}`;
|
||||
const isSystem = !!user.username.match(/\./);
|
||||
|
||||
const [avatar, banner, profile] = await Promise.all([
|
||||
user.avatarId ? DriveFiles.findOne(user.avatarId) : Promise.resolve(undefined),
|
||||
@@ -52,7 +53,7 @@ export async function renderPerson(user: ILocalUser) {
|
||||
const keypair = await UserKeypairs.findOne(user.id).then(ensure);
|
||||
|
||||
return {
|
||||
type: user.isBot ? 'Service' : 'Person',
|
||||
type: isSystem ? 'Application' : user.isBot ? 'Service' : 'Person',
|
||||
id,
|
||||
inbox: `${id}/inbox`,
|
||||
outbox: `${id}/outbox`,
|
||||
|
Reference in New Issue
Block a user