diff --git a/package.json b/package.json index 8e263ea256ebfd7f8f924943bd9109aa56a09848..767de2559b4f5b78d6fdc0e78091778eb99951d9 100644 --- a/package.json +++ b/package.json @@ -143,7 +143,7 @@ "json5": "2.1.0", "json5-loader": "1.0.1", "katex": "0.10.0", - "koa": "2.6.1", + "koa": "2.6.2", "koa-bodyparser": "4.2.1", "koa-compress": "3.0.0", "koa-favicon": "2.0.1", @@ -237,7 +237,7 @@ "webpack": "4.26.0", "webpack-cli": "3.1.2", "websocket": "1.0.28", - "ws": "6.1.0", + "ws": "6.1.2", "xev": "2.0.1" } } diff --git a/src/remote/activitypub/models/note.ts b/src/remote/activitypub/models/note.ts index 82d6d267c2f2b8d91f42ee72c6b4b60d77d4d3f8..0f0f0bc2bf32d5cc7aefa2589dfe35f6444308bf 100644 --- a/src/remote/activitypub/models/note.ts +++ b/src/remote/activitypub/models/note.ts @@ -96,6 +96,13 @@ export async function createNote(value: any, resolver?: Resolver, silent = false // リプライ const reply = note.inReplyTo ? await resolveNote(note.inReplyTo, resolver) : null; + // 引用 + let quote: INote; + + if (note._misskey_quote && typeof note._misskey_quote == 'string') { + quote = await resolveNote(note._misskey_quote).catch(() => null); + } + // テã‚ストã®ãƒ‘ース const text = note._misskey_content ? note._misskey_content : htmlToMFM(note.content); @@ -112,7 +119,7 @@ export async function createNote(value: any, resolver?: Resolver, silent = false createdAt: new Date(note.published), files: files, reply, - renote: undefined, + renote: quote, cw: note.summary, text: text, viaMobile: false, diff --git a/src/remote/activitypub/renderer/note.ts b/src/remote/activitypub/renderer/note.ts index d6e2d612c772edc54ba7935e12038deb85e1fac5..a854ad9f1919eebbcb87bf9865f24ec266b7021d 100644 --- a/src/remote/activitypub/renderer/note.ts +++ b/src/remote/activitypub/renderer/note.ts @@ -42,6 +42,18 @@ export default async function renderNote(note: INote, dive = true): Promise<any> inReplyTo = null; } + let quote; + + if (note.renoteId) { + const renote = await Note.findOne({ + _id: note.renoteId, + }); + + if (renote) { + quote = renote.uri ? renote.uri : `${config.url}/notes/${renote._id}`; + } + } + const user = await User.findOne({ _id: note.userId }); @@ -112,6 +124,7 @@ export default async function renderNote(note: INote, dive = true): Promise<any> summary: note.cw, content, _misskey_content: text, + _misskey_quote: quote, published: note.createdAt.toISOString(), to, cc, diff --git a/src/remote/activitypub/type.ts b/src/remote/activitypub/type.ts index 23440350137216a2ab076a81c0373665022ef465..530aaa13db1d23d90064095006d19ac828db6f76 100644 --- a/src/remote/activitypub/type.ts +++ b/src/remote/activitypub/type.ts @@ -41,6 +41,7 @@ export interface IOrderedCollection extends IObject { export interface INote extends IObject { type: 'Note'; _misskey_content: string; + _misskey_quote: string; } export interface IPerson extends IObject { diff --git a/src/server/activitypub.ts b/src/server/activitypub.ts index 888feb08ced65c2af5ba897fec789da71e45e0ce..0d4e244856dfee39f6cd2c6ede1c3339603e0936 100644 --- a/src/server/activitypub.ts +++ b/src/server/activitypub.ts @@ -76,7 +76,7 @@ router.get('/notes/:note', async (ctx, next) => { } ctx.body = pack(await renderNote(note, false)); - ctx.set('Cache-Control', 'public, max-age=180'); + ctx.set('Cache-Control', 'private, max-age=0, must-revalidate'); setResponseType(ctx); }); diff --git a/src/server/api/common/signin.ts b/src/server/api/common/signin.ts index 8d44b377fe6914baad6dc0bc963a20ea45c6dc21..3a5ba0ea04fe2033cb470898a9bb531c488e83f8 100644 --- a/src/server/api/common/signin.ts +++ b/src/server/api/common/signin.ts @@ -9,8 +9,8 @@ export default function(ctx: Koa.Context, user: ILocalUser, redirect = false) { path: '/', domain: config.hostname, // SEE: https://github.com/koajs/koa/issues/974 - //secure: config.url.startsWith('https'), - secure: false, + // When using a SSL proxy it should be configured to add the "X-Forwarded-Proto: https" header + secure: config.url.startsWith('https'), httpOnly: false, expires: new Date(Date.now() + expires), maxAge: expires diff --git a/src/server/web/index.ts b/src/server/web/index.ts index 616aaa36bb81e30715d0cd810e99632922304155..42292cd398562d235c4502cfd048ad338a6203c3 100644 --- a/src/server/web/index.ts +++ b/src/server/web/index.ts @@ -111,7 +111,7 @@ router.get('/notes/:note', async ctx => { note: _note, summary: getNoteSummary(_note) }); - ctx.set('Cache-Control', 'public, max-age=180'); + ctx.set('Cache-Control', 'private, max-age=0, must-revalidate'); } else { ctx.status = 404; }