diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-10-16 08:58:54 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-10-16 08:58:54 +0900 |
| commit | 1c9c4af9f100ae970067e6bf0cdec188a6d75dad (patch) | |
| tree | 56de697323969b7f02f562940950d69ab87fd74f /src/server | |
| parent | Add some tests (diff) | |
| parent | Implement /api/v1/instance/peers (#2913) (diff) | |
| download | sharkey-1c9c4af9f100ae970067e6bf0cdec188a6d75dad.tar.gz sharkey-1c9c4af9f100ae970067e6bf0cdec188a6d75dad.tar.bz2 sharkey-1c9c4af9f100ae970067e6bf0cdec188a6d75dad.zip | |
Merge branch 'develop' of https://github.com/syuilo/misskey into develop
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/api/index.ts | 2 | ||||
| -rw-r--r-- | src/server/api/mastodon.ts | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/server/api/index.ts b/src/server/api/index.ts index c68f109ae1..33e98f650a 100644 --- a/src/server/api/index.ts +++ b/src/server/api/index.ts @@ -46,6 +46,8 @@ router.post('/signin', require('./private/signin').default); router.use(require('./service/github').routes()); router.use(require('./service/twitter').routes()); +router.use(require('./mastodon').routes()); + // Return 404 for unknown API router.all('*', async ctx => { ctx.status = 404; diff --git a/src/server/api/mastodon.ts b/src/server/api/mastodon.ts new file mode 100644 index 0000000000..f2ce1c384f --- /dev/null +++ b/src/server/api/mastodon.ts @@ -0,0 +1,14 @@ +import * as Router from 'koa-router'; +import User from '../../models/user'; +import { toASCII } from 'punycode'; + +// Init router +const router = new Router(); + +router.get('/v1/instance/peers', async ctx => { + const peers = await User.distinct('host', { host: { $ne: null } }) as any as string[]; + const punyCodes = peers.map(peer => toASCII(peer)); + ctx.body = punyCodes; +}); + +module.exports = router; |