mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: upgrade to context tracing
This commit is contained in:
9 files changed
+42
-38
No files matched your search
@@ -179,7 +179,6 @@ export class HomeHandler extends Handler {
|
||||
}
|
||||
}
|
||||
|
||||
let geoip: Context['geoip'] = null;
|
||||
class HomeSecurityHandler extends Handler {
|
||||
@requireSudo
|
||||
async get() {
|
||||
@@ -189,7 +188,7 @@ class HomeSecurityHandler extends Handler {
|
||||
session.isCurrent = session._id === this.session._id;
|
||||
session._id = md5(session._id);
|
||||
session.updateUa = useragent.parse(session.updateUa || session.createUa || '');
|
||||
session.updateGeoip = geoip?.lookup?.(
|
||||
session.updateGeoip = this.ctx.geoip?.lookup?.(
|
||||
session.updateIp || session.createIp,
|
||||
this.translate('geoip_locale'),
|
||||
);
|
||||
@@ -202,7 +201,7 @@ class HomeSecurityHandler extends Handler {
|
||||
'credentialID', 'name', 'credentialType', 'credentialDeviceType',
|
||||
'authenticatorAttachment', 'regat', 'fmt',
|
||||
])),
|
||||
geoipProvider: geoip?.provider,
|
||||
geoipProvider: this.ctx?.geoip?.provider,
|
||||
icon: (str = '') => str.split(' ')[0].toLowerCase(),
|
||||
};
|
||||
}
|
||||
@@ -591,10 +590,8 @@ class HomeMessagesConnectionHandler extends ConnectionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
export async function apply(ctx: Context) {
|
||||
ctx.inject(['geoip'], (g) => {
|
||||
geoip = g.geoip;
|
||||
});
|
||||
export const inject = { geoip: { required: false } };
|
||||
export function apply(ctx: Context) {
|
||||
ctx.Route('homepage', '/', HomeHandler);
|
||||
ctx.Route('home_security', '/home/security', HomeSecurityHandler, PRIV.PRIV_USER_PROFILE);
|
||||
ctx.Route('user_changemail_with_code', '/home/changeMail/:code', UserChangemailWithCodeHandler, PRIV.PRIV_USER_PROFILE);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { statSync } from 'fs';
|
||||
import { pick } from 'lodash';
|
||||
import { lookup } from 'mime-types';
|
||||
import { Context } from '../context';
|
||||
import {
|
||||
AccessDeniedError, FileExistsError, FileLimitExceededError, FileUploadError, NotFoundError,
|
||||
ValidationError,
|
||||
@@ -132,7 +133,7 @@ export class SwitchAccountHandler extends Handler {
|
||||
}
|
||||
}
|
||||
|
||||
export async function apply(ctx) {
|
||||
export async function apply(ctx: Context) {
|
||||
ctx.Route('switch_language', '/language/:lang', SwitchLanguageHandler);
|
||||
ctx.Route('home_files', '/file', FilesHandler);
|
||||
ctx.Route('fs_download', '/file/:uid/:filename', FSDownloadHandler);
|
||||
|
||||
Reference in new issue
Block a user