Merge branch 'develop' into sw-notification-action
This commit is contained in:
commit
212eec2042
313 changed files with 3307 additions and 2363 deletions
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) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue