Skip to content

Commit

Permalink
feat(compat): Add support for Micropub (misskey-dev#9523)
Browse files Browse the repository at this point in the history
  • Loading branch information
chocolate-pie committed Feb 2, 2024
1 parent e21cece commit 3ccad99
Show file tree
Hide file tree
Showing 12 changed files with 1,294 additions and 79 deletions.
2 changes: 1 addition & 1 deletion locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4894,7 +4894,7 @@ export interface Locale extends ILocale {
*/
"readConfirmText": ParameterizedString<"title">;
/**
* 特に新規ユーザーのUXを損ねる可能性が高いため、ストック情報ではなくフロー情報の掲示にお知らせを使用することを推奨します
* 特に新規ユーザーのUXを損ねる可能性が高いため、常時掲示するための情報ではなく、即時性が求められる情報の掲示のためにお知らせを使用することを推奨します
*/
"shouldNotBeUsedToPresentPermanentInfo": string;
/**
Expand Down
22 changes: 22 additions & 0 deletions packages/backend/migration/1706599230317-support-micropub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* SPDX-FileCopyrightText: syuilo and other misskey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/

export class SupportMicropub1706599230317 {
name = 'SupportMicropub1706599230317'

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "drive_file" ADD "downloadedFrom" character varying(512)`);
await queryRunner.query(`ALTER TABLE "drive_file" ADD "createdByMicropub" boolean NOT NULL DEFAULT false`);
await queryRunner.query(`CREATE INDEX "IDX_209c886ff6705aa121d29f13c1" ON "drive_file" ("downloadedFrom") `);
await queryRunner.query(`CREATE INDEX "IDX_aa00d9f0d9c8c99c5dd17ecca8" ON "drive_file" ("createdByMicropub") `);
}

async down(queryRunner) {
await queryRunner.query(`DROP INDEX "public"."IDX_aa00d9f0d9c8c99c5dd17ecca8"`);
await queryRunner.query(`DROP INDEX "public"."IDX_209c886ff6705aa121d29f13c1"`);
await queryRunner.query(`ALTER TABLE "drive_file" DROP COLUMN "createdByMicropub"`);
await queryRunner.query(`ALTER TABLE "drive_file" DROP COLUMN "downloadedFrom"`);
}
}
1 change: 1 addition & 0 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"@fastify/cookie": "9.3.1",
"@fastify/cors": "8.5.0",
"@fastify/express": "2.3.0",
"@fastify/formbody": "^7.4.0",
"@fastify/http-proxy": "9.3.0",
"@fastify/multipart": "8.1.0",
"@fastify/static": "6.12.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/backend/src/core/DriveService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ type AddFileArgs = {
/** Extension to force */
ext?: string | null;

micropub?: boolean;
downloadedFrom?: string | null;
requestIp?: string | null;
requestHeaders?: Record<string, string> | null;
};
Expand Down Expand Up @@ -453,6 +455,8 @@ export class DriveService {
url = null,
uri = null,
sensitive = null,
micropub = false,
downloadedFrom = null,
requestIp = null,
requestHeaders = null,
ext = null,
Expand Down Expand Up @@ -572,6 +576,8 @@ export class DriveService {
file.properties = properties;
file.blurhash = info.blurhash ?? null;
file.isLink = isLink;
file.createdByMicropub = micropub;
file.downloadedFrom = downloadedFrom;
file.requestIp = requestIp;
file.requestHeaders = requestHeaders;
file.maybeSensitive = info.sensitive;
Expand Down
12 changes: 12 additions & 0 deletions packages/backend/src/models/DriveFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,16 @@ export class MiDriveFile {
length: 128, nullable: true,
})
public requestIp: string | null;

@Index()
@Column('varchar', {
length: 512, nullable: true,
})
public downloadedFrom: string | null;

@Index()
@Column('boolean', {
default: false,
})
public createdByMicropub: boolean;
}
2 changes: 2 additions & 0 deletions packages/backend/src/server/ServerModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { ClientServerService } from './web/ClientServerService.js';
import { FeedService } from './web/FeedService.js';
import { UrlPreviewService } from './web/UrlPreviewService.js';
import { ClientLoggerService } from './web/ClientLoggerService.js';
import { MicropubServerService } from './micropub/MicropubServerService.js';
import { OAuth2ProviderService } from './oauth/OAuth2ProviderService.js';

import { MainChannelService } from './api/stream/channels/main.js';
Expand Down Expand Up @@ -89,6 +90,7 @@ import { ReversiGameChannelService } from './api/stream/channels/reversi-game.js
ServerStatsChannelService,
UserListChannelService,
OpenApiServerService,
MicropubServerService,
OAuth2ProviderService,
],
exports: [
Expand Down
3 changes: 3 additions & 0 deletions packages/backend/src/server/ServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { WellKnownServerService } from './WellKnownServerService.js';
import { FileServerService } from './FileServerService.js';
import { ClientServerService } from './web/ClientServerService.js';
import { OpenApiServerService } from './api/openapi/OpenApiServerService.js';
import { MicropubServerService } from './micropub/MicropubServerService.js';
import { OAuth2ProviderService } from './oauth/OAuth2ProviderService.js';

const _dirname = fileURLToPath(new URL('.', import.meta.url));
Expand Down Expand Up @@ -65,6 +66,7 @@ export class ServerService implements OnApplicationShutdown {
private clientServerService: ClientServerService,
private globalEventService: GlobalEventService,
private loggerService: LoggerService,
private micropubServerService: MicropubServerService,
private oauth2ProviderService: OAuth2ProviderService,
) {
this.logger = this.loggerService.getLogger('server', 'gray', false);
Expand Down Expand Up @@ -107,6 +109,7 @@ export class ServerService implements OnApplicationShutdown {
fastify.register(this.activityPubServerService.createServer);
fastify.register(this.nodeinfoServerService.createServer);
fastify.register(this.wellKnownServerService.createServer);
fastify.register(this.micropubServerService.createServer, { prefix: '/micropub' });
fastify.register(this.oauth2ProviderService.createServer, { prefix: '/oauth' });
fastify.register(this.oauth2ProviderService.createTokenServer, { prefix: '/oauth/token' });

Expand Down
Loading

0 comments on commit 3ccad99

Please sign in to comment.