Merge branch 'develop' into sw-notification-action
This commit is contained in:
43
src/server/api/endpoints/federation/dns.ts
Normal file
43
src/server/api/endpoints/federation/dns.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { promises as dns } from 'dns';
|
||||
import $ from 'cafy';
|
||||
import define from '../../define';
|
||||
import { Instances } from '../../../../models';
|
||||
import { toPuny } from '@/misc/convert-host';
|
||||
|
||||
const resolver = new dns.Resolver();
|
||||
resolver.setServers(['1.1.1.1']);
|
||||
|
||||
export const meta = {
|
||||
tags: ['federation'],
|
||||
|
||||
requireCredential: false as const,
|
||||
|
||||
params: {
|
||||
host: {
|
||||
validator: $.str
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default define(meta, async (ps, me) => {
|
||||
const instance = await Instances.findOneOrFail({ host: toPuny(ps.host) });
|
||||
|
||||
const [
|
||||
resolved4,
|
||||
resolved6,
|
||||
resolvedCname,
|
||||
resolvedTxt,
|
||||
] = await Promise.all([
|
||||
resolver.resolve4(instance.host).catch(() => []),
|
||||
resolver.resolve6(instance.host).catch(() => []),
|
||||
resolver.resolveCname(instance.host).catch(() => []),
|
||||
resolver.resolveTxt(instance.host).catch(() => []),
|
||||
]);
|
||||
|
||||
return {
|
||||
a: resolved4,
|
||||
aaaa: resolved6,
|
||||
cname: resolvedCname,
|
||||
txt: resolvedTxt,
|
||||
};
|
||||
});
|
@@ -1,6 +1,7 @@
|
||||
import { USER_ONLINE_THRESHOLD } from '@/const';
|
||||
import { Users } from '@/models';
|
||||
import { MoreThan } from 'typeorm';
|
||||
import define from '../define';
|
||||
import { redisClient } from '../../../db/redis';
|
||||
import config from '@/config';
|
||||
|
||||
export const meta = {
|
||||
tags: ['meta'],
|
||||
@@ -11,12 +12,12 @@ export const meta = {
|
||||
}
|
||||
};
|
||||
|
||||
export default define(meta, (ps, user) => {
|
||||
return new Promise((res, rej) => {
|
||||
redisClient.pubsub('numsub', config.host, (_, x) => {
|
||||
res({
|
||||
count: x[1]
|
||||
});
|
||||
});
|
||||
export default define(meta, async () => {
|
||||
const count = await Users.count({
|
||||
lastActiveDate: MoreThan(new Date(Date.now() - USER_ONLINE_THRESHOLD))
|
||||
});
|
||||
|
||||
return {
|
||||
count
|
||||
};
|
||||
});
|
||||
|
@@ -96,6 +96,10 @@ export const meta = {
|
||||
validator: $.optional.bool,
|
||||
},
|
||||
|
||||
hideOnlineStatus: {
|
||||
validator: $.optional.bool,
|
||||
},
|
||||
|
||||
carefulBot: {
|
||||
validator: $.optional.bool,
|
||||
desc: {
|
||||
@@ -228,6 +232,7 @@ export default define(meta, async (ps, _user, token) => {
|
||||
if (ps.mutingNotificationTypes !== undefined) profileUpdates.mutingNotificationTypes = ps.mutingNotificationTypes as typeof notificationTypes[number][];
|
||||
if (typeof ps.isLocked === 'boolean') updates.isLocked = ps.isLocked;
|
||||
if (typeof ps.isExplorable === 'boolean') updates.isExplorable = ps.isExplorable;
|
||||
if (typeof ps.hideOnlineStatus === 'boolean') updates.hideOnlineStatus = ps.hideOnlineStatus;
|
||||
if (typeof ps.isBot === 'boolean') updates.isBot = ps.isBot;
|
||||
if (typeof ps.carefulBot === 'boolean') profileUpdates.carefulBot = ps.carefulBot;
|
||||
if (typeof ps.autoAcceptFollowed === 'boolean') profileUpdates.autoAcceptFollowed = ps.autoAcceptFollowed;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '../../../../misc/cafy-id';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { readNotification } from '../../common/read-notification';
|
||||
|
||||
|
@@ -6,6 +6,7 @@ import { ParsedUrlQuery } from 'querystring';
|
||||
import authenticate from './authenticate';
|
||||
import { EventEmitter } from 'events';
|
||||
import { subsdcriber as redisClient } from '../../db/redis';
|
||||
import { Users } from '@/models';
|
||||
|
||||
module.exports = (server: http.Server) => {
|
||||
// Init websocket server
|
||||
@@ -34,10 +35,22 @@ module.exports = (server: http.Server) => {
|
||||
|
||||
const main = new MainStreamConnection(connection, ev, user, app);
|
||||
|
||||
const intervalId = user ? setInterval(() => {
|
||||
Users.update(user.id, {
|
||||
lastActiveDate: new Date(),
|
||||
});
|
||||
}, 1000 * 60 * 5) : null;
|
||||
if (user) {
|
||||
Users.update(user.id, {
|
||||
lastActiveDate: new Date(),
|
||||
});
|
||||
}
|
||||
|
||||
connection.once('close', () => {
|
||||
ev.removeAllListeners();
|
||||
main.dispose();
|
||||
redisClient.off('message', onRedisMessage);
|
||||
if (intervalId) clearInterval(intervalId);
|
||||
});
|
||||
|
||||
connection.on('message', async (data) => {
|
||||
|
@@ -99,7 +99,7 @@ router.get('/manifest.json', require('./manifest'));
|
||||
|
||||
router.get('/robots.txt', async ctx => {
|
||||
await send(ctx as any, '/robots.txt', {
|
||||
root: assets
|
||||
root: staticAssets
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -2,7 +2,11 @@ block vars
|
||||
|
||||
doctype html
|
||||
|
||||
!= '\n<!-- Thank you for using Misskey! @syuilo -->\n'
|
||||
!= '\n'
|
||||
!= '<!-- Thank you for using Misskey! -->\n'
|
||||
!= '<!-- If you are reading this message... how about joining the development of Misskey? -->\n'
|
||||
!= '<!-- https://github.com/misskey-dev/misskey -->'
|
||||
!= '\n'
|
||||
|
||||
html
|
||||
|
||||
@@ -20,13 +24,15 @@ html
|
||||
link(rel='prefetch' href='https://xn--931a.moe/assets/info.jpg')
|
||||
link(rel='prefetch' href='https://xn--931a.moe/assets/not-found.jpg')
|
||||
link(rel='prefetch' href='https://xn--931a.moe/assets/error.jpg')
|
||||
link(rel='preload' href='https://use.fontawesome.com/releases/v5.15.3/css/all.css' as='style')
|
||||
link(rel='stylesheet' href='https://use.fontawesome.com/releases/v5.15.3/css/all.css')
|
||||
|
||||
title
|
||||
block title
|
||||
= title || 'Misskey'
|
||||
|
||||
block desc
|
||||
meta(name='description' content= desc || '✨🌎✨ A federated blogging platform ✨🚀✨')
|
||||
meta(name='description' content= desc || '✨🌎✨ A interplanetary communication platform ✨🚀✨')
|
||||
|
||||
block meta
|
||||
|
||||
|
Reference in New Issue
Block a user