Merge pull request #2474 from mei23/mei-0825-appleroma2
Pleromaとつながらないのを修正
This commit is contained in:
commit
d9b02a18bf
|
@ -6,6 +6,7 @@ export default (object: any, note: INote) => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: `${config.url}/notes/${note._id}`,
|
id: `${config.url}/notes/${note._id}`,
|
||||||
|
actor: `${config.url}/users/${note.userId}`,
|
||||||
type: 'Announce',
|
type: 'Announce',
|
||||||
published: note.createdAt.toISOString(),
|
published: note.createdAt.toISOString(),
|
||||||
to: ['https://www.w3.org/ns/activitystreams#Public'],
|
to: ['https://www.w3.org/ns/activitystreams#Public'],
|
||||||
|
|
|
@ -1,4 +1,17 @@
|
||||||
export default (object: any) => ({
|
import config from '../../../config';
|
||||||
|
import { INote } from '../../../models/note';
|
||||||
|
|
||||||
|
export default (object: any, note: INote) => {
|
||||||
|
const activity = {
|
||||||
|
id: `${config.url}/notes/${note._id}/activity`,
|
||||||
|
actor: `${config.url}/users/${note.userId}`,
|
||||||
type: 'Create',
|
type: 'Create',
|
||||||
|
published: note.createdAt.toISOString(),
|
||||||
object
|
object
|
||||||
});
|
} as any;
|
||||||
|
|
||||||
|
if (object.to) activity.to = object.to;
|
||||||
|
if (object.cc) activity.cc = object.cc;
|
||||||
|
|
||||||
|
return activity;
|
||||||
|
};
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
export default (object: any) => ({
|
import config from '../../../config';
|
||||||
|
import { ILocalUser } from "../../../models/user";
|
||||||
|
|
||||||
|
export default (object: any, user: ILocalUser) => ({
|
||||||
type: 'Delete',
|
type: 'Delete',
|
||||||
|
actor: `${config.url}/users/${user._id}`,
|
||||||
object
|
object
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,16 @@
|
||||||
export default (x: any) => Object.assign({
|
import config from '../../../config';
|
||||||
|
import * as uuid from 'uuid';
|
||||||
|
|
||||||
|
export default (x: any) => {
|
||||||
|
if (x !== null && typeof x === 'object' && x.id == null) {
|
||||||
|
x.id = `${config.url}/${uuid.v4()}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Object.assign({
|
||||||
'@context': [
|
'@context': [
|
||||||
'https://www.w3.org/ns/activitystreams',
|
'https://www.w3.org/ns/activitystreams',
|
||||||
'https://w3id.org/security/v1',
|
'https://w3id.org/security/v1',
|
||||||
{ Hashtag: 'as:Hashtag' }
|
{ Hashtag: 'as:Hashtag' }
|
||||||
]
|
]
|
||||||
}, x);
|
}, x);
|
||||||
|
};
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
export default (object: any) => ({
|
import config from '../../../config';
|
||||||
|
import { ILocalUser, IUser } from "../../../models/user";
|
||||||
|
|
||||||
|
export default (object: any, user: ILocalUser | IUser) => ({
|
||||||
type: 'Undo',
|
type: 'Undo',
|
||||||
|
actor: `${config.url}/users/${user._id}`,
|
||||||
object
|
object
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,6 +19,9 @@ export default (user: ILocalUser, url: string, object: any) => new Promise((reso
|
||||||
port,
|
port,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
path: pathname + search,
|
path: pathname + search,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/activity+json'
|
||||||
|
}
|
||||||
}, res => {
|
}, res => {
|
||||||
log(`${url} --> ${res.statusCode}`);
|
log(`${url} --> ${res.statusCode}`);
|
||||||
|
|
||||||
|
@ -32,7 +35,7 @@ export default (user: ILocalUser, url: string, object: any) => new Promise((reso
|
||||||
sign(req, {
|
sign(req, {
|
||||||
authorizationHeaderName: 'Signature',
|
authorizationHeaderName: 'Signature',
|
||||||
key: user.keypair,
|
key: user.keypair,
|
||||||
keyId: `acct:${user.username}@${config.host}`
|
keyId: `${config.url}/users/${user._id}/publickey`
|
||||||
});
|
});
|
||||||
|
|
||||||
// Signature: Signature ... => Signature: ...
|
// Signature: Signature ... => Signature: ...
|
||||||
|
|
|
@ -25,7 +25,7 @@ function inbox(ctx: Router.IRouterContext) {
|
||||||
ctx.req.headers.authorization = 'Signature ' + ctx.req.headers.signature;
|
ctx.req.headers.authorization = 'Signature ' + ctx.req.headers.signature;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
signature = httpSignature.parseRequest(ctx.req);
|
signature = httpSignature.parseRequest(ctx.req, { 'headers': [] });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ctx.status = 401;
|
ctx.status = 401;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -56,7 +56,7 @@ export default async function(follower: IUser, followee: IUser) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLocalUser(follower) && isRemoteUser(followee)) {
|
if (isLocalUser(follower) && isRemoteUser(followee)) {
|
||||||
const content = pack(renderUndo(renderFollow(follower, followee)));
|
const content = pack(renderUndo(renderFollow(follower, followee), follower));
|
||||||
deliver(follower, content, followee.inbox);
|
deliver(follower, content, followee.inbox);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { publishUserStream } from '../../../stream';
|
||||||
|
|
||||||
export default async function(followee: IUser, follower: IUser) {
|
export default async function(followee: IUser, follower: IUser) {
|
||||||
if (isRemoteUser(followee)) {
|
if (isRemoteUser(followee)) {
|
||||||
const content = pack(renderUndo(renderFollow(follower, followee)));
|
const content = pack(renderUndo(renderFollow(follower, followee), follower));
|
||||||
deliver(follower as ILocalUser, content, followee.inbox);
|
deliver(follower as ILocalUser, content, followee.inbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,7 @@ export default async (user: IUser, data: Option, silent = false) => new Promise<
|
||||||
async function renderActivity(data: Option, note: INote) {
|
async function renderActivity(data: Option, note: INote) {
|
||||||
const content = data.renote && data.text == null
|
const content = data.renote && data.text == null
|
||||||
? renderAnnounce(data.renote.uri ? data.renote.uri : `${config.url}/notes/${data.renote._id}`, note)
|
? renderAnnounce(data.renote.uri ? data.renote.uri : `${config.url}/notes/${data.renote._id}`, note)
|
||||||
: renderCreate(await renderNote(note, false));
|
: renderCreate(await renderNote(note, false), note);
|
||||||
|
|
||||||
return packAp(content);
|
return packAp(content);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ export default async function(user: IUser, note: INote) {
|
||||||
|
|
||||||
//#region ローカルの投稿なら削除アクティビティを配送
|
//#region ローカルの投稿なら削除アクティビティを配送
|
||||||
if (isLocalUser(user)) {
|
if (isLocalUser(user)) {
|
||||||
const content = pack(renderDelete(await renderNote(note)));
|
const content = pack(renderDelete(await renderNote(note), user));
|
||||||
|
|
||||||
const followings = await Following.find({
|
const followings = await Following.find({
|
||||||
followeeId: user._id,
|
followeeId: user._id,
|
||||||
|
|
Loading…
Reference in New Issue