Merge branch 'notification-read-api' into swn
This commit is contained in:
commit
ab73ba4d66
515 changed files with 12078 additions and 10359 deletions
11
packages/backend/src/@types/hcaptcha.d.ts
vendored
Normal file
11
packages/backend/src/@types/hcaptcha.d.ts
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
declare module 'hcaptcha' {
|
||||
interface IVerifyResponse {
|
||||
success: boolean;
|
||||
challenge_ts: string;
|
||||
hostname: string;
|
||||
credit?: boolean;
|
||||
'error-codes'?: unknown[];
|
||||
}
|
||||
|
||||
export function verify(secret: string, token: string): Promise<IVerifyResponse>;
|
||||
}
|
||||
77
packages/backend/src/@types/http-signature.d.ts
vendored
Normal file
77
packages/backend/src/@types/http-signature.d.ts
vendored
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
declare module 'http-signature' {
|
||||
import { IncomingMessage, ClientRequest } from 'http';
|
||||
|
||||
interface ISignature {
|
||||
keyId: string;
|
||||
algorithm: string;
|
||||
headers: string[];
|
||||
signature: string;
|
||||
}
|
||||
|
||||
interface IOptions {
|
||||
headers?: string[];
|
||||
algorithm?: string;
|
||||
strict?: boolean;
|
||||
authorizationHeaderName?: string;
|
||||
}
|
||||
|
||||
interface IParseRequestOptions extends IOptions {
|
||||
clockSkew?: number;
|
||||
}
|
||||
|
||||
interface IParsedSignature {
|
||||
scheme: string;
|
||||
params: ISignature;
|
||||
signingString: string;
|
||||
algorithm: string;
|
||||
keyId: string;
|
||||
}
|
||||
|
||||
type RequestSignerConstructorOptions =
|
||||
IRequestSignerConstructorOptionsFromProperties |
|
||||
IRequestSignerConstructorOptionsFromFunction;
|
||||
|
||||
interface IRequestSignerConstructorOptionsFromProperties {
|
||||
keyId: string;
|
||||
key: string | Buffer;
|
||||
algorithm?: string;
|
||||
}
|
||||
|
||||
interface IRequestSignerConstructorOptionsFromFunction {
|
||||
sign?: (data: string, cb: (err: any, sig: ISignature) => void) => void;
|
||||
}
|
||||
|
||||
class RequestSigner {
|
||||
constructor(options: RequestSignerConstructorOptions);
|
||||
|
||||
public writeHeader(header: string, value: string): string;
|
||||
|
||||
public writeDateHeader(): string;
|
||||
|
||||
public writeTarget(method: string, path: string): void;
|
||||
|
||||
public sign(cb: (err: any, authz: string) => void): void;
|
||||
}
|
||||
|
||||
interface ISignRequestOptions extends IOptions {
|
||||
keyId: string;
|
||||
key: string;
|
||||
httpVersion?: string;
|
||||
}
|
||||
|
||||
export function parse(request: IncomingMessage, options?: IParseRequestOptions): IParsedSignature;
|
||||
export function parseRequest(request: IncomingMessage, options?: IParseRequestOptions): IParsedSignature;
|
||||
|
||||
export function sign(request: ClientRequest, options: ISignRequestOptions): boolean;
|
||||
export function signRequest(request: ClientRequest, options: ISignRequestOptions): boolean;
|
||||
export function createSigner(): RequestSigner;
|
||||
export function isSigner(obj: any): obj is RequestSigner;
|
||||
|
||||
export function sshKeyToPEM(key: string): string;
|
||||
export function sshKeyFingerprint(key: string): string;
|
||||
export function pemToRsaSSHKey(pem: string, comment: string): string;
|
||||
|
||||
export function verify(parsedSignature: IParsedSignature, pubkey: string | Buffer): boolean;
|
||||
export function verifySignature(parsedSignature: IParsedSignature, pubkey: string | Buffer): boolean;
|
||||
export function verifyHMAC(parsedSignature: IParsedSignature, secret: string): boolean;
|
||||
}
|
||||
800
packages/backend/src/@types/jsrsasign.d.ts
vendored
Normal file
800
packages/backend/src/@types/jsrsasign.d.ts
vendored
Normal file
|
|
@ -0,0 +1,800 @@
|
|||
// Attention: Partial Type Definition
|
||||
|
||||
declare module 'jsrsasign' {
|
||||
//// HELPER TYPES
|
||||
|
||||
/**
|
||||
* Attention: The value might be changed by the function.
|
||||
*/
|
||||
type Mutable<T> = T;
|
||||
|
||||
/**
|
||||
* Deprecated: The function might be deleted in future release.
|
||||
*/
|
||||
type Deprecated<T> = T;
|
||||
|
||||
//// COMMON TYPES
|
||||
|
||||
/**
|
||||
* byte number
|
||||
*/
|
||||
type ByteNumber = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255;
|
||||
|
||||
/**
|
||||
* hexadecimal string /[0-9A-F]/
|
||||
*/
|
||||
type HexString = string;
|
||||
|
||||
/**
|
||||
* binary string /[01]/
|
||||
*/
|
||||
type BinString = string;
|
||||
|
||||
/**
|
||||
* base64 string /[A-Za-z0-9+/]=+/
|
||||
*/
|
||||
type Base64String = string;
|
||||
|
||||
/**
|
||||
* base64 URL encoded string /[A-Za-z0-9_-]/
|
||||
*/
|
||||
type Base64URLString = string;
|
||||
|
||||
/**
|
||||
* time value (ex. "151231235959Z")
|
||||
*/
|
||||
type TimeValue = string;
|
||||
|
||||
/**
|
||||
* OID string (ex. '1.2.3.4.567')
|
||||
*/
|
||||
type OID = string;
|
||||
|
||||
/**
|
||||
* OID name
|
||||
*/
|
||||
type OIDName = string;
|
||||
|
||||
/**
|
||||
* PEM formatted string
|
||||
*/
|
||||
type PEM = string;
|
||||
|
||||
//// ASN1 TYPES
|
||||
|
||||
class ASN1Object {
|
||||
public isModified: boolean;
|
||||
|
||||
public hTLV: ASN1TLV;
|
||||
|
||||
public hT: ASN1T;
|
||||
|
||||
public hL: ASN1L;
|
||||
|
||||
public hV: ASN1V;
|
||||
|
||||
public getLengthHexFromValue(): HexString;
|
||||
|
||||
public getEncodedHex(): ASN1TLV;
|
||||
|
||||
public getValueHex(): ASN1V;
|
||||
|
||||
public getFreshValueHex(): ASN1V;
|
||||
}
|
||||
|
||||
class DERAbstractStructured extends ASN1Object {
|
||||
constructor(params?: Partial<Record<'array', ASN1Object[]>>);
|
||||
|
||||
public setByASN1ObjectArray(asn1ObjectArray: ASN1Object[]): void;
|
||||
|
||||
public appendASN1Object(asn1Object: ASN1Object): void;
|
||||
}
|
||||
|
||||
class DERSequence extends DERAbstractStructured {
|
||||
constructor(params?: Partial<Record<'array', ASN1Object[]>>);
|
||||
|
||||
public getFreshValueHex(): ASN1V;
|
||||
}
|
||||
|
||||
//// ASN1HEX TYPES
|
||||
|
||||
/**
|
||||
* ASN.1 DER encoded data (hexadecimal string)
|
||||
*/
|
||||
type ASN1S = HexString;
|
||||
|
||||
/**
|
||||
* index of something
|
||||
*/
|
||||
type Idx<T extends { [idx: string]: unknown } | { [idx: number]: unknown }> = ASN1S extends { [idx: string]: unknown } ? string : ASN1S extends { [idx: number]: unknown } ? number : never;
|
||||
|
||||
/**
|
||||
* byte length of something
|
||||
*/
|
||||
type ByteLength<T extends { length: unknown }> = T['length'];
|
||||
|
||||
/**
|
||||
* ASN.1 L(length) (hexadecimal string)
|
||||
*/
|
||||
type ASN1L = HexString;
|
||||
|
||||
/**
|
||||
* ASN.1 T(tag) (hexadecimal string)
|
||||
*/
|
||||
type ASN1T = HexString;
|
||||
|
||||
/**
|
||||
* ASN.1 V(value) (hexadecimal string)
|
||||
*/
|
||||
type ASN1V = HexString;
|
||||
|
||||
/**
|
||||
* ASN.1 TLV (hexadecimal string)
|
||||
*/
|
||||
type ASN1TLV = HexString;
|
||||
|
||||
/**
|
||||
* ASN.1 object string
|
||||
*/
|
||||
type ASN1ObjectString = string;
|
||||
|
||||
/**
|
||||
* nth
|
||||
*/
|
||||
type Nth = number;
|
||||
|
||||
/**
|
||||
* ASN.1 DER encoded OID value (hexadecimal string)
|
||||
*/
|
||||
type ASN1OIDV = HexString;
|
||||
|
||||
class ASN1HEX {
|
||||
public static getLblen(s: ASN1S, idx: Idx<ASN1S>): ByteLength<ASN1L>;
|
||||
|
||||
public static getL(s: ASN1S, idx: Idx<ASN1S>): ASN1L;
|
||||
|
||||
public static getVblen(s: ASN1S, idx: Idx<ASN1S>): ByteLength<ASN1V>;
|
||||
|
||||
public static getVidx(s: ASN1S, idx: Idx<ASN1S>): Idx<ASN1V>;
|
||||
|
||||
public static getV(s: ASN1S, idx: Idx<ASN1S>): ASN1V;
|
||||
|
||||
public static getTLV(s: ASN1S, idx: Idx<ASN1S>): ASN1TLV;
|
||||
|
||||
public static getNextSiblingIdx(s: ASN1S, idx: Idx<ASN1S>): Idx<ASN1ObjectString>;
|
||||
|
||||
public static getChildIdx(h: ASN1S, pos: Idx<ASN1S>): Idx<ASN1ObjectString>[];
|
||||
|
||||
public static getNthChildIdx(h: ASN1S, idx: Idx<ASN1S>, nth: Nth): Idx<ASN1ObjectString>;
|
||||
|
||||
public static getIdxbyList(h: ASN1S, currentIndex: Idx<ASN1ObjectString>, nthList: Mutable<Nth[]>, checkingTag?: string): Idx<Mutable<Nth[]>>;
|
||||
|
||||
public static getTLVbyList(h: ASN1S, currentIndex: Idx<ASN1ObjectString>, nthList: Mutable<Nth[]>, checkingTag?: string): ASN1TLV;
|
||||
|
||||
// eslint:disable-next-line:bool-param-default
|
||||
public static getVbyList(h: ASN1S, currentIndex: Idx<ASN1ObjectString>, nthList: Mutable<Nth[]>, checkingTag?: string, removeUnusedbits?: boolean): ASN1V;
|
||||
|
||||
public static hextooidstr(hex: ASN1OIDV): OID;
|
||||
|
||||
public static dump(hexOrObj: ASN1S | ASN1Object, flags?: Record<string, unknown>, idx?: Idx<ASN1S>, indent?: string): string;
|
||||
|
||||
public static isASN1HEX(hex: string): hex is HexString;
|
||||
|
||||
public static oidname(oidDotOrHex: OID | ASN1OIDV): OIDName;
|
||||
}
|
||||
|
||||
//// BIG INTEGER TYPES (PARTIAL)
|
||||
|
||||
class BigInteger {
|
||||
constructor(a: null);
|
||||
|
||||
constructor(a: number, b: SecureRandom);
|
||||
|
||||
constructor(a: number, b: number, c: SecureRandom);
|
||||
|
||||
constructor(a: unknown);
|
||||
|
||||
constructor(a: string, b: number);
|
||||
|
||||
public am(i: number, x: number, w: number, j: number, c: number, n: number): number;
|
||||
|
||||
public DB: number;
|
||||
|
||||
public DM: number;
|
||||
|
||||
public DV: number;
|
||||
|
||||
public FV: number;
|
||||
|
||||
public F1: number;
|
||||
|
||||
public F2: number;
|
||||
|
||||
protected copyTo(r: Mutable<BigInteger>): void;
|
||||
|
||||
protected fromInt(x: number): void;
|
||||
|
||||
protected fromString(s: string, b: number): void;
|
||||
|
||||
protected clamp(): void;
|
||||
|
||||
public toString(b: number): string;
|
||||
|
||||
public negate(): BigInteger;
|
||||
|
||||
public abs(): BigInteger;
|
||||
|
||||
public compareTo(a: BigInteger): number;
|
||||
|
||||
public bitLength(): number;
|
||||
|
||||
protected dlShiftTo(n: number, r: Mutable<BigInteger>): void;
|
||||
|
||||
protected drShiftTo(n: number, r: Mutable<BigInteger>): void;
|
||||
|
||||
protected lShiftTo(n: number, r: Mutable<BigInteger>): void;
|
||||
|
||||
protected rShiftTo(n: number, r: Mutable<BigInteger>): void;
|
||||
|
||||
protected subTo(a: BigInteger, r: Mutable<BigInteger>): void;
|
||||
|
||||
protected multiplyTo(a: BigInteger, r: Mutable<BigInteger>): void;
|
||||
|
||||
protected squareTo(r: Mutable<BigInteger>): void;
|
||||
|
||||
protected divRemTo(m: BigInteger, q: Mutable<BigInteger>, r: Mutable<BigInteger>): void;
|
||||
|
||||
public mod(a: BigInteger): BigInteger;
|
||||
|
||||
protected invDigit(): number;
|
||||
|
||||
protected isEven(): boolean;
|
||||
|
||||
protected exp(e: number, z: Classic | Montgomery): BigInteger;
|
||||
|
||||
public modPowInt(e: number, m: BigInteger): BigInteger;
|
||||
|
||||
public static ZERO: BigInteger;
|
||||
|
||||
public static ONE: BigInteger;
|
||||
}
|
||||
|
||||
class Classic {
|
||||
constructor(m: BigInteger);
|
||||
|
||||
public convert(x: BigInteger): BigInteger;
|
||||
|
||||
public revert(x: BigInteger): BigInteger;
|
||||
|
||||
public reduce(x: Mutable<BigInteger>): void;
|
||||
|
||||
public mulTo(x: BigInteger, r: Mutable<BigInteger>): void;
|
||||
|
||||
public sqrTo(x: BigInteger, y: BigInteger, r: Mutable<BigInteger>): void;
|
||||
}
|
||||
|
||||
class Montgomery {
|
||||
constructor(m: BigInteger);
|
||||
|
||||
public convert(x: BigInteger): BigInteger;
|
||||
|
||||
public revert(x: BigInteger): BigInteger;
|
||||
|
||||
public reduce(x: Mutable<BigInteger>): void;
|
||||
|
||||
public mulTo(x: BigInteger, r: Mutable<BigInteger>): void;
|
||||
|
||||
public sqrTo(x: BigInteger, y: BigInteger, r: Mutable<BigInteger>): void;
|
||||
}
|
||||
|
||||
//// KEYUTIL TYPES
|
||||
|
||||
type DecryptAES = (dataHex: HexString, keyHex: HexString, ivHex: HexString) => HexString;
|
||||
|
||||
type Decrypt3DES = (dataHex: HexString, keyHex: HexString, ivHex: HexString) => HexString;
|
||||
|
||||
type DecryptDES = (dataHex: HexString, keyHex: HexString, ivHex: HexString) => HexString;
|
||||
|
||||
type EncryptAES = (dataHex: HexString, keyHex: HexString, ivHex: HexString) => HexString;
|
||||
|
||||
type Encrypt3DES = (dataHex: HexString, keyHex: HexString, ivHex: HexString) => HexString;
|
||||
|
||||
type EncryptDES = (dataHex: HexString, keyHex: HexString, ivHex: HexString) => HexString;
|
||||
|
||||
type AlgList = {
|
||||
'AES-256-CBC': { 'proc': DecryptAES; 'eproc': EncryptAES; keylen: 32; ivlen: 16; };
|
||||
'AES-192-CBC': { 'proc': DecryptAES; 'eproc': EncryptAES; keylen: 24; ivlen: 16; };
|
||||
'AES-128-CBC': { 'proc': DecryptAES; 'eproc': EncryptAES; keylen: 16; ivlen: 16; };
|
||||
'DES-EDE3-CBC': { 'proc': Decrypt3DES; 'eproc': Encrypt3DES; keylen: 24; ivlen: 8; };
|
||||
'DES-CBC': { 'proc': DecryptDES; 'eproc': EncryptDES; keylen: 8; ivlen: 8; };
|
||||
};
|
||||
|
||||
type AlgName = keyof AlgList;
|
||||
|
||||
type PEMHeadAlgName = 'RSA' | 'EC' | 'DSA';
|
||||
|
||||
type GetKeyRSAParam = RSAKey | {
|
||||
n: BigInteger;
|
||||
e: number;
|
||||
} | Record<'n' | 'e', HexString> | Record<'n' | 'e', HexString> & Record<'d' | 'p' | 'q' | 'dp' | 'dq' | 'co', HexString | null> | {
|
||||
n: BigInteger;
|
||||
e: number;
|
||||
d: BigInteger;
|
||||
} | {
|
||||
kty: 'RSA';
|
||||
} & Record<'n' | 'e', Base64URLString> | {
|
||||
kty: 'RSA';
|
||||
} & Record<'n' | 'e' | 'd' | 'p' | 'q' | 'dp' | 'dq' | 'qi', Base64URLString> | {
|
||||
kty: 'RSA';
|
||||
} & Record<'n' | 'e' | 'd', Base64URLString>;
|
||||
|
||||
type GetKeyECDSAParam = KJUR.crypto.ECDSA | {
|
||||
curve: KJUR.crypto.CurveName;
|
||||
xy: HexString;
|
||||
} | {
|
||||
curve: KJUR.crypto.CurveName;
|
||||
d: HexString;
|
||||
} | {
|
||||
kty: 'EC';
|
||||
crv: KJUR.crypto.CurveName;
|
||||
x: Base64URLString;
|
||||
y: Base64URLString;
|
||||
} | {
|
||||
kty: 'EC';
|
||||
crv: KJUR.crypto.CurveName;
|
||||
x: Base64URLString;
|
||||
y: Base64URLString;
|
||||
d: Base64URLString;
|
||||
};
|
||||
|
||||
type GetKeyDSAParam = KJUR.crypto.DSA | Record<'p' | 'q' | 'g', BigInteger> & Record<'y', BigInteger | null> | Record<'p' | 'q' | 'g' | 'x', BigInteger> & Record<'y', BigInteger | null>;
|
||||
|
||||
type GetKeyParam = GetKeyRSAParam | GetKeyECDSAParam | GetKeyDSAParam | string;
|
||||
|
||||
class KEYUTIL {
|
||||
public version: '1.0.0';
|
||||
|
||||
public parsePKCS5PEM(sPKCS5PEM: PEM): Partial<Record<'type' | 's', string>> & (Record<'cipher' | 'ivsalt', string> | Record<'cipher' | 'ivsalt', undefined>);
|
||||
|
||||
public getKeyAndUnusedIvByPasscodeAndIvsalt(algName: AlgName, passcode: string, ivsaltHex: HexString): Record<'keyhex' | 'ivhex', HexString>;
|
||||
|
||||
public decryptKeyB64(privateKeyB64: Base64String, sharedKeyAlgName: AlgName, sharedKeyHex: HexString, ivsaltHex: HexString): Base64String;
|
||||
|
||||
public getDecryptedKeyHex(sEncryptedPEM: PEM, passcode: string): HexString;
|
||||
|
||||
public getEncryptedPKCS5PEMFromPrvKeyHex(pemHeadAlg: PEMHeadAlgName, hPrvKey: string, passcode: string, sharedKeyAlgName?: AlgName | null, ivsaltHex?: HexString | null): PEM;
|
||||
|
||||
public parseHexOfEncryptedPKCS8(sHEX: HexString): {
|
||||
ciphertext: ASN1V;
|
||||
encryptionSchemeAlg: 'TripleDES';
|
||||
encryptionSchemeIV: ASN1V;
|
||||
pbkdf2Salt: ASN1V;
|
||||
pbkdf2Iter: number;
|
||||
};
|
||||
|
||||
public getPBKDF2KeyHexFromParam(info: ReturnType<this['parseHexOfEncryptedPKCS8']>, passcode: string): HexString;
|
||||
|
||||
private _getPlainPKCS8HexFromEncryptedPKCS8PEM(pkcs8PEM: PEM, passcode: string): HexString;
|
||||
|
||||
public getKeyFromEncryptedPKCS8PEM(prvKeyHex: HexString): ReturnType<this['getKeyFromPlainPrivatePKCS8Hex']>;
|
||||
|
||||
public parsePlainPrivatePKCS8Hex(pkcs8PrvHex: HexString): {
|
||||
algparam: ASN1V | null;
|
||||
algoid: ASN1V;
|
||||
keyidx: Idx<ASN1V>;
|
||||
};
|
||||
|
||||
public getKeyFromPlainPrivatePKCS8PEM(prvKeyHex: HexString): ReturnType<this['getKeyFromPlainPrivatePKCS8Hex']>;
|
||||
|
||||
public getKeyFromPlainPrivatePKCS8Hex(prvKeyHex: HexString): RSAKey | KJUR.crypto.DSA | KJUR.crypto.ECDSA;
|
||||
|
||||
private _getKeyFromPublicPKCS8Hex(h: HexString): RSAKey | KJUR.crypto.DSA | KJUR.crypto.ECDSA;
|
||||
|
||||
public parsePublicRawRSAKeyHex(pubRawRSAHex: HexString): Record<'n' | 'e', ASN1V>;
|
||||
|
||||
public parsePublicPKCS8Hex(pkcs8PubHex: HexString): {
|
||||
algparam: ASN1V | Record<'p' | 'q' | 'g', ASN1V> | null;
|
||||
algoid: ASN1V;
|
||||
key: ASN1V;
|
||||
};
|
||||
|
||||
public static getKey(param: GetKeyRSAParam): RSAKey;
|
||||
|
||||
public static getKey(param: GetKeyECDSAParam): KJUR.crypto.ECDSA;
|
||||
|
||||
public static getKey(param: GetKeyDSAParam): KJUR.crypto.DSA;
|
||||
|
||||
public static getKey(param: string, passcode?: string, hextype?: string): RSAKey | KJUR.crypto.ECDSA | KJUR.crypto.DSA;
|
||||
|
||||
public static generateKeypair(alg: 'RSA', keylen: number): Record<'prvKeyObj' | 'pubKeyObj', RSAKey>;
|
||||
|
||||
public static generateKeypair(alg: 'EC', curve: KJUR.crypto.CurveName): Record<'prvKeyObj' | 'pubKeyObj', KJUR.crypto.ECDSA>;
|
||||
|
||||
public static getPEM(keyObjOrHex: RSAKey | KJUR.crypto.ECDSA | KJUR.crypto.DSA, formatType?: 'PKCS1PRV' | 'PKCS5PRV' | 'PKCS8PRV', passwd?: string, encAlg?: 'DES-CBC' | 'DES-EDE3-CBC' | 'AES-128-CBC' | 'AES-192-CBC' | 'AES-256-CBC', hexType?: string, ivsaltHex?: HexString): object; // To Do
|
||||
|
||||
public static getKeyFromCSRPEM(csrPEM: PEM): RSAKey | KJUR.crypto.ECDSA | KJUR.crypto.DSA;
|
||||
|
||||
public static getKeyFromCSRHex(csrHex: HexString): RSAKey | KJUR.crypto.ECDSA | KJUR.crypto.DSA;
|
||||
|
||||
public static parseCSRHex(csrHex: HexString): Record<'p8pubkeyhex', ASN1TLV>;
|
||||
|
||||
public static getJWKFromKey(keyObj: RSAKey): {
|
||||
kty: 'RSA';
|
||||
} & Record<'n' | 'e' | 'd' | 'p' | 'q' | 'dp' | 'dq' | 'qi', Base64URLString> | {
|
||||
kty: 'RSA';
|
||||
} & Record<'n' | 'e', Base64URLString>;
|
||||
|
||||
public static getJWKFromKey(keyObj: KJUR.crypto.ECDSA): {
|
||||
kty: 'EC';
|
||||
crv: KJUR.crypto.CurveName;
|
||||
x: Base64URLString;
|
||||
y: Base64URLString;
|
||||
d: Base64URLString;
|
||||
} | {
|
||||
kty: 'EC';
|
||||
crv: KJUR.crypto.CurveName;
|
||||
x: Base64URLString;
|
||||
y: Base64URLString;
|
||||
};
|
||||
}
|
||||
|
||||
//// KJUR NAMESPACE (PARTIAL)
|
||||
|
||||
namespace KJUR {
|
||||
namespace crypto {
|
||||
type CurveName = 'secp128r1' | 'secp160k1' | 'secp160r1' | 'secp192k1' | 'secp192r1' | 'secp224r1' | 'secp256k1' | 'secp256r1' | 'secp384r1' | 'secp521r1';
|
||||
|
||||
class DSA {
|
||||
public p: BigInteger | null;
|
||||
|
||||
public q: BigInteger | null;
|
||||
|
||||
public g: BigInteger | null;
|
||||
|
||||
public y: BigInteger | null;
|
||||
|
||||
public x: BigInteger | null;
|
||||
|
||||
public type: 'DSA';
|
||||
|
||||
public isPrivate: boolean;
|
||||
|
||||
public isPublic: boolean;
|
||||
|
||||
public setPrivate(p: BigInteger, q: BigInteger, g: BigInteger, y: BigInteger | null, x: BigInteger): void;
|
||||
|
||||
public setPrivateHex(hP: HexString, hQ: HexString, hG: HexString, hY: HexString | null, hX: HexString): void;
|
||||
|
||||
public setPublic(p: BigInteger, q: BigInteger, g: BigInteger, y: BigInteger): void;
|
||||
|
||||
public setPublicHex(hP: HexString, hQ: HexString, hG: HexString, hY: HexString): void;
|
||||
|
||||
public signWithMessageHash(sHashHex: HexString): HexString;
|
||||
|
||||
public verifyWithMessageHash(sHashHex: HexString, hSigVal: HexString): boolean;
|
||||
|
||||
public parseASN1Signature(hSigVal: HexString): [BigInteger, BigInteger];
|
||||
|
||||
public readPKCS5PrvKeyHex(h: HexString): void;
|
||||
|
||||
public readPKCS8PrvKeyHex(h: HexString): void;
|
||||
|
||||
public readPKCS8PubKeyHex(h: HexString): void;
|
||||
|
||||
public readCertPubKeyHex(h: HexString, nthPKI: number): void;
|
||||
}
|
||||
|
||||
class ECDSA {
|
||||
constructor(params?: {
|
||||
curve?: CurveName;
|
||||
prv?: HexString;
|
||||
pub?: HexString;
|
||||
});
|
||||
|
||||
public p: BigInteger | null;
|
||||
|
||||
public q: BigInteger | null;
|
||||
|
||||
public g: BigInteger | null;
|
||||
|
||||
public y: BigInteger | null;
|
||||
|
||||
public x: BigInteger | null;
|
||||
|
||||
public type: 'EC';
|
||||
|
||||
public isPrivate: boolean;
|
||||
|
||||
public isPublic: boolean;
|
||||
|
||||
public getBigRandom(limit: BigInteger): BigInteger;
|
||||
|
||||
public setNamedCurve(curveName: CurveName): void;
|
||||
|
||||
public setPrivateKeyHex(prvKeyHex: HexString): void;
|
||||
|
||||
public setPublicKeyHex(pubKeyHex: HexString): void;
|
||||
|
||||
public getPublicKeyXYHex(): Record<'x' | 'y', HexString>;
|
||||
|
||||
public getShortNISTPCurveName(): 'P-256' | 'P-384' | null;
|
||||
|
||||
public generateKeyPairHex(): Record<'ecprvhex' | 'ecpubhex', HexString>;
|
||||
|
||||
public signWithMessageHash(hashHex: HexString): HexString;
|
||||
|
||||
public signHex(hashHex: HexString, privHex: HexString): HexString;
|
||||
|
||||
public verifyWithMessageHash(sHashHex: HexString, hSigVal: HexString): boolean;
|
||||
|
||||
public parseASN1Signature(hSigVal: HexString): [BigInteger, BigInteger];
|
||||
|
||||
public readPKCS5PrvKeyHex(h: HexString): void;
|
||||
|
||||
public readPKCS8PrvKeyHex(h: HexString): void;
|
||||
|
||||
public readPKCS8PubKeyHex(h: HexString): void;
|
||||
|
||||
public readCertPubKeyHex(h: HexString, nthPKI: number): void;
|
||||
|
||||
public static parseSigHex(sigHex: HexString): Record<'r' | 's', BigInteger>;
|
||||
|
||||
public static parseSigHexInHexRS(sigHex: HexString): Record<'r' | 's', ASN1V>;
|
||||
|
||||
public static asn1SigToConcatSig(asn1Sig: HexString): HexString;
|
||||
|
||||
public static concatSigToASN1Sig(concatSig: HexString): ASN1TLV;
|
||||
|
||||
public static hexRSSigToASN1Sig(hR: HexString, hS: HexString): ASN1TLV;
|
||||
|
||||
public static biRSSigToASN1Sig(biR: BigInteger, biS: BigInteger): ASN1TLV;
|
||||
|
||||
public static getName(s: CurveName | HexString): 'secp256r1' | 'secp256k1' | 'secp384r1' | null;
|
||||
}
|
||||
|
||||
class Signature {
|
||||
constructor(params?: ({
|
||||
alg: string;
|
||||
prov?: string;
|
||||
} | {}) & ({
|
||||
psssaltlen: number;
|
||||
} | {}) & ({
|
||||
prvkeypem: PEM;
|
||||
prvkeypas?: never;
|
||||
} | {}));
|
||||
|
||||
private _setAlgNames(): void;
|
||||
|
||||
private _zeroPaddingOfSignature(hex: HexString, bitLength: number): HexString;
|
||||
|
||||
public setAlgAndProvider(alg: string, prov: string): void;
|
||||
|
||||
public init(key: GetKeyParam, pass?: string): void;
|
||||
|
||||
public updateString(str: string): void;
|
||||
|
||||
public updateHex(hex: HexString): void;
|
||||
|
||||
public sign(): HexString;
|
||||
|
||||
public signString(str: string): HexString;
|
||||
|
||||
public signHex(hex: HexString): HexString;
|
||||
|
||||
public verify(hSigVal: string): boolean | 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// RSAKEY TYPES
|
||||
|
||||
class RSAKey {
|
||||
public n: BigInteger | null;
|
||||
|
||||
public e: number;
|
||||
|
||||
public d: BigInteger | null;
|
||||
|
||||
public p: BigInteger | null;
|
||||
|
||||
public q: BigInteger | null;
|
||||
|
||||
public dmp1: BigInteger | null;
|
||||
|
||||
public dmq1: BigInteger | null;
|
||||
|
||||
public coeff: BigInteger | null;
|
||||
|
||||
public type: 'RSA';
|
||||
|
||||
public isPrivate?: boolean;
|
||||
|
||||
public isPublic?: boolean;
|
||||
|
||||
//// RSA PUBLIC
|
||||
|
||||
protected doPublic(x: BigInteger): BigInteger;
|
||||
|
||||
public setPublic(N: BigInteger, E: number): void;
|
||||
|
||||
public setPublic(N: HexString, E: HexString): void;
|
||||
|
||||
public encrypt(text: string): HexString | null;
|
||||
|
||||
public encryptOAEP(text: string, hash?: string | ((s: string) => string), hashLen?: number): HexString | null;
|
||||
|
||||
//// RSA PRIVATE
|
||||
|
||||
protected doPrivate(x: BigInteger): BigInteger;
|
||||
|
||||
public setPrivate(N: BigInteger, E: number, D: BigInteger): void;
|
||||
|
||||
public setPrivate(N: HexString, E: HexString, D: HexString): void;
|
||||
|
||||
public setPrivateEx(N: HexString, E: HexString, D?: HexString | null, P?: HexString | null, Q?: HexString | null, DP?: HexString | null, DQ?: HexString | null, C?: HexString | null): void;
|
||||
|
||||
public generate(B: number, E: HexString): void;
|
||||
|
||||
public decrypt(ctext: HexString): string;
|
||||
|
||||
public decryptOAEP(ctext: HexString, hash?: string | ((s: string) => string), hashLen?: number): string | null;
|
||||
|
||||
//// RSA PEM
|
||||
|
||||
public getPosArrayOfChildrenFromHex(hPrivateKey: PEM): Idx<ASN1ObjectString>[];
|
||||
|
||||
public getHexValueArrayOfChildrenFromHex(hPrivateKey: PEM): Idx<ASN1ObjectString>[];
|
||||
|
||||
public readPrivateKeyFromPEMString(keyPEM: PEM): void;
|
||||
|
||||
public readPKCS5PrvKeyHex(h: HexString): void;
|
||||
|
||||
public readPKCS8PrvKeyHex(h: HexString): void;
|
||||
|
||||
public readPKCS5PubKeyHex(h: HexString): void;
|
||||
|
||||
public readPKCS8PubKeyHex(h: HexString): void;
|
||||
|
||||
public readCertPubKeyHex(h: HexString, nthPKI: Nth): void;
|
||||
|
||||
//// RSA SIGN
|
||||
|
||||
public sign(s: string, hashAlg: string): HexString;
|
||||
|
||||
public signWithMessageHash(sHashHex: HexString, hashAlg: string): HexString;
|
||||
|
||||
public signPSS(s: string, hashAlg: string, sLen: number): HexString;
|
||||
|
||||
public signWithMessageHashPSS(hHash: HexString, hashAlg: string, sLen: number): HexString;
|
||||
|
||||
public verify(sMsg: string, hSig: HexString): boolean | 0;
|
||||
|
||||
public verifyWithMessageHash(sHashHex: HexString, hSig: HexString): boolean | 0;
|
||||
|
||||
public verifyPSS(sMsg: string, hSig: HexString, hashAlg: string, sLen: number): boolean;
|
||||
|
||||
public verifyWithMessageHashPSS(hHash: HexString, hSig: HexString, hashAlg: string, sLen: number): boolean;
|
||||
|
||||
public static SALT_LEN_HLEN: -1;
|
||||
|
||||
public static SALT_LEN_MAX: -2;
|
||||
|
||||
public static SALT_LEN_RECOVER: -2;
|
||||
}
|
||||
|
||||
/// RNG TYPES
|
||||
class SecureRandom {
|
||||
public nextBytes(ba: Mutable<ByteNumber[]>): void;
|
||||
}
|
||||
|
||||
//// X509 TYPES
|
||||
|
||||
type ExtInfo = {
|
||||
critical: boolean;
|
||||
oid: OID;
|
||||
vidx: Idx<ASN1V>;
|
||||
};
|
||||
|
||||
type ExtAIAInfo = Record<'ocsp' | 'caissuer', string>;
|
||||
|
||||
type ExtCertificatePolicy = {
|
||||
id: OIDName;
|
||||
} & Partial<{
|
||||
cps: string;
|
||||
} | {
|
||||
unotice: string;
|
||||
}>;
|
||||
|
||||
class X509 {
|
||||
public hex: HexString | null;
|
||||
|
||||
public version: number;
|
||||
|
||||
public foffset: number;
|
||||
|
||||
public aExtInfo: null;
|
||||
|
||||
public getVersion(): number;
|
||||
|
||||
public getSerialNumberHex(): ASN1V;
|
||||
|
||||
public getSignatureAlgorithmField(): OIDName;
|
||||
|
||||
public getIssuerHex(): ASN1TLV;
|
||||
|
||||
public getIssuerString(): HexString;
|
||||
|
||||
public getSubjectHex(): ASN1TLV;
|
||||
|
||||
public getSubjectString(): HexString;
|
||||
|
||||
public getNotBefore(): TimeValue;
|
||||
|
||||
public getNotAfter(): TimeValue;
|
||||
|
||||
public getPublicKeyHex(): ASN1TLV;
|
||||
|
||||
public getPublicKeyIdx(): Idx<Mutable<Nth[]>>;
|
||||
|
||||
public getPublicKeyContentIdx(): Idx<Mutable<Nth[]>>;
|
||||
|
||||
public getPublicKey(): RSAKey | KJUR.crypto.ECDSA | KJUR.crypto.DSA;
|
||||
|
||||
public getSignatureAlgorithmName(): OIDName;
|
||||
|
||||
public getSignatureValueHex(): ASN1V;
|
||||
|
||||
public verifySignature(pubKey: GetKeyParam): boolean | 0;
|
||||
|
||||
public parseExt(): void;
|
||||
|
||||
public getExtInfo(oidOrName: OID | string): ExtInfo | undefined;
|
||||
|
||||
public getExtBasicConstraints(): ExtInfo | {} | {
|
||||
cA: true;
|
||||
pathLen?: number;
|
||||
};
|
||||
|
||||
public getExtKeyUsageBin(): BinString;
|
||||
|
||||
public getExtKeyUsageString(): string;
|
||||
|
||||
public getExtSubjectKeyIdentifier(): ASN1V | undefined;
|
||||
|
||||
public getExtAuthorityKeyIdentifier(): {
|
||||
kid: ASN1V;
|
||||
} | undefined;
|
||||
|
||||
public getExtExtKeyUsageName(): OIDName[] | undefined;
|
||||
|
||||
public getExtSubjectAltName(): Deprecated<string[]>;
|
||||
|
||||
public getExtSubjectAltName2(): ['MAIL' | 'DNS' | 'DN' | 'URI' | 'IP', string][] | undefined;
|
||||
|
||||
public getExtCRLDistributionPointsURI(): string[] | undefined;
|
||||
|
||||
public getExtAIAInfo(): ExtAIAInfo | undefined;
|
||||
|
||||
public getExtCertificatePolicies(): ExtCertificatePolicy[] | undefined;
|
||||
|
||||
public readCertPEM(sCertPEM: PEM): void;
|
||||
|
||||
public readCertHex(sCertHex: HexString): void;
|
||||
|
||||
public getInfo(): string;
|
||||
|
||||
public static hex2dn(hex: HexString, idx?: Idx<HexString>): string;
|
||||
|
||||
public static hex2rdn(hex: HexString, idx?: Idx<HexString>): string;
|
||||
|
||||
public static hex2attrTypeValue(hex: HexString, idx?: Idx<HexString>): string;
|
||||
|
||||
public static getPublicKeyFromCertPEM(sCertPEM: PEM): RSAKey | KJUR.crypto.ECDSA | KJUR.crypto.DSA;
|
||||
|
||||
public static getPublicKeyInfoPropOfCertPEM(sCertPEM: PEM): {
|
||||
algparam: ASN1V | null;
|
||||
leyhex: ASN1V;
|
||||
algoid: ASN1V;
|
||||
};
|
||||
}
|
||||
}
|
||||
15
packages/backend/src/@types/koa-json-body.d.ts
vendored
Normal file
15
packages/backend/src/@types/koa-json-body.d.ts
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
declare module 'koa-json-body' {
|
||||
import { Middleware } from 'koa';
|
||||
|
||||
interface IKoaJsonBodyOptions {
|
||||
strict: boolean;
|
||||
limit: string;
|
||||
fallback: boolean;
|
||||
}
|
||||
|
||||
function koaJsonBody(opt?: IKoaJsonBodyOptions): Middleware;
|
||||
|
||||
namespace koaJsonBody {} // Hack
|
||||
|
||||
export = koaJsonBody;
|
||||
}
|
||||
14
packages/backend/src/@types/koa-slow.d.ts
vendored
Normal file
14
packages/backend/src/@types/koa-slow.d.ts
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
declare module 'koa-slow' {
|
||||
import { Middleware } from 'koa';
|
||||
|
||||
interface ISlowOptions {
|
||||
url?: RegExp;
|
||||
delay?: number;
|
||||
}
|
||||
|
||||
function slow(options?: ISlowOptions): Middleware;
|
||||
|
||||
namespace slow {} // Hack
|
||||
|
||||
export = slow;
|
||||
}
|
||||
10
packages/backend/src/@types/langmap.d.ts
vendored
Normal file
10
packages/backend/src/@types/langmap.d.ts
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
declare module 'langmap' {
|
||||
type Lang = {
|
||||
nativeName: string;
|
||||
englishName: string;
|
||||
};
|
||||
|
||||
const langmap: { [lang: string]: Lang };
|
||||
|
||||
export = langmap;
|
||||
}
|
||||
30
packages/backend/src/@types/os-utils.d.ts
vendored
Normal file
30
packages/backend/src/@types/os-utils.d.ts
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
declare module 'os-utils' {
|
||||
type FreeCommandCallback = (usedmem: number) => void;
|
||||
|
||||
type HarddriveCallback = (total: number, free: number, used: number) => void;
|
||||
|
||||
type GetProcessesCallback = (result: string) => void;
|
||||
|
||||
type CPUCallback = (perc: number) => void;
|
||||
|
||||
export function platform(): NodeJS.Platform;
|
||||
export function cpuCount(): number;
|
||||
export function sysUptime(): number;
|
||||
export function processUptime(): number;
|
||||
|
||||
export function freemem(): number;
|
||||
export function totalmem(): number;
|
||||
export function freememPercentage(): number;
|
||||
export function freeCommand(callback: FreeCommandCallback): void;
|
||||
|
||||
export function harddrive(callback: HarddriveCallback): void;
|
||||
|
||||
export function getProcesses(callback: GetProcessesCallback): void;
|
||||
export function getProcesses(nProcess: number, callback: GetProcessesCallback): void;
|
||||
|
||||
export function allLoadavg(): string;
|
||||
export function loadavg(_time?: number): number;
|
||||
|
||||
export function cpuFree(callback: CPUCallback): void;
|
||||
export function cpuUsage(callback: CPUCallback): void;
|
||||
}
|
||||
10
packages/backend/src/@types/package.json.d.ts
vendored
Normal file
10
packages/backend/src/@types/package.json.d.ts
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
declare module '*/package.json' {
|
||||
interface IRepository {
|
||||
type: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
export const name: string;
|
||||
export const version: string;
|
||||
export const repository: IRepository;
|
||||
}
|
||||
27
packages/backend/src/@types/probe-image-size.d.ts
vendored
Normal file
27
packages/backend/src/@types/probe-image-size.d.ts
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
declare module 'probe-image-size' {
|
||||
import { ReadStream } from 'fs';
|
||||
|
||||
type ProbeOptions = {
|
||||
retries: 1;
|
||||
timeout: 30000;
|
||||
};
|
||||
|
||||
type ProbeResult = {
|
||||
width: number;
|
||||
height: number;
|
||||
length?: number;
|
||||
type: string;
|
||||
mime: string;
|
||||
wUnits: 'in' | 'mm' | 'cm' | 'pt' | 'pc' | 'px' | 'em' | 'ex';
|
||||
hUnits: 'in' | 'mm' | 'cm' | 'pt' | 'pc' | 'px' | 'em' | 'ex';
|
||||
url?: string;
|
||||
};
|
||||
|
||||
function probeImageSize(src: string | ReadStream, options?: ProbeOptions): Promise<ProbeResult>;
|
||||
function probeImageSize(src: string | ReadStream, callback: (err: Error | null, result?: ProbeResult) => void): void;
|
||||
function probeImageSize(src: string | ReadStream, options: ProbeOptions, callback: (err: Error | null, result?: ProbeResult) => void): void;
|
||||
|
||||
namespace probeImageSize {} // Hack
|
||||
|
||||
export = probeImageSize;
|
||||
}
|
||||
|
|
@ -36,8 +36,8 @@ export default function() {
|
|||
tx: round(Math.max(0, netStats.tx_sec)),
|
||||
},
|
||||
fs: {
|
||||
r: round(Math.max(0, fsStats.rIO_sec)),
|
||||
w: round(Math.max(0, fsStats.wIO_sec)),
|
||||
r: round(Math.max(0, fsStats.rIO_sec ?? 0)),
|
||||
w: round(Math.max(0, fsStats.wIO_sec ?? 0)),
|
||||
},
|
||||
};
|
||||
ev.emit('serverStats', stats);
|
||||
|
|
@ -51,9 +51,9 @@ export default function() {
|
|||
}
|
||||
|
||||
// CPU STAT
|
||||
function cpuUsage() {
|
||||
function cpuUsage(): Promise<number> {
|
||||
return new Promise((res, rej) => {
|
||||
osUtils.cpuUsage((cpuUsage: number) => {
|
||||
osUtils.cpuUsage((cpuUsage) => {
|
||||
res(cpuUsage);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ import { URL } from 'url';
|
|||
const urlRegex = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+/;
|
||||
const urlRegexFull = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+$/;
|
||||
|
||||
export function fromHtml(html: string, hashtagNames?: string[]): string | null {
|
||||
if (html == null) return null;
|
||||
|
||||
export function fromHtml(html: string, hashtagNames?: string[]): string {
|
||||
const dom = parse5.parseFragment(html);
|
||||
|
||||
let text = '';
|
||||
|
|
|
|||
|
|
@ -24,14 +24,14 @@ const SHUTDOWN_TIMEOUT = 15000;
|
|||
* down the process.
|
||||
* @type {BeforeShutdownListener[]}
|
||||
*/
|
||||
const shutdownListeners = [];
|
||||
const shutdownListeners: ((signalOrEvent: string) => void)[] = [];
|
||||
|
||||
/**
|
||||
* Listen for signals and execute given `fn` function once.
|
||||
* @param {string[]} signals System signals to listen to.
|
||||
* @param {function(string)} fn Function to execute on shutdown.
|
||||
*/
|
||||
const processOnce = (signals, fn) => {
|
||||
const processOnce = (signals: string[], fn: (signalOrEvent: string) => void) => {
|
||||
for (const sig of signals) {
|
||||
process.once(sig, fn);
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ const processOnce = (signals, fn) => {
|
|||
* Sets a forced shutdown mechanism that will exit the process after `timeout` milliseconds.
|
||||
* @param {number} timeout Time to wait before forcing shutdown (milliseconds)
|
||||
*/
|
||||
const forceExitAfter = timeout => () => {
|
||||
const forceExitAfter = (timeout: number) => () => {
|
||||
setTimeout(() => {
|
||||
// Force shutdown after timeout
|
||||
console.warn(`Could not close resources gracefully after ${timeout}ms: forcing shutdown`);
|
||||
|
|
@ -55,7 +55,7 @@ const forceExitAfter = timeout => () => {
|
|||
* be logged out as a warning, but won't prevent other callbacks from executing.
|
||||
* @param {string} signalOrEvent The exit signal or event name received on the process.
|
||||
*/
|
||||
async function shutdownHandler(signalOrEvent) {
|
||||
async function shutdownHandler(signalOrEvent: string) {
|
||||
if (process.env.NODE_ENV === 'test') return process.exit(0);
|
||||
|
||||
console.warn(`Shutting down: received [${signalOrEvent}] signal`);
|
||||
|
|
@ -64,7 +64,9 @@ async function shutdownHandler(signalOrEvent) {
|
|||
try {
|
||||
await listener(signalOrEvent);
|
||||
} catch (err) {
|
||||
console.warn(`A shutdown handler failed before completing with: ${err.message || err}`);
|
||||
if (err instanceof Error) {
|
||||
console.warn(`A shutdown handler failed before completing with: ${err.message || err}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +80,7 @@ async function shutdownHandler(signalOrEvent) {
|
|||
* @param {BeforeShutdownListener} listener The shutdown listener to register.
|
||||
* @returns {BeforeShutdownListener} Echoes back the supplied `listener`.
|
||||
*/
|
||||
export function beforeShutdown(listener) {
|
||||
export function beforeShutdown(listener: () => void) {
|
||||
shutdownListeners.push(listener);
|
||||
return listener;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,26 +11,31 @@ type UserLike = {
|
|||
id: User['id'];
|
||||
};
|
||||
|
||||
export async function checkWordMute(note: NoteLike, me: UserLike | null | undefined, mutedWords: string[][]): Promise<boolean> {
|
||||
export async function checkWordMute(note: NoteLike, me: UserLike | null | undefined, mutedWords: Array<string | string[]>): Promise<boolean> {
|
||||
// 自分自身
|
||||
if (me && (note.userId === me.id)) return false;
|
||||
|
||||
const words = mutedWords
|
||||
// Clean up
|
||||
.map(xs => xs.filter(x => x !== ''))
|
||||
.filter(xs => xs.length > 0);
|
||||
|
||||
if (words.length > 0) {
|
||||
if (mutedWords.length > 0) {
|
||||
if (note.text == null) return false;
|
||||
|
||||
const matched = words.some(and =>
|
||||
and.every(keyword => {
|
||||
const regexp = keyword.match(/^\/(.+)\/(.*)$/);
|
||||
if (regexp) {
|
||||
const matched = mutedWords.some(filter => {
|
||||
if (Array.isArray(filter)) {
|
||||
return filter.every(keyword => note.text!.includes(keyword));
|
||||
} else {
|
||||
// represents RegExp
|
||||
const regexp = filter.match(/^\/(.+)\/(.*)$/);
|
||||
|
||||
// This should never happen due to input sanitisation.
|
||||
if (!regexp) return false;
|
||||
|
||||
try {
|
||||
return new RE2(regexp[1], regexp[2]).test(note.text!);
|
||||
} catch (err) {
|
||||
// This should never happen due to input sanitisation.
|
||||
return false;
|
||||
}
|
||||
return note.text!.includes(keyword);
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
if (matched) return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,9 @@ export async function downloadUrl(url: string, path: string): Promise<void> {
|
|||
https: httpsAgent,
|
||||
},
|
||||
http2: false, // default
|
||||
retry: 0,
|
||||
retry: {
|
||||
limit: 0,
|
||||
},
|
||||
}).on('response', (res: Got.Response) => {
|
||||
if ((process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'test') && !config.proxy && res.ip) {
|
||||
if (isPrivateIp(res.ip)) {
|
||||
|
|
@ -75,7 +77,7 @@ export async function downloadUrl(url: string, path: string): Promise<void> {
|
|||
logger.succ(`Download finished: ${chalk.cyan(url)}`);
|
||||
}
|
||||
|
||||
function isPrivateIp(ip: string) {
|
||||
function isPrivateIp(ip: string): boolean {
|
||||
for (const net of config.allowedPrivateNetworks || []) {
|
||||
const cidr = new IPCIDR(net);
|
||||
if (cidr.contains(ip)) {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ const sideN = Math.floor(n / 2);
|
|||
*/
|
||||
export function genIdenticon(seed: string, stream: WriteStream): Promise<void> {
|
||||
const rand = gen.create(seed);
|
||||
const canvas = p.make(size, size);
|
||||
const canvas = p.make(size, size, undefined);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.fillStyle = bg;
|
||||
|
|
|
|||
|
|
@ -65,16 +65,18 @@ export const refs = {
|
|||
|
||||
// Packed = SchemaTypeDef<typeof refs[x]>; とすると展開されてマウスホバー時に型表示が使い物にならなくなる
|
||||
// ObjType<r['properties']>を指定すると(なぜか)展開されずにPacked<'Hoge'>と表示される
|
||||
type PackedDef<r extends { properties?: Obj; oneOf?: ReadonlyArray<MinimumSchema>; allOf?: ReadonlyArray<MinimumSchema> }> =
|
||||
r['allOf'] extends ReadonlyArray<MinimumSchema> ? UnionToIntersection<UnionSchemaType<r['allOf']>> :
|
||||
r['oneOf'] extends ReadonlyArray<MinimumSchema> ? UnionSchemaType<r['oneOf']> :
|
||||
r['properties'] extends Obj ? ObjType<r['properties']> :
|
||||
type PackedDef<r extends { properties?: Obj; oneOf?: ReadonlyArray<Schema>; allOf?: ReadonlyArray<Schema> }> =
|
||||
r['allOf'] extends ReadonlyArray<Schema> ? UnionToIntersection<UnionSchemaType<r['allOf']>> :
|
||||
r['oneOf'] extends ReadonlyArray<Schema> ? UnionSchemaType<r['oneOf']> :
|
||||
r['properties'] extends Obj ? ObjType<r['properties'], any> :
|
||||
never;
|
||||
export type Packed<x extends keyof typeof refs> = PackedDef<typeof refs[x]>;
|
||||
|
||||
type TypeStringef = 'boolean' | 'number' | 'string' | 'array' | 'object' | 'any';
|
||||
type TypeStringef = 'null' | 'boolean' | 'integer' | 'number' | 'string' | 'array' | 'object' | 'any';
|
||||
type StringDefToType<T extends TypeStringef> =
|
||||
T extends 'null' ? null :
|
||||
T extends 'boolean' ? boolean :
|
||||
T extends 'integer' ? number :
|
||||
T extends 'number' ? number :
|
||||
T extends 'string' ? string | Date :
|
||||
T extends 'array' ? ReadonlyArray<any> :
|
||||
|
|
@ -83,17 +85,18 @@ type StringDefToType<T extends TypeStringef> =
|
|||
|
||||
// https://swagger.io/specification/?sbsearch=optional#schema-object
|
||||
type OfSchema = {
|
||||
readonly anyOf?: ReadonlyArray<MinimumSchema>;
|
||||
readonly oneOf?: ReadonlyArray<MinimumSchema>;
|
||||
readonly allOf?: ReadonlyArray<MinimumSchema>;
|
||||
readonly anyOf?: ReadonlyArray<Schema>;
|
||||
readonly oneOf?: ReadonlyArray<Schema>;
|
||||
readonly allOf?: ReadonlyArray<Schema>;
|
||||
}
|
||||
|
||||
export interface MinimumSchema extends OfSchema {
|
||||
export interface Schema extends OfSchema {
|
||||
readonly type?: TypeStringef;
|
||||
readonly nullable?: boolean;
|
||||
readonly optional?: boolean;
|
||||
readonly items?: MinimumSchema;
|
||||
readonly items?: Schema;
|
||||
readonly properties?: Obj;
|
||||
readonly required?: ReadonlyArray<keyof NonNullable<this['properties']>>;
|
||||
readonly description?: string;
|
||||
readonly example?: any;
|
||||
readonly format?: string;
|
||||
|
|
@ -104,26 +107,33 @@ export interface MinimumSchema extends OfSchema {
|
|||
readonly minLength?: number;
|
||||
}
|
||||
|
||||
export interface Schema extends MinimumSchema {
|
||||
readonly nullable: boolean;
|
||||
readonly optional: boolean;
|
||||
}
|
||||
|
||||
type NonUndefinedPropertyNames<T extends Obj> = {
|
||||
[K in keyof T]: T[K]['optional'] extends true ? never : K
|
||||
type OptionalPropertyNames<T extends Obj> = {
|
||||
[K in keyof T]: T[K]['optional'] extends true ? K : never
|
||||
}[keyof T];
|
||||
|
||||
type UndefinedPropertyNames<T extends Obj> = {
|
||||
[K in keyof T]: T[K]['optional'] extends true ? K : never
|
||||
type NonOptionalPropertyNames<T extends Obj> = {
|
||||
[K in keyof T]: T[K]['optional'] extends false ? K : never
|
||||
}[keyof T];
|
||||
|
||||
type DefaultPropertyNames<T extends Obj> = {
|
||||
[K in keyof T]: T[K]['default'] extends null ? K :
|
||||
T[K]['default'] extends string ? K :
|
||||
T[K]['default'] extends number ? K :
|
||||
T[K]['default'] extends boolean ? K :
|
||||
T[K]['default'] extends Record<string, unknown> ? K :
|
||||
never
|
||||
}[keyof T];
|
||||
|
||||
export interface Obj { [key: string]: Schema; }
|
||||
|
||||
export type ObjType<s extends Obj> =
|
||||
{ -readonly [P in UndefinedPropertyNames<s>]?: SchemaType<s[P]> } &
|
||||
{ -readonly [P in NonUndefinedPropertyNames<s>]: SchemaType<s[P]> };
|
||||
export type ObjType<s extends Obj, RequiredProps extends ReadonlyArray<keyof s>> =
|
||||
{ -readonly [P in keyof s]?: SchemaType<s[P]> } &
|
||||
{ -readonly [P in RequiredProps[number]]: SchemaType<s[P]> } &
|
||||
{ -readonly [P in OptionalPropertyNames<s>]?: SchemaType<s[P]> } &
|
||||
{ -readonly [P in NonOptionalPropertyNames<s>]: SchemaType<s[P]> } &
|
||||
{ -readonly [P in DefaultPropertyNames<s>]: SchemaType<s[P]> };
|
||||
|
||||
type NullOrUndefined<p extends MinimumSchema, T> =
|
||||
type NullOrUndefined<p extends Schema, T> =
|
||||
p['nullable'] extends true
|
||||
? p['optional'] extends true
|
||||
? (T | null | undefined)
|
||||
|
|
@ -137,10 +147,12 @@ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
|||
|
||||
// https://github.com/misskey-dev/misskey/pull/8144#discussion_r785287552
|
||||
// 単純にSchemaTypeDef<X>で判定するだけではダメ
|
||||
type UnionSchemaType<a extends readonly any[], X extends MinimumSchema = a[number]> = X extends any ? SchemaType<X> : never;
|
||||
type UnionSchemaType<a extends readonly any[], X extends Schema = a[number]> = X extends any ? SchemaType<X> : never;
|
||||
type ArrayUnion<T> = T extends any ? Array<T> : never;
|
||||
|
||||
export type SchemaTypeDef<p extends MinimumSchema> =
|
||||
export type SchemaTypeDef<p extends Schema> =
|
||||
p['type'] extends 'null' ? null :
|
||||
p['type'] extends 'integer' ? number :
|
||||
p['type'] extends 'number' ? number :
|
||||
p['type'] extends 'string' ? (
|
||||
p['enum'] extends readonly string[] ?
|
||||
|
|
@ -151,22 +163,22 @@ export type SchemaTypeDef<p extends MinimumSchema> =
|
|||
p['type'] extends 'boolean' ? boolean :
|
||||
p['type'] extends 'object' ? (
|
||||
p['ref'] extends keyof typeof refs ? Packed<p['ref']> :
|
||||
p['properties'] extends NonNullable<Obj> ? ObjType<p['properties']> :
|
||||
p['anyOf'] extends ReadonlyArray<MinimumSchema> ? UnionSchemaType<p['anyOf']> & Partial<UnionToIntersection<UnionSchemaType<p['anyOf']>>> :
|
||||
p['allOf'] extends ReadonlyArray<MinimumSchema> ? UnionToIntersection<UnionSchemaType<p['allOf']>> :
|
||||
p['properties'] extends NonNullable<Obj> ? ObjType<p['properties'], NonNullable<p['required']>> :
|
||||
p['anyOf'] extends ReadonlyArray<Schema> ? UnionSchemaType<p['anyOf']> & Partial<UnionToIntersection<UnionSchemaType<p['anyOf']>>> :
|
||||
p['allOf'] extends ReadonlyArray<Schema> ? UnionToIntersection<UnionSchemaType<p['allOf']>> :
|
||||
any
|
||||
) :
|
||||
p['type'] extends 'array' ? (
|
||||
p['items'] extends OfSchema ? (
|
||||
p['items']['anyOf'] extends ReadonlyArray<MinimumSchema> ? UnionSchemaType<NonNullable<p['items']['anyOf']>>[] :
|
||||
p['items']['oneOf'] extends ReadonlyArray<MinimumSchema> ? ArrayUnion<UnionSchemaType<NonNullable<p['items']['oneOf']>>> :
|
||||
p['items']['allOf'] extends ReadonlyArray<MinimumSchema> ? UnionToIntersection<UnionSchemaType<NonNullable<p['items']['allOf']>>>[] :
|
||||
p['items']['anyOf'] extends ReadonlyArray<Schema> ? UnionSchemaType<NonNullable<p['items']['anyOf']>>[] :
|
||||
p['items']['oneOf'] extends ReadonlyArray<Schema> ? ArrayUnion<UnionSchemaType<NonNullable<p['items']['oneOf']>>> :
|
||||
p['items']['allOf'] extends ReadonlyArray<Schema> ? UnionToIntersection<UnionSchemaType<NonNullable<p['items']['allOf']>>>[] :
|
||||
never
|
||||
) :
|
||||
p['items'] extends NonNullable<MinimumSchema> ? SchemaTypeDef<p['items']>[] :
|
||||
p['items'] extends NonNullable<Schema> ? SchemaTypeDef<p['items']>[] :
|
||||
any[]
|
||||
) :
|
||||
p['oneOf'] extends ReadonlyArray<MinimumSchema> ? UnionSchemaType<p['oneOf']> :
|
||||
p['oneOf'] extends ReadonlyArray<Schema> ? UnionSchemaType<p['oneOf']> :
|
||||
any;
|
||||
|
||||
export type SchemaType<p extends MinimumSchema> = NullOrUndefined<p, SchemaTypeDef<p>>;
|
||||
export type SchemaType<p extends Schema> = NullOrUndefined<p, SchemaTypeDef<p>>;
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ export class Following {
|
|||
public follower: User | null;
|
||||
|
||||
//#region Denormalized fields
|
||||
@Index()
|
||||
@Column('varchar', {
|
||||
length: 128, nullable: true,
|
||||
comment: '[Denormalized]',
|
||||
|
|
@ -59,6 +60,7 @@ export class Following {
|
|||
})
|
||||
public followerSharedInbox: string | null;
|
||||
|
||||
@Index()
|
||||
@Column('varchar', {
|
||||
length: 128, nullable: true,
|
||||
comment: '[Denormalized]',
|
||||
|
|
|
|||
|
|
@ -88,6 +88,12 @@ export class Meta {
|
|||
})
|
||||
public pinnedClipId: Clip['id'] | null;
|
||||
|
||||
@Column('varchar', {
|
||||
length: 512,
|
||||
nullable: true,
|
||||
})
|
||||
public themeColor: string | null;
|
||||
|
||||
@Column('varchar', {
|
||||
length: 512,
|
||||
nullable: true,
|
||||
|
|
|
|||
|
|
@ -225,6 +225,12 @@ export class User {
|
|||
})
|
||||
public followersUri: string | null;
|
||||
|
||||
@Column('boolean', {
|
||||
default: false,
|
||||
comment: 'Whether to show users replying to other users in the timeline'
|
||||
})
|
||||
public showTimelineReplies: boolean;
|
||||
|
||||
@Index({ unique: true })
|
||||
@Column('char', {
|
||||
length: 16, nullable: true, unique: true,
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ import { RegistryItem } from './entities/registry-item';
|
|||
import { Ad } from './entities/ad';
|
||||
import { PasswordResetRequest } from './entities/password-reset-request';
|
||||
import { UserPending } from './entities/user-pending';
|
||||
import { InstanceRepository } from './repositories/instance';
|
||||
|
||||
export const Announcements = getRepository(Announcement);
|
||||
export const AnnouncementReads = getRepository(AnnouncementRead);
|
||||
|
|
@ -89,7 +90,7 @@ export const UserNotePinings = getRepository(UserNotePining);
|
|||
export const UsedUsernames = getRepository(UsedUsername);
|
||||
export const Followings = getCustomRepository(FollowingRepository);
|
||||
export const FollowRequests = getCustomRepository(FollowRequestRepository);
|
||||
export const Instances = getRepository(Instance);
|
||||
export const Instances = getCustomRepository(InstanceRepository);
|
||||
export const Emojis = getCustomRepository(EmojiRepository);
|
||||
export const DriveFiles = getCustomRepository(DriveFileRepository);
|
||||
export const DriveFolders = getCustomRepository(DriveFolderRepository);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export class AbuseUserReportRepository extends Repository<AbuseUserReport> {
|
|||
|
||||
return await awaitAll({
|
||||
id: report.id,
|
||||
createdAt: report.createdAt,
|
||||
createdAt: report.createdAt.toISOString(),
|
||||
comment: report.comment,
|
||||
resolved: report.resolved,
|
||||
reporterId: report.reporterId,
|
||||
|
|
|
|||
|
|
@ -6,13 +6,6 @@ import { Packed } from '@/misc/schema';
|
|||
|
||||
@EntityRepository(DriveFolder)
|
||||
export class DriveFolderRepository extends Repository<DriveFolder> {
|
||||
public validateFolderName(name: string): boolean {
|
||||
return (
|
||||
(name.trim().length > 0) &&
|
||||
(name.length <= 200)
|
||||
);
|
||||
}
|
||||
|
||||
public async pack(
|
||||
src: DriveFolder['id'] | DriveFolder,
|
||||
options?: {
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
import config from '@/config/index';
|
||||
|
||||
39
packages/backend/src/models/repositories/instance.ts
Normal file
39
packages/backend/src/models/repositories/instance.ts
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { Instance } from '@/models/entities/instance';
|
||||
import { Packed } from '@/misc/schema';
|
||||
|
||||
@EntityRepository(Instance)
|
||||
export class InstanceRepository extends Repository<Instance> {
|
||||
public async pack(
|
||||
instance: Instance,
|
||||
): Promise<Packed<'FederationInstance'>> {
|
||||
return {
|
||||
id: instance.id,
|
||||
caughtAt: instance.caughtAt.toISOString(),
|
||||
host: instance.host,
|
||||
usersCount: instance.usersCount,
|
||||
notesCount: instance.notesCount,
|
||||
followingCount: instance.followingCount,
|
||||
followersCount: instance.followersCount,
|
||||
latestRequestSentAt: instance.latestRequestSentAt ? instance.latestRequestSentAt.toISOString() : null,
|
||||
lastCommunicatedAt: instance.lastCommunicatedAt.toISOString(),
|
||||
isNotResponding: instance.isNotResponding,
|
||||
isSuspended: instance.isSuspended,
|
||||
softwareName: instance.softwareName,
|
||||
softwareVersion: instance.softwareVersion,
|
||||
openRegistrations: instance.openRegistrations,
|
||||
name: instance.name,
|
||||
description: instance.description,
|
||||
maintainerName: instance.maintainerName,
|
||||
maintainerEmail: instance.maintainerEmail,
|
||||
iconUrl: instance.iconUrl,
|
||||
infoUpdatedAt: instance.infoUpdatedAt ? instance.infoUpdatedAt.toISOString() : null,
|
||||
};
|
||||
}
|
||||
|
||||
public packMany(
|
||||
instances: Instance[],
|
||||
) {
|
||||
return Promise.all(instances.map(x => this.pack(x)));
|
||||
}
|
||||
}
|
||||
|
|
@ -6,10 +6,6 @@ import { User } from '@/models/entities/user';
|
|||
|
||||
@EntityRepository(MessagingMessage)
|
||||
export class MessagingMessageRepository extends Repository<MessagingMessage> {
|
||||
public validateText(text: string): boolean {
|
||||
return text.trim().length <= 1000 && text.trim() != '';
|
||||
}
|
||||
|
||||
public async pack(
|
||||
src: MessagingMessage['id'] | MessagingMessage,
|
||||
me?: { id: User['id'] } | null | undefined,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export class ModerationLogRepository extends Repository<ModerationLog> {
|
|||
|
||||
return await awaitAll({
|
||||
id: log.id,
|
||||
createdAt: log.createdAt,
|
||||
createdAt: log.createdAt.toISOString(),
|
||||
type: log.type,
|
||||
info: log.info,
|
||||
userId: log.userId,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export class NoteFavoriteRepository extends Repository<NoteFavorite> {
|
|||
|
||||
return {
|
||||
id: favorite.id,
|
||||
createdAt: favorite.createdAt,
|
||||
createdAt: favorite.createdAt.toISOString(),
|
||||
noteId: favorite.noteId,
|
||||
note: await Notes.pack(favorite.note || favorite.noteId, me),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,10 +12,6 @@ import { aggregateNoteEmojis, populateEmojis, prefetchEmojis } from '@/misc/popu
|
|||
|
||||
@EntityRepository(Note)
|
||||
export class NoteRepository extends Repository<Note> {
|
||||
public validateCw(x: string) {
|
||||
return x.trim().length <= 100;
|
||||
}
|
||||
|
||||
public async isVisibleForMe(note: Note, meId: User['id'] | null): Promise<boolean> {
|
||||
// visibility が specified かつ自分が指定されていなかったら非表示
|
||||
if (note.visibility === 'specified') {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import $ from 'cafy';
|
||||
import { EntityRepository, Repository, In, Not } from 'typeorm';
|
||||
import * as Ajv from 'ajv';
|
||||
import { User, ILocalUser, IRemoteUser } from '@/models/entities/user';
|
||||
import { Notes, NoteUnreads, FollowRequests, Notifications, MessagingMessages, UserNotePinings, Followings, Blockings, Mutings, UserProfiles, UserSecurityKeys, UserGroupJoinings, Pages, Announcements, AnnouncementReads, Antennas, AntennaNotes, ChannelFollowings, Instances } from '../index';
|
||||
import config from '@/config/index';
|
||||
|
|
@ -17,8 +17,26 @@ type IsMeAndIsUserDetailed<ExpectsMe extends boolean | null, Detailed extends bo
|
|||
Packed<'UserDetailed'> :
|
||||
Packed<'UserLite'>;
|
||||
|
||||
const ajv = new Ajv();
|
||||
|
||||
@EntityRepository(User)
|
||||
export class UserRepository extends Repository<User> {
|
||||
public localUsernameSchema = { type: 'string', pattern: /^\w{1,20}$/.toString().slice(1, -1) } as const;
|
||||
public passwordSchema = { type: 'string', minLength: 1 } as const;
|
||||
public nameSchema = { type: 'string', minLength: 1, maxLength: 50 } as const;
|
||||
public descriptionSchema = { type: 'string', minLength: 1, maxLength: 500 } as const;
|
||||
public locationSchema = { type: 'string', minLength: 1, maxLength: 50 } as const;
|
||||
public birthdaySchema = { type: 'string', pattern: /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.toString().slice(1, -1) } as const;
|
||||
|
||||
//#region Validators
|
||||
public validateLocalUsername = ajv.compile(this.localUsernameSchema);
|
||||
public validatePassword = ajv.compile(this.passwordSchema);
|
||||
public validateName = ajv.compile(this.nameSchema);
|
||||
public validateDescription = ajv.compile(this.descriptionSchema);
|
||||
public validateLocation = ajv.compile(this.locationSchema);
|
||||
public validateBirthday = ajv.compile(this.birthdaySchema);
|
||||
//#endregion
|
||||
|
||||
public async getRelation(me: User['id'], target: User['id']) {
|
||||
const [following1, following2, followReq1, followReq2, toBlocking, fromBlocked, mute] = await Promise.all([
|
||||
Followings.findOne({
|
||||
|
|
@ -220,6 +238,7 @@ export class UserRepository extends Repository<User> {
|
|||
isModerator: user.isModerator || falsy,
|
||||
isBot: user.isBot || falsy,
|
||||
isCat: user.isCat || falsy,
|
||||
showTimelineReplies: user.showTimelineReplies || falsy,
|
||||
instance: user.host ? Instances.findOne({ host: user.host }).then(instance => instance ? {
|
||||
name: instance.name,
|
||||
softwareName: instance.softwareName,
|
||||
|
|
@ -350,13 +369,4 @@ export class UserRepository extends Repository<User> {
|
|||
public isRemoteUser(user: User | { host: User['host'] }): boolean {
|
||||
return !this.isLocalUser(user);
|
||||
}
|
||||
|
||||
//#region Validators
|
||||
public validateLocalUsername = $.str.match(/^\w{1,20}$/);
|
||||
public validatePassword = $.str.min(1);
|
||||
public validateName = $.str.min(1).max(50);
|
||||
public validateDescription = $.str.min(1).max(500);
|
||||
public validateLocation = $.str.min(1).max(50);
|
||||
public validateBirthday = $.str.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/);
|
||||
//#endregion
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,14 +34,6 @@ export const packedFederationInstanceSchema = {
|
|||
type: 'number',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
driveUsage: {
|
||||
type: 'number',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
driveFiles: {
|
||||
type: 'number',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
latestRequestSentAt: {
|
||||
type: 'string',
|
||||
optional: false, nullable: true,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ import { envOption } from '../env';
|
|||
import processDeliver from './processors/deliver';
|
||||
import processInbox from './processors/inbox';
|
||||
import processDb from './processors/db/index';
|
||||
import procesObjectStorage from './processors/object-storage/index';
|
||||
import processObjectStorage from './processors/object-storage/index';
|
||||
import processSystemQueue from './processors/system/index';
|
||||
import { queueLogger } from './logger';
|
||||
import { DriveFile } from '@/models/entities/drive-file';
|
||||
import { getJobInfo } from './get-job-info';
|
||||
|
|
@ -255,12 +256,24 @@ export default function() {
|
|||
deliverQueue.process(config.deliverJobConcurrency || 128, processDeliver);
|
||||
inboxQueue.process(config.inboxJobConcurrency || 16, processInbox);
|
||||
processDb(dbQueue);
|
||||
procesObjectStorage(objectStorageQueue);
|
||||
processObjectStorage(objectStorageQueue);
|
||||
|
||||
systemQueue.add('tickCharts', {
|
||||
}, {
|
||||
repeat: { cron: '55 * * * *' },
|
||||
});
|
||||
|
||||
systemQueue.add('resyncCharts', {
|
||||
}, {
|
||||
repeat: { cron: '0 0 * * *' },
|
||||
});
|
||||
|
||||
systemQueue.add('cleanCharts', {
|
||||
}, {
|
||||
repeat: { cron: '0 0 * * *' },
|
||||
});
|
||||
|
||||
processSystemQueue(systemQueue);
|
||||
}
|
||||
|
||||
export function destroy() {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ export async function deleteAccount(job: Bull.Job<DbUserDeleteJobData>): Promise
|
|||
order: {
|
||||
id: 1,
|
||||
},
|
||||
});
|
||||
}) as Note[];
|
||||
|
||||
if (notes.length === 0) {
|
||||
break;
|
||||
|
|
@ -58,7 +58,7 @@ export async function deleteAccount(job: Bull.Job<DbUserDeleteJobData>): Promise
|
|||
order: {
|
||||
id: 1,
|
||||
},
|
||||
});
|
||||
}) as DriveFile[];
|
||||
|
||||
if (files.length === 0) {
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import * as fs from 'fs';
|
|||
|
||||
import { queueLogger } from '../../logger';
|
||||
import { addFile } from '@/services/drive/add-file';
|
||||
import * as dateFormat from 'dateformat';
|
||||
import { format as dateFormat } from 'date-fns';
|
||||
import { getFullApAccount } from '@/misc/convert-host';
|
||||
import { Users, Blockings } from '@/models/index';
|
||||
import { MoreThan } from 'typeorm';
|
||||
|
|
@ -85,7 +85,7 @@ export async function exportBlocking(job: Bull.Job<DbUserJobData>, done: any): P
|
|||
stream.end();
|
||||
logger.succ(`Exported to: ${path}`);
|
||||
|
||||
const fileName = 'blocking-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.csv';
|
||||
const fileName = 'blocking-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.csv';
|
||||
const driveFile = await addFile({ user, path, name: fileName, force: true });
|
||||
|
||||
logger.succ(`Exported to: ${driveFile.id}`);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ const mime = require('mime-types');
|
|||
const archiver = require('archiver');
|
||||
import { queueLogger } from '../../logger';
|
||||
import { addFile } from '@/services/drive/add-file';
|
||||
import * as dateFormat from 'dateformat';
|
||||
import { format as dateFormat } from 'date-fns';
|
||||
import { Users, Emojis } from '@/models/index';
|
||||
import { } from '@/queue/types';
|
||||
import { downloadUrl } from '@/misc/download-url';
|
||||
|
|
@ -75,7 +75,7 @@ export async function exportCustomEmojis(job: Bull.Job, done: () => void): Promi
|
|||
await downloadUrl(emoji.originalUrl, emojiPath);
|
||||
downloaded = true;
|
||||
} catch (e) { // TODO: 何度か再試行
|
||||
logger.error(e);
|
||||
logger.error(e instanceof Error ? e : new Error(e as string));
|
||||
}
|
||||
|
||||
if (!downloaded) {
|
||||
|
|
@ -110,7 +110,7 @@ export async function exportCustomEmojis(job: Bull.Job, done: () => void): Promi
|
|||
archiveStream.on('close', async () => {
|
||||
logger.succ(`Exported to: ${archivePath}`);
|
||||
|
||||
const fileName = 'custom-emojis-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.zip';
|
||||
const fileName = 'custom-emojis-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.zip';
|
||||
const driveFile = await addFile({ user, path: archivePath, name: fileName, force: true });
|
||||
|
||||
logger.succ(`Exported to: ${driveFile.id}`);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import * as fs from 'fs';
|
|||
|
||||
import { queueLogger } from '../../logger';
|
||||
import { addFile } from '@/services/drive/add-file';
|
||||
import * as dateFormat from 'dateformat';
|
||||
import { format as dateFormat } from 'date-fns';
|
||||
import { getFullApAccount } from '@/misc/convert-host';
|
||||
import { Users, Followings, Mutings } from '@/models/index';
|
||||
import { In, MoreThan, Not } from 'typeorm';
|
||||
|
|
@ -51,7 +51,7 @@ export async function exportFollowing(job: Bull.Job<DbUserJobData>, done: () =>
|
|||
order: {
|
||||
id: 1,
|
||||
},
|
||||
});
|
||||
}) as Following[];
|
||||
|
||||
if (followings.length === 0) {
|
||||
break;
|
||||
|
|
@ -86,7 +86,7 @@ export async function exportFollowing(job: Bull.Job<DbUserJobData>, done: () =>
|
|||
stream.end();
|
||||
logger.succ(`Exported to: ${path}`);
|
||||
|
||||
const fileName = 'following-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.csv';
|
||||
const fileName = 'following-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.csv';
|
||||
const driveFile = await addFile({ user, path, name: fileName, force: true });
|
||||
|
||||
logger.succ(`Exported to: ${driveFile.id}`);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import * as fs from 'fs';
|
|||
|
||||
import { queueLogger } from '../../logger';
|
||||
import { addFile } from '@/services/drive/add-file';
|
||||
import * as dateFormat from 'dateformat';
|
||||
import { format as dateFormat } from 'date-fns';
|
||||
import { getFullApAccount } from '@/misc/convert-host';
|
||||
import { Users, Mutings } from '@/models/index';
|
||||
import { MoreThan } from 'typeorm';
|
||||
|
|
@ -85,7 +85,7 @@ export async function exportMute(job: Bull.Job<DbUserJobData>, done: any): Promi
|
|||
stream.end();
|
||||
logger.succ(`Exported to: ${path}`);
|
||||
|
||||
const fileName = 'mute-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.csv';
|
||||
const fileName = 'mute-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.csv';
|
||||
const driveFile = await addFile({ user, path, name: fileName, force: true });
|
||||
|
||||
logger.succ(`Exported to: ${driveFile.id}`);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import * as fs from 'fs';
|
|||
|
||||
import { queueLogger } from '../../logger';
|
||||
import { addFile } from '@/services/drive/add-file';
|
||||
import * as dateFormat from 'dateformat';
|
||||
import { format as dateFormat } from 'date-fns';
|
||||
import { Users, Notes, Polls } from '@/models/index';
|
||||
import { MoreThan } from 'typeorm';
|
||||
import { Note } from '@/models/entities/note';
|
||||
|
|
@ -62,7 +62,7 @@ export async function exportNotes(job: Bull.Job<DbUserJobData>, done: any): Prom
|
|||
order: {
|
||||
id: 1,
|
||||
},
|
||||
});
|
||||
}) as Note[];
|
||||
|
||||
if (notes.length === 0) {
|
||||
job.progress(100);
|
||||
|
|
@ -94,7 +94,7 @@ export async function exportNotes(job: Bull.Job<DbUserJobData>, done: any): Prom
|
|||
stream.end();
|
||||
logger.succ(`Exported to: ${path}`);
|
||||
|
||||
const fileName = 'notes-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.json';
|
||||
const fileName = 'notes-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.json';
|
||||
const driveFile = await addFile({ user, path, name: fileName, force: true });
|
||||
|
||||
logger.succ(`Exported to: ${driveFile.id}`);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import * as fs from 'fs';
|
|||
|
||||
import { queueLogger } from '../../logger';
|
||||
import { addFile } from '@/services/drive/add-file';
|
||||
import * as dateFormat from 'dateformat';
|
||||
import { format as dateFormat } from 'date-fns';
|
||||
import { getFullApAccount } from '@/misc/convert-host';
|
||||
import { Users, UserLists, UserListJoinings } from '@/models/index';
|
||||
import { In } from 'typeorm';
|
||||
|
|
@ -62,7 +62,7 @@ export async function exportUserLists(job: Bull.Job<DbUserJobData>, done: any):
|
|||
stream.end();
|
||||
logger.succ(`Exported to: ${path}`);
|
||||
|
||||
const fileName = 'user-lists-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.csv';
|
||||
const fileName = 'user-lists-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.csv';
|
||||
const driveFile = await addFile({ user, path, name: fileName, force: true });
|
||||
|
||||
logger.succ(`Exported to: ${driveFile.id}`);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,9 @@ export async function importCustomEmojis(job: Bull.Job<DbUserImportJobData>, don
|
|||
fs.writeFileSync(destPath, '', 'binary');
|
||||
await downloadUrl(file.url, destPath);
|
||||
} catch (e) { // TODO: 何度か再試行
|
||||
logger.error(e);
|
||||
if (e instanceof Error || typeof e === 'string') {
|
||||
logger.error(e);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ export async function importUserLists(job: Bull.Job<DbUserImportJobData>, done:
|
|||
createdAt: new Date(),
|
||||
userId: user.id,
|
||||
name: listName,
|
||||
userIds: [],
|
||||
}).then(x => UserLists.findOneOrFail(x.identifiers[0]));
|
||||
}
|
||||
|
||||
|
|
@ -67,9 +66,9 @@ export async function importUserLists(job: Bull.Job<DbUserImportJobData>, done:
|
|||
target = await resolveUser(username, host);
|
||||
}
|
||||
|
||||
if (await UserListJoinings.findOne({ userListId: list.id, userId: target.id }) != null) continue;
|
||||
if (await UserListJoinings.findOne({ userListId: list!.id, userId: target.id }) != null) continue;
|
||||
|
||||
pushUserToUserList(target, list);
|
||||
pushUserToUserList(target, list!);
|
||||
} catch (e) {
|
||||
logger.warn(`Error in line:${linenum} ${e}`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import request from '@/remote/activitypub/request';
|
|||
import { registerOrFetchInstanceDoc } from '@/services/register-or-fetch-instance-doc';
|
||||
import Logger from '@/services/logger';
|
||||
import { Instances } from '@/models/index';
|
||||
import { instanceChart } from '@/services/chart/index';
|
||||
import { apRequestChart, federationChart, instanceChart } from '@/services/chart/index';
|
||||
import { fetchInstanceMetadata } from '@/services/fetch-instance-metadata';
|
||||
import { fetchMeta } from '@/misc/fetch-meta';
|
||||
import { toPuny } from '@/misc/convert-host';
|
||||
|
|
@ -61,6 +61,8 @@ export default async (job: Bull.Job<DeliverJobData>) => {
|
|||
fetchInstanceMetadata(i);
|
||||
|
||||
instanceChart.requestSent(i.host, true);
|
||||
apRequestChart.deliverSucc();
|
||||
federationChart.deliverd(i.host, true);
|
||||
});
|
||||
|
||||
return 'Success';
|
||||
|
|
@ -74,6 +76,8 @@ export default async (job: Bull.Job<DeliverJobData>) => {
|
|||
});
|
||||
|
||||
instanceChart.requestSent(i.host, false);
|
||||
apRequestChart.deliverFail();
|
||||
federationChart.deliverd(i.host, false);
|
||||
});
|
||||
|
||||
if (res instanceof StatusError) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import perform from '@/remote/activitypub/perform';
|
|||
import Logger from '@/services/logger';
|
||||
import { registerOrFetchInstanceDoc } from '@/services/register-or-fetch-instance-doc';
|
||||
import { Instances } from '@/models/index';
|
||||
import { instanceChart } from '@/services/chart/index';
|
||||
import { apRequestChart, federationChart, instanceChart } from '@/services/chart/index';
|
||||
import { fetchMeta } from '@/misc/fetch-meta';
|
||||
import { toPuny, extractDbHost } from '@/misc/convert-host';
|
||||
import { getApId } from '@/remote/activitypub/type';
|
||||
|
|
@ -54,10 +54,12 @@ export default async (job: Bull.Job<InboxJobData>): Promise<string> => {
|
|||
authUser = await dbResolver.getAuthUserFromApId(getApId(activity.actor));
|
||||
} catch (e) {
|
||||
// 対象が4xxならスキップ
|
||||
if (e instanceof StatusError && e.isClientError) {
|
||||
return `skip: Ignored deleted actors on both ends ${activity.actor} - ${e.statusCode}`;
|
||||
if (e instanceof StatusError) {
|
||||
if (e.isClientError) {
|
||||
return `skip: Ignored deleted actors on both ends ${activity.actor} - ${e.statusCode}`;
|
||||
}
|
||||
throw `Error in actor ${activity.actor} - ${e.statusCode || e}`;
|
||||
}
|
||||
throw `Error in actor ${activity.actor} - ${e.statusCode || e}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -141,6 +143,8 @@ export default async (job: Bull.Job<InboxJobData>): Promise<string> => {
|
|||
fetchInstanceMetadata(i);
|
||||
|
||||
instanceChart.requestReceived(i.host);
|
||||
apRequestChart.inbox();
|
||||
federationChart.inbox(i.host);
|
||||
});
|
||||
|
||||
// アクティビティを処理
|
||||
|
|
|
|||
28
packages/backend/src/queue/processors/system/clean-charts.ts
Normal file
28
packages/backend/src/queue/processors/system/clean-charts.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import * as Bull from 'bull';
|
||||
|
||||
import { queueLogger } from '../../logger';
|
||||
import { activeUsersChart, driveChart, federationChart, hashtagChart, instanceChart, notesChart, perUserDriveChart, perUserFollowingChart, perUserNotesChart, perUserReactionsChart, usersChart, apRequestChart } from '@/services/chart/index';
|
||||
|
||||
const logger = queueLogger.createSubLogger('clean-charts');
|
||||
|
||||
export async function cleanCharts(job: Bull.Job<Record<string, unknown>>, done: any): Promise<void> {
|
||||
logger.info(`Clean charts...`);
|
||||
|
||||
await Promise.all([
|
||||
federationChart.clean(),
|
||||
notesChart.clean(),
|
||||
usersChart.clean(),
|
||||
activeUsersChart.clean(),
|
||||
instanceChart.clean(),
|
||||
perUserNotesChart.clean(),
|
||||
driveChart.clean(),
|
||||
perUserReactionsChart.clean(),
|
||||
hashtagChart.clean(),
|
||||
perUserFollowingChart.clean(),
|
||||
perUserDriveChart.clean(),
|
||||
apRequestChart.clean(),
|
||||
]);
|
||||
|
||||
logger.succ(`All charts successfully cleaned.`);
|
||||
done();
|
||||
}
|
||||
|
|
@ -1,8 +1,12 @@
|
|||
import * as Bull from 'bull';
|
||||
import { tickCharts } from './tick-charts';
|
||||
import { resyncCharts } from './resync-charts';
|
||||
import { cleanCharts } from './clean-charts';
|
||||
|
||||
const jobs = {
|
||||
tickCharts,
|
||||
resyncCharts,
|
||||
cleanCharts,
|
||||
} as Record<string, Bull.ProcessCallbackFunction<Record<string, unknown>> | Bull.ProcessPromiseFunction<Record<string, unknown>>>;
|
||||
|
||||
export default function(dbQueue: Bull.Queue<Record<string, unknown>>) {
|
||||
|
|
|
|||
28
packages/backend/src/queue/processors/system/tick-charts.ts
Normal file
28
packages/backend/src/queue/processors/system/tick-charts.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import * as Bull from 'bull';
|
||||
|
||||
import { queueLogger } from '../../logger';
|
||||
import { activeUsersChart, driveChart, federationChart, hashtagChart, instanceChart, notesChart, perUserDriveChart, perUserFollowingChart, perUserNotesChart, perUserReactionsChart, usersChart, apRequestChart } from '@/services/chart/index';
|
||||
|
||||
const logger = queueLogger.createSubLogger('tick-charts');
|
||||
|
||||
export async function tickCharts(job: Bull.Job<Record<string, unknown>>, done: any): Promise<void> {
|
||||
logger.info(`Tick charts...`);
|
||||
|
||||
await Promise.all([
|
||||
federationChart.tick(false),
|
||||
notesChart.tick(false),
|
||||
usersChart.tick(false),
|
||||
activeUsersChart.tick(false),
|
||||
instanceChart.tick(false),
|
||||
perUserNotesChart.tick(false),
|
||||
driveChart.tick(false),
|
||||
perUserReactionsChart.tick(false),
|
||||
hashtagChart.tick(false),
|
||||
perUserFollowingChart.tick(false),
|
||||
perUserDriveChart.tick(false),
|
||||
apRequestChart.tick(false),
|
||||
]);
|
||||
|
||||
logger.succ(`All charts successfully ticked.`);
|
||||
done();
|
||||
}
|
||||
|
|
@ -42,11 +42,14 @@ export default async function(resolver: Resolver, actor: IRemoteUser, activity:
|
|||
renote = await resolveNote(targetUri);
|
||||
} catch (e) {
|
||||
// 対象が4xxならスキップ
|
||||
if (e instanceof StatusError && e.isClientError) {
|
||||
logger.warn(`Ignored announce target ${targetUri} - ${e.statusCode}`);
|
||||
return;
|
||||
if (e instanceof StatusError) {
|
||||
if (e.isClientError) {
|
||||
logger.warn(`Ignored announce target ${targetUri} - ${e.statusCode}`);
|
||||
return;
|
||||
}
|
||||
|
||||
logger.warn(`Error in announce target ${targetUri} - ${e.statusCode || e}`);
|
||||
}
|
||||
logger.warn(`Error in announce target ${targetUri} - ${e.statusCode || e}`);
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export default async (actor: IRemoteUser, activity: IFlag): Promise<string> => {
|
|||
// 対象ユーザーは一番最初のユーザー として あとはコメントとして格納する
|
||||
const uris = getApIds(activity.object);
|
||||
|
||||
const userIds = uris.filter(uri => uri.startsWith(config.url + '/users/')).map(uri => uri.split('/').pop());
|
||||
const userIds = uris.filter(uri => uri.startsWith(config.url + '/users/')).map(uri => uri.split('/').pop()!);
|
||||
const users = await Users.find({
|
||||
id: In(userIds),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -25,8 +25,10 @@ export async function performActivity(actor: IRemoteUser, activity: IObject) {
|
|||
const act = await resolver.resolve(item);
|
||||
try {
|
||||
await performOneActivity(actor, act);
|
||||
} catch (e) {
|
||||
apLogger.error(e);
|
||||
} catch (err) {
|
||||
if (err instanceof Error || typeof err === 'string') {
|
||||
apLogger.error(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ export class LdSignature {
|
|||
} as {
|
||||
type: string;
|
||||
creator: string;
|
||||
domain: string;
|
||||
domain?: string;
|
||||
nonce: string;
|
||||
created: string;
|
||||
};
|
||||
|
|
@ -114,7 +114,7 @@ export class LdSignature {
|
|||
Accept: 'application/ld+json, application/json',
|
||||
},
|
||||
timeout: this.loderTimeout,
|
||||
agent: u => u.protocol == 'http:' ? httpAgent : httpsAgent,
|
||||
agent: u => u.protocol === 'http:' ? httpAgent : httpsAgent,
|
||||
}).then(res => {
|
||||
if (!res.ok) {
|
||||
throw `${res.status} ${res.statusText}`;
|
||||
|
|
|
|||
|
|
@ -164,6 +164,7 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<Us
|
|||
tags,
|
||||
isBot,
|
||||
isCat: (person as any).isCat === true,
|
||||
showTimelineReplies: false,
|
||||
})) as IRemoteUser;
|
||||
|
||||
await transactionalEntityManager.save(new UserProfile({
|
||||
|
|
@ -198,7 +199,7 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<Us
|
|||
throw new Error('already registered');
|
||||
}
|
||||
} else {
|
||||
logger.error(e);
|
||||
logger.error(e instanceof Error ? e : new Error(e as string));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import { In } from 'typeorm';
|
|||
import { Emoji } from '@/models/entities/emoji';
|
||||
import { Poll } from '@/models/entities/poll';
|
||||
|
||||
export default async function renderNote(note: Note, dive = true, isTalk = false): Promise<any> {
|
||||
export default async function renderNote(note: Note, dive = true, isTalk = false): Promise<Record<string, unknown>> {
|
||||
const getPromisedFiles = async (ids: string[]) => {
|
||||
if (!ids || ids.length === 0) return [];
|
||||
const items = await DriveFiles.find({ id: In(ids) });
|
||||
|
|
|
|||
|
|
@ -6,7 +6,14 @@
|
|||
* @param last URL of last page (optional)
|
||||
* @param orderedItems attached objects (optional)
|
||||
*/
|
||||
export default function(id: string | null, totalItems: any, first?: string, last?: string, orderedItems?: Record<string, unknown>) {
|
||||
export default function(id: string | null, totalItems: any, first?: string, last?: string, orderedItems?: Record<string, unknown>[]): {
|
||||
id: string | null;
|
||||
type: 'OrderedCollection';
|
||||
totalItems: any;
|
||||
first?: string;
|
||||
last?: string;
|
||||
orderedItems?: Record<string, unknown>[];
|
||||
} {
|
||||
const page: any = {
|
||||
id,
|
||||
type: 'OrderedCollection',
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ export default async (ctx: Router.RouterContext) => {
|
|||
|
||||
const rendered = renderOrderedCollection(
|
||||
`${config.url}/users/${userId}/collections/featured`,
|
||||
renderedNotes.length, undefined, undefined, renderedNotes
|
||||
renderedNotes.length, undefined, undefined, renderedNotes,
|
||||
);
|
||||
|
||||
ctx.body = renderActivity(rendered);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import authenticate, { AuthenticationError } from './authenticate';
|
|||
import call from './call';
|
||||
import { ApiError } from './error';
|
||||
|
||||
export default (endpoint: IEndpoint, ctx: Koa.Context) => new Promise((res) => {
|
||||
export default (endpoint: IEndpoint, ctx: Koa.Context) => new Promise<void>((res) => {
|
||||
const body = ctx.request.body;
|
||||
|
||||
const reply = (x?: any, y?: ApiError) => {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import * as Koa from 'koa';
|
|||
import { performance } from 'perf_hooks';
|
||||
import { limiter } from './limiter';
|
||||
import { User } from '@/models/entities/user';
|
||||
import endpoints from './endpoints';
|
||||
import endpoints, { IEndpoint } from './endpoints';
|
||||
import { ApiError } from './error';
|
||||
import { apiLogger } from './logger';
|
||||
import { AccessToken } from '@/models/entities/access-token';
|
||||
|
|
@ -67,7 +67,7 @@ export default async (endpoint: string, user: User | null | undefined, token: Ac
|
|||
|
||||
if (ep.meta.requireCredential && ep.meta.limit && !user!.isAdmin && !user!.isModerator) {
|
||||
// Rate limit
|
||||
await limiter(ep, user!).catch(e => {
|
||||
await limiter(ep as IEndpoint & { meta: { limit: NonNullable<IEndpoint['meta']['limit']> } }, user!).catch(e => {
|
||||
throw new ApiError({
|
||||
message: 'Rate limit exceeded. Please try again later.',
|
||||
code: 'RATE_LIMIT_EXCEEDED',
|
||||
|
|
@ -78,12 +78,22 @@ export default async (endpoint: string, user: User | null | undefined, token: Ac
|
|||
}
|
||||
|
||||
// Cast non JSON input
|
||||
if (ep.meta.requireFile && ep.meta.params) {
|
||||
const body = (ctx!.request as any).body;
|
||||
for (const k of Object.keys(ep.meta.params)) {
|
||||
const param = ep.meta.params[k];
|
||||
if (['Boolean', 'Number'].includes(param.validator.name) && typeof body[k] === 'string') {
|
||||
body[k] = JSON.parse(body[k]);
|
||||
if (ep.meta.requireFile) {
|
||||
for (const k of Object.keys(ep.params)) {
|
||||
const param = ep.params.properties![k];
|
||||
if (['boolean', 'number', 'integer'].includes(param.type ?? '') && typeof data[k] === 'string') {
|
||||
try {
|
||||
data[k] = JSON.parse(data[k]);
|
||||
} catch (e) {
|
||||
throw new ApiError({
|
||||
message: 'Invalid param.',
|
||||
code: 'INVALID_PARAM',
|
||||
id: '0b5f1631-7c1a-41a6-b399-cce335f34d85',
|
||||
}, {
|
||||
param: k,
|
||||
reason: `cannot cast to ${param.type}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { User } from '@/models/entities/user';
|
||||
import { Brackets, SelectQueryBuilder } from 'typeorm';
|
||||
|
||||
export function generateRepliesQuery(q: SelectQueryBuilder<any>, me?: { id: User['id'] } | null) {
|
||||
export function generateRepliesQuery(q: SelectQueryBuilder<any>, me?: Pick<User, 'id' | 'showTimelineReplies'> | null) {
|
||||
if (me == null) {
|
||||
q.andWhere(new Brackets(qb => { qb
|
||||
.where(`note.replyId IS NULL`) // 返信ではない
|
||||
|
|
@ -10,7 +10,7 @@ export function generateRepliesQuery(q: SelectQueryBuilder<any>, me?: { id: User
|
|||
.andWhere('note.replyUserId = note.userId');
|
||||
}));
|
||||
}));
|
||||
} else {
|
||||
} else if (!me.showTimelineReplies) {
|
||||
q.andWhere(new Brackets(qb => { qb
|
||||
.where(`note.replyId IS NULL`) // 返信ではない
|
||||
.orWhere('note.replyUserId = :meId', { meId: me.id }) // 返信だけど自分のノートへの返信
|
||||
|
|
|
|||
|
|
@ -21,13 +21,13 @@ export async function signup(opts: {
|
|||
let hash = passwordHash;
|
||||
|
||||
// Validate username
|
||||
if (!Users.validateLocalUsername.ok(username)) {
|
||||
if (!Users.validateLocalUsername(username)) {
|
||||
throw new Error('INVALID_USERNAME');
|
||||
}
|
||||
|
||||
if (password != null && passwordHash == null) {
|
||||
// Validate password
|
||||
if (!Users.validatePassword.ok(password)) {
|
||||
if (!Users.validatePassword(password)) {
|
||||
throw new Error('INVALID_PASSWORD');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
import * as fs from 'fs';
|
||||
import * as Ajv from 'ajv';
|
||||
import { ILocalUser } from '@/models/entities/user';
|
||||
import { IEndpointMeta } from './endpoints';
|
||||
import { ApiError } from './error';
|
||||
import { SchemaType } from '@/misc/schema';
|
||||
import { Schema, SchemaType } from '@/misc/schema';
|
||||
import { AccessToken } from '@/models/entities/access-token';
|
||||
|
||||
type NonOptional<T> = T extends undefined ? never : T;
|
||||
|
||||
type SimpleUserInfo = {
|
||||
id: ILocalUser['id'];
|
||||
createdAt: ILocalUser['createdAt'];
|
||||
host: ILocalUser['host'];
|
||||
username: ILocalUser['username'];
|
||||
uri: ILocalUser['uri'];
|
||||
|
|
@ -17,24 +17,27 @@ type SimpleUserInfo = {
|
|||
isAdmin: ILocalUser['isAdmin'];
|
||||
isModerator: ILocalUser['isModerator'];
|
||||
isSilenced: ILocalUser['isSilenced'];
|
||||
};
|
||||
|
||||
type Params<T extends IEndpointMeta> = {
|
||||
[P in keyof T['params']]: NonNullable<T['params']>[P]['transform'] extends () => any
|
||||
? ReturnType<NonNullable<T['params']>[P]['transform']>
|
||||
: NonNullable<T['params']>[P]['default'] extends null | number | string
|
||||
? NonOptional<ReturnType<NonNullable<T['params']>[P]['validator']['get']>[0]>
|
||||
: ReturnType<NonNullable<T['params']>[P]['validator']['get']>[0];
|
||||
showTimelineReplies: ILocalUser['showTimelineReplies'];
|
||||
};
|
||||
|
||||
export type Response = Record<string, any> | void;
|
||||
|
||||
type executor<T extends IEndpointMeta> =
|
||||
(params: Params<T>, user: T['requireCredential'] extends true ? SimpleUserInfo : SimpleUserInfo | null, token: AccessToken | null, file?: any, cleanup?: () => any) =>
|
||||
// TODO: paramsの型をT['params']のスキーマ定義から推論する
|
||||
type executor<T extends IEndpointMeta, Ps extends Schema> =
|
||||
(params: SchemaType<Ps>, user: T['requireCredential'] extends true ? SimpleUserInfo : SimpleUserInfo | null, token: AccessToken | null, file?: any, cleanup?: () => any) =>
|
||||
Promise<T['res'] extends undefined ? Response : SchemaType<NonNullable<T['res']>>>;
|
||||
|
||||
export default function <T extends IEndpointMeta>(meta: T, cb: executor<T>)
|
||||
const ajv = new Ajv({
|
||||
useDefaults: true,
|
||||
});
|
||||
|
||||
ajv.addFormat('misskey:id', /^[a-z0-9]+$/);
|
||||
|
||||
export default function <T extends IEndpointMeta, Ps extends Schema>(meta: T, paramDef: Ps, cb: executor<T, Ps>)
|
||||
: (params: any, user: T['requireCredential'] extends true ? SimpleUserInfo : SimpleUserInfo | null, token: AccessToken | null, file?: any) => Promise<any> {
|
||||
|
||||
const validate = ajv.compile(paramDef);
|
||||
|
||||
return (params: any, user: T['requireCredential'] extends true ? SimpleUserInfo : SimpleUserInfo | null, token: AccessToken | null, file?: any) => {
|
||||
function cleanup() {
|
||||
fs.unlink(file.path, () => {});
|
||||
|
|
@ -46,42 +49,22 @@ export default function <T extends IEndpointMeta>(meta: T, cb: executor<T>)
|
|||
id: '4267801e-70d1-416a-b011-4ee502885d8b',
|
||||
}));
|
||||
|
||||
const [ps, pserr] = getParams(meta, params);
|
||||
if (pserr) {
|
||||
const valid = validate(params);
|
||||
if (!valid) {
|
||||
if (file) cleanup();
|
||||
return Promise.reject(pserr);
|
||||
}
|
||||
|
||||
return cb(ps, user, token, file, cleanup);
|
||||
};
|
||||
}
|
||||
|
||||
function getParams<T extends IEndpointMeta>(defs: T, params: any): [Params<T>, ApiError | null] {
|
||||
if (defs.params == null) return [params, null];
|
||||
|
||||
const x: any = {};
|
||||
let err: ApiError | null = null;
|
||||
Object.entries(defs.params).some(([k, def]) => {
|
||||
const [v, e] = def.validator.get(params[k]);
|
||||
if (e) {
|
||||
err = new ApiError({
|
||||
const errors = validate.errors!;
|
||||
const err = new ApiError({
|
||||
message: 'Invalid param.',
|
||||
code: 'INVALID_PARAM',
|
||||
id: '3d81ceae-475f-4600-b2a8-2bc116157532',
|
||||
}, {
|
||||
param: k,
|
||||
reason: e.message,
|
||||
param: errors[0].schemaPath,
|
||||
reason: errors[0].message,
|
||||
});
|
||||
return true;
|
||||
} else {
|
||||
if (v === undefined && Object.prototype.hasOwnProperty.call(def, 'default')) {
|
||||
x[k] = def.default;
|
||||
} else {
|
||||
x[k] = v;
|
||||
}
|
||||
if (def.transform) x[k] = def.transform(x[k]);
|
||||
return false;
|
||||
return Promise.reject(err);
|
||||
}
|
||||
});
|
||||
return [x, err];
|
||||
|
||||
return cb(params, user, token, file, cleanup);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import { fileURLToPath } from 'url';
|
||||
import { dirname } from 'path';
|
||||
import { Context } from 'cafy';
|
||||
import * as path from 'path';
|
||||
import * as glob from 'glob';
|
||||
import { Schema } from '@/misc/schema';
|
||||
|
|
@ -9,23 +7,11 @@ import { Schema } from '@/misc/schema';
|
|||
const _filename = __filename;
|
||||
const _dirname = dirname(_filename);
|
||||
|
||||
export type Param = {
|
||||
validator: Context<any>;
|
||||
transform?: any;
|
||||
default?: any;
|
||||
deprecated?: boolean;
|
||||
ref?: string;
|
||||
};
|
||||
|
||||
export interface IEndpointMeta {
|
||||
readonly stability?: 'deprecated' | 'experimental' | 'stable';
|
||||
|
||||
readonly tags?: ReadonlyArray<string>;
|
||||
|
||||
readonly params?: {
|
||||
readonly [key: string]: Param;
|
||||
};
|
||||
|
||||
readonly errors?: {
|
||||
readonly [key: string]: {
|
||||
readonly message: string;
|
||||
|
|
@ -99,12 +85,15 @@ export interface IEndpointMeta {
|
|||
* パーミッションの実現に利用されます。
|
||||
*/
|
||||
readonly kind?: string;
|
||||
|
||||
readonly description?: string;
|
||||
}
|
||||
|
||||
export interface IEndpoint {
|
||||
name: string;
|
||||
exec: any;
|
||||
meta: IEndpointMeta;
|
||||
params: Schema;
|
||||
}
|
||||
|
||||
const files = glob.sync('**/*.js', {
|
||||
|
|
@ -118,6 +107,7 @@ const endpoints: IEndpoint[] = files.map(f => {
|
|||
name: f.replace('.js', ''),
|
||||
exec: ep.default,
|
||||
meta: ep.meta || {},
|
||||
params: ep.paramDef,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { AbuseUserReports } from '@/models/index';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query';
|
||||
|
|
@ -10,49 +8,6 @@ export const meta = {
|
|||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
limit: {
|
||||
validator: $.optional.num.range(1, 100),
|
||||
default: 10,
|
||||
},
|
||||
|
||||
sinceId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
untilId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
state: {
|
||||
validator: $.optional.nullable.str,
|
||||
default: null,
|
||||
},
|
||||
|
||||
reporterOrigin: {
|
||||
validator: $.optional.str.or([
|
||||
'combined',
|
||||
'local',
|
||||
'remote',
|
||||
]),
|
||||
default: 'combined',
|
||||
},
|
||||
|
||||
targetUserOrigin: {
|
||||
validator: $.optional.str.or([
|
||||
'combined',
|
||||
'local',
|
||||
'remote',
|
||||
]),
|
||||
default: 'combined',
|
||||
},
|
||||
|
||||
forwarded: {
|
||||
validator: $.optional.bool,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
|
|
@ -115,8 +70,22 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
state: { type: 'string', nullable: true, default: null },
|
||||
reporterOrigin: { type: 'string', enum: ['combined', 'local', 'remote'], default: "combined" },
|
||||
targetUserOrigin: { type: 'string', enum: ['combined', 'local', 'remote'], default: "combined" },
|
||||
forwarded: { type: 'boolean', default: false },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps) => {
|
||||
export default define(meta, paramDef, async (ps) => {
|
||||
const query = makePaginationQuery(AbuseUserReports.createQueryBuilder('report'), ps.sinceId, ps.untilId);
|
||||
|
||||
switch (ps.state) {
|
||||
|
|
@ -134,7 +103,7 @@ export default define(meta, async (ps) => {
|
|||
case 'remote': query.andWhere('report.targetUserHost IS NOT NULL'); break;
|
||||
}
|
||||
|
||||
const reports = await query.take(ps.limit!).getMany();
|
||||
const reports = await query.take(ps.limit).getMany();
|
||||
|
||||
return await AbuseUserReports.packMany(reports);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,16 +5,6 @@ import { signup } from '../../../common/signup';
|
|||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
||||
params: {
|
||||
username: {
|
||||
validator: Users.validateLocalUsername,
|
||||
},
|
||||
|
||||
password: {
|
||||
validator: Users.validatePassword,
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
|
|
@ -28,8 +18,17 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
username: Users.localUsernameSchema,
|
||||
password: Users.passwordSchema,
|
||||
},
|
||||
required: ['username', 'password'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, _me) => {
|
||||
export default define(meta, paramDef, async (ps, _me) => {
|
||||
const me = _me ? await Users.findOneOrFail(_me.id) : null;
|
||||
const noUsers = (await Users.count({
|
||||
host: null,
|
||||
|
|
|
|||
|
|
@ -1,26 +1,26 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { Users } from '@/models/index';
|
||||
import { doPostSuspend } from '@/services/suspend-user';
|
||||
import { publishUserEvent } from '@/services/stream';
|
||||
import { createDeleteAccountJob } from '@/queue';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
||||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
} as const;
|
||||
|
||||
params: {
|
||||
userId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
userId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['userId'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const user = await Users.findOne(ps.userId);
|
||||
|
||||
if (user == null) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { Ads } from '@/models/index';
|
||||
import { genId } from '@/misc/gen-id';
|
||||
|
|
@ -8,34 +7,24 @@ export const meta = {
|
|||
|
||||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
} as const;
|
||||
|
||||
params: {
|
||||
url: {
|
||||
validator: $.str.min(1),
|
||||
},
|
||||
memo: {
|
||||
validator: $.str,
|
||||
},
|
||||
place: {
|
||||
validator: $.str,
|
||||
},
|
||||
priority: {
|
||||
validator: $.str,
|
||||
},
|
||||
ratio: {
|
||||
validator: $.num.int().min(0),
|
||||
},
|
||||
expiresAt: {
|
||||
validator: $.num.int(),
|
||||
},
|
||||
imageUrl: {
|
||||
validator: $.str.min(1),
|
||||
},
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
url: { type: 'string', minLength: 1 },
|
||||
memo: { type: 'string' },
|
||||
place: { type: 'string' },
|
||||
priority: { type: 'string' },
|
||||
ratio: { type: 'integer' },
|
||||
expiresAt: { type: 'integer' },
|
||||
imageUrl: { type: 'string', minLength: 1 },
|
||||
},
|
||||
required: ['url', 'memo', 'place', 'priority', 'ratio', 'expiresAt', 'imageUrl'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps) => {
|
||||
export default define(meta, paramDef, async (ps) => {
|
||||
await Ads.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import { Ads } from '@/models/index';
|
||||
import { ApiError } from '../../../error';
|
||||
|
||||
|
|
@ -10,12 +8,6 @@ export const meta = {
|
|||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
id: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchAd: {
|
||||
message: 'No such ad.',
|
||||
|
|
@ -25,8 +17,16 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['id'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const ad = await Ads.findOne(ps.id);
|
||||
|
||||
if (ad == null) throw new ApiError(meta.errors.noSuchAd);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../../define';
|
||||
import { Ads } from '@/models/index';
|
||||
import { makePaginationQuery } from '../../../common/make-pagination-query';
|
||||
|
|
@ -9,29 +7,24 @@ export const meta = {
|
|||
|
||||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
} as const;
|
||||
|
||||
params: {
|
||||
limit: {
|
||||
validator: $.optional.num.range(1, 100),
|
||||
default: 10,
|
||||
},
|
||||
|
||||
sinceId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
untilId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps) => {
|
||||
export default define(meta, paramDef, async (ps) => {
|
||||
const query = makePaginationQuery(Ads.createQueryBuilder('ad'), ps.sinceId, ps.untilId)
|
||||
.andWhere('ad.expiresAt > :now', { now: new Date() });
|
||||
|
||||
const ads = await query.take(ps.limit!).getMany();
|
||||
const ads = await query.take(ps.limit).getMany();
|
||||
|
||||
return ads;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import { Ads } from '@/models/index';
|
||||
import { ApiError } from '../../../error';
|
||||
|
||||
|
|
@ -10,33 +8,6 @@ export const meta = {
|
|||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
id: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
memo: {
|
||||
validator: $.str,
|
||||
},
|
||||
url: {
|
||||
validator: $.str.min(1),
|
||||
},
|
||||
imageUrl: {
|
||||
validator: $.str.min(1),
|
||||
},
|
||||
place: {
|
||||
validator: $.str,
|
||||
},
|
||||
priority: {
|
||||
validator: $.str,
|
||||
},
|
||||
ratio: {
|
||||
validator: $.num.int().min(0),
|
||||
},
|
||||
expiresAt: {
|
||||
validator: $.num.int(),
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchAd: {
|
||||
message: 'No such ad.',
|
||||
|
|
@ -46,8 +17,23 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { type: 'string', format: 'misskey:id' },
|
||||
memo: { type: 'string' },
|
||||
url: { type: 'string', minLength: 1 },
|
||||
imageUrl: { type: 'string', minLength: 1 },
|
||||
place: { type: 'string' },
|
||||
priority: { type: 'string' },
|
||||
ratio: { type: 'integer' },
|
||||
expiresAt: { type: 'integer' },
|
||||
},
|
||||
required: ['id', 'memo', 'url', 'imageUrl', 'place', 'priority', 'ratio', 'expiresAt'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const ad = await Ads.findOne(ps.id);
|
||||
|
||||
if (ad == null) throw new ApiError(meta.errors.noSuchAd);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { Announcements } from '@/models/index';
|
||||
import { genId } from '@/misc/gen-id';
|
||||
|
|
@ -9,18 +8,6 @@ export const meta = {
|
|||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
title: {
|
||||
validator: $.str.min(1),
|
||||
},
|
||||
text: {
|
||||
validator: $.str.min(1),
|
||||
},
|
||||
imageUrl: {
|
||||
validator: $.nullable.str.min(1),
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
|
|
@ -57,8 +44,18 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
title: { type: 'string', minLength: 1 },
|
||||
text: { type: 'string', minLength: 1 },
|
||||
imageUrl: { type: 'string', nullable: true, minLength: 1 },
|
||||
},
|
||||
required: ['title', 'text', 'imageUrl'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps) => {
|
||||
export default define(meta, paramDef, async (ps) => {
|
||||
const announcement = await Announcements.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import { Announcements } from '@/models/index';
|
||||
import { ApiError } from '../../../error';
|
||||
|
||||
|
|
@ -10,12 +8,6 @@ export const meta = {
|
|||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
id: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchAnnouncement: {
|
||||
message: 'No such announcement.',
|
||||
|
|
@ -25,8 +17,16 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['id'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const announcement = await Announcements.findOne(ps.id);
|
||||
|
||||
if (announcement == null) throw new ApiError(meta.errors.noSuchAnnouncement);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../../define';
|
||||
import { Announcements, AnnouncementReads } from '@/models/index';
|
||||
import { makePaginationQuery } from '../../../common/make-pagination-query';
|
||||
|
|
@ -10,21 +8,6 @@ export const meta = {
|
|||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
limit: {
|
||||
validator: $.optional.num.range(1, 100),
|
||||
default: 10,
|
||||
},
|
||||
|
||||
sinceId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
untilId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
|
|
@ -69,11 +52,21 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps) => {
|
||||
export default define(meta, paramDef, async (ps) => {
|
||||
const query = makePaginationQuery(Announcements.createQueryBuilder('announcement'), ps.sinceId, ps.untilId);
|
||||
|
||||
const announcements = await query.take(ps.limit!).getMany();
|
||||
const announcements = await query.take(ps.limit).getMany();
|
||||
|
||||
for (const announcement of announcements) {
|
||||
(announcement as any).reads = await AnnouncementReads.count({
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import { Announcements } from '@/models/index';
|
||||
import { ApiError } from '../../../error';
|
||||
|
||||
|
|
@ -10,21 +8,6 @@ export const meta = {
|
|||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
id: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
title: {
|
||||
validator: $.str.min(1),
|
||||
},
|
||||
text: {
|
||||
validator: $.str.min(1),
|
||||
},
|
||||
imageUrl: {
|
||||
validator: $.nullable.str.min(1),
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchAnnouncement: {
|
||||
message: 'No such announcement.',
|
||||
|
|
@ -34,8 +17,19 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { type: 'string', format: 'misskey:id' },
|
||||
title: { type: 'string', minLength: 1 },
|
||||
text: { type: 'string', minLength: 1 },
|
||||
imageUrl: { type: 'string', nullable: true, minLength: 1 },
|
||||
},
|
||||
required: ['id', 'title', 'text', 'imageUrl'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const announcement = await Announcements.findOne(ps.id);
|
||||
|
||||
if (announcement == null) throw new ApiError(meta.errors.noSuchAnnouncement);
|
||||
|
|
|
|||
|
|
@ -1,24 +1,24 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../define';
|
||||
import { deleteFile } from '@/services/drive/delete-file';
|
||||
import { DriveFiles } from '@/models/index';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
||||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
} as const;
|
||||
|
||||
params: {
|
||||
userId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
userId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['userId'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const files = await DriveFiles.find({
|
||||
userId: ps.userId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,7 +8,13 @@ export const meta = {
|
|||
requireModerator: true,
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
createCleanRemoteFilesJob();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,8 +10,14 @@ export const meta = {
|
|||
requireModerator: true,
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const files = await DriveFiles.find({
|
||||
userId: IsNull(),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { DriveFiles } from '@/models/index';
|
||||
import { makePaginationQuery } from '../../../common/make-pagination-query';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
|
@ -10,39 +8,6 @@ export const meta = {
|
|||
requireCredential: false,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
limit: {
|
||||
validator: $.optional.num.range(1, 100),
|
||||
default: 10,
|
||||
},
|
||||
|
||||
sinceId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
untilId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
type: {
|
||||
validator: $.optional.nullable.str.match(/^[a-zA-Z0-9\/\-*]+$/),
|
||||
},
|
||||
|
||||
origin: {
|
||||
validator: $.optional.str.or([
|
||||
'combined',
|
||||
'local',
|
||||
'remote',
|
||||
]),
|
||||
default: 'local',
|
||||
},
|
||||
|
||||
hostname: {
|
||||
validator: $.optional.nullable.str,
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
|
|
@ -54,8 +19,21 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
type: { type: 'string', nullable: true, pattern: /^[a-zA-Z0-9\/\-*]+$/.toString().slice(1, -1) },
|
||||
origin: { type: 'string', enum: ['combined', 'local', 'remote'], default: "local" },
|
||||
hostname: { type: 'string', nullable: true, default: null },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const query = makePaginationQuery(DriveFiles.createQueryBuilder('file'), ps.sinceId, ps.untilId);
|
||||
|
||||
if (ps.origin === 'local') {
|
||||
|
|
@ -76,7 +54,7 @@ export default define(meta, async (ps, me) => {
|
|||
}
|
||||
}
|
||||
|
||||
const files = await query.take(ps.limit!).getMany();
|
||||
const files = await query.take(ps.limit).getMany();
|
||||
|
||||
return await DriveFiles.packMany(files, { detail: true, withUser: true, self: true });
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../../define';
|
||||
import { ApiError } from '../../../error';
|
||||
import { DriveFiles } from '@/models/index';
|
||||
|
|
@ -10,16 +8,6 @@ export const meta = {
|
|||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
fileId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
url: {
|
||||
validator: $.optional.str,
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchFile: {
|
||||
message: 'No such file.',
|
||||
|
|
@ -161,8 +149,17 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
fileId: { type: 'string', format: 'misskey:id' },
|
||||
url: { type: 'string' },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const file = ps.fileId ? await DriveFiles.findOne(ps.fileId) : await DriveFiles.findOne({
|
||||
where: [{
|
||||
url: ps.url,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import { Emojis } from '@/models/index';
|
||||
import { getConnection, In } from 'typeorm';
|
||||
import { ApiError } from '../../../error';
|
||||
|
|
@ -10,20 +8,23 @@ export const meta = {
|
|||
|
||||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
} as const;
|
||||
|
||||
params: {
|
||||
ids: {
|
||||
validator: $.arr($.type(ID)),
|
||||
},
|
||||
|
||||
aliases: {
|
||||
validator: $.arr($.str),
|
||||
},
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
ids: { type: 'array', items: {
|
||||
type: 'string', format: 'misskey:id',
|
||||
} },
|
||||
aliases: { type: 'array', items: {
|
||||
type: 'string',
|
||||
} },
|
||||
},
|
||||
required: ['ids', 'aliases'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps) => {
|
||||
export default define(meta, paramDef, async (ps) => {
|
||||
const emojis = await Emojis.find({
|
||||
id: In(ps.ids),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { Emojis, DriveFiles } from '@/models/index';
|
||||
import { genId } from '@/misc/gen-id';
|
||||
import { getConnection } from 'typeorm';
|
||||
import { insertModerationLog } from '@/services/insert-moderation-log';
|
||||
import { ApiError } from '../../../error';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import rndstr from 'rndstr';
|
||||
import { publishBroadcastStream } from '@/services/stream';
|
||||
|
||||
|
|
@ -15,12 +13,6 @@ export const meta = {
|
|||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
fileId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchFile: {
|
||||
message: 'No such file.',
|
||||
|
|
@ -30,8 +22,16 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
fileId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['fileId'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const file = await DriveFiles.findOne(ps.fileId);
|
||||
|
||||
if (file == null) throw new ApiError(meta.errors.noSuchFile);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { Emojis } from '@/models/index';
|
||||
import { genId } from '@/misc/gen-id';
|
||||
import { getConnection } from 'typeorm';
|
||||
import { ApiError } from '../../../error';
|
||||
import { DriveFile } from '@/models/entities/drive-file';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import { uploadFromUrl } from '@/services/drive/upload-from-url';
|
||||
import { publishBroadcastStream } from '@/services/stream';
|
||||
|
||||
|
|
@ -15,12 +13,6 @@ export const meta = {
|
|||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
emojiId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchEmoji: {
|
||||
message: 'No such emoji.',
|
||||
|
|
@ -42,8 +34,16 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
emojiId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['emojiId'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const emoji = await Emojis.findOne(ps.emojiId);
|
||||
|
||||
if (emoji == null) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import { Emojis } from '@/models/index';
|
||||
import { getConnection, In } from 'typeorm';
|
||||
import { insertModerationLog } from '@/services/insert-moderation-log';
|
||||
|
|
@ -11,16 +9,20 @@ export const meta = {
|
|||
|
||||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
} as const;
|
||||
|
||||
params: {
|
||||
ids: {
|
||||
validator: $.arr($.type(ID)),
|
||||
},
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
ids: { type: 'array', items: {
|
||||
type: 'string', format: 'misskey:id',
|
||||
} },
|
||||
},
|
||||
required: ['ids'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const emojis = await Emojis.find({
|
||||
id: In(ps.ids),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import { Emojis } from '@/models/index';
|
||||
import { getConnection } from 'typeorm';
|
||||
import { insertModerationLog } from '@/services/insert-moderation-log';
|
||||
|
|
@ -12,12 +10,6 @@ export const meta = {
|
|||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
id: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchEmoji: {
|
||||
message: 'No such emoji.',
|
||||
|
|
@ -27,8 +19,16 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['id'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const emoji = await Emojis.findOne(ps.id);
|
||||
|
||||
if (emoji == null) throw new ApiError(meta.errors.noSuchEmoji);
|
||||
|
|
|
|||
|
|
@ -1,21 +1,22 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { createImportCustomEmojisJob } from '@/queue/index';
|
||||
import ms from 'ms';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
|
||||
export const meta = {
|
||||
secure: true,
|
||||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
params: {
|
||||
fileId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
fileId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['fileId'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, user) => {
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
createImportCustomEmojisJob(user, ps.fileId);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { Emojis } from '@/models/index';
|
||||
import { toPuny } from '@/misc/convert-host';
|
||||
import { makePaginationQuery } from '../../../common/make-pagination-query';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
|
@ -11,31 +9,6 @@ export const meta = {
|
|||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
query: {
|
||||
validator: $.optional.nullable.str,
|
||||
default: null,
|
||||
},
|
||||
|
||||
host: {
|
||||
validator: $.optional.nullable.str,
|
||||
default: null,
|
||||
},
|
||||
|
||||
limit: {
|
||||
validator: $.optional.num.range(1, 100),
|
||||
default: 10,
|
||||
},
|
||||
|
||||
sinceId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
untilId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
|
|
@ -77,8 +50,20 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
query: { type: 'string', nullable: true, default: null },
|
||||
host: { type: 'string', nullable: true, default: null },
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps) => {
|
||||
export default define(meta, paramDef, async (ps) => {
|
||||
const q = makePaginationQuery(Emojis.createQueryBuilder('emoji'), ps.sinceId, ps.untilId);
|
||||
|
||||
if (ps.host == null) {
|
||||
|
|
@ -93,7 +78,7 @@ export default define(meta, async (ps) => {
|
|||
|
||||
const emojis = await q
|
||||
.orderBy('emoji.id', 'DESC')
|
||||
.take(ps.limit!)
|
||||
.take(ps.limit)
|
||||
.getMany();
|
||||
|
||||
return Emojis.packMany(emojis);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { Emojis } from '@/models/index';
|
||||
import { makePaginationQuery } from '../../../common/make-pagination-query';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import { Emoji } from '@/models/entities/emoji';
|
||||
|
||||
export const meta = {
|
||||
|
|
@ -11,26 +9,6 @@ export const meta = {
|
|||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
query: {
|
||||
validator: $.optional.nullable.str,
|
||||
default: null,
|
||||
},
|
||||
|
||||
limit: {
|
||||
validator: $.optional.num.range(1, 100),
|
||||
default: 10,
|
||||
},
|
||||
|
||||
sinceId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
untilId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
|
|
@ -72,8 +50,19 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
query: { type: 'string', nullable: true, default: null },
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps) => {
|
||||
export default define(meta, paramDef, async (ps) => {
|
||||
const q = makePaginationQuery(Emojis.createQueryBuilder('emoji'), ps.sinceId, ps.untilId)
|
||||
.andWhere(`emoji.host IS NULL`);
|
||||
|
||||
|
|
@ -81,7 +70,7 @@ export default define(meta, async (ps) => {
|
|||
|
||||
if (ps.query) {
|
||||
//q.andWhere('emoji.name ILIKE :q', { q: `%${ps.query}%` });
|
||||
//const emojis = await q.take(ps.limit!).getMany();
|
||||
//const emojis = await q.take(ps.limit).getMany();
|
||||
|
||||
emojis = await q.getMany();
|
||||
|
||||
|
|
@ -90,9 +79,9 @@ export default define(meta, async (ps) => {
|
|||
emoji.aliases.some(a => a.includes(ps.query!)) ||
|
||||
emoji.category?.includes(ps.query!));
|
||||
|
||||
emojis.splice(ps.limit! + 1);
|
||||
emojis.splice(ps.limit + 1);
|
||||
} else {
|
||||
emojis = await q.take(ps.limit!).getMany();
|
||||
emojis = await q.take(ps.limit).getMany();
|
||||
}
|
||||
|
||||
return Emojis.packMany(emojis);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import { Emojis } from '@/models/index';
|
||||
import { getConnection, In } from 'typeorm';
|
||||
import { ApiError } from '../../../error';
|
||||
|
|
@ -10,20 +8,23 @@ export const meta = {
|
|||
|
||||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
} as const;
|
||||
|
||||
params: {
|
||||
ids: {
|
||||
validator: $.arr($.type(ID)),
|
||||
},
|
||||
|
||||
aliases: {
|
||||
validator: $.arr($.str),
|
||||
},
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
ids: { type: 'array', items: {
|
||||
type: 'string', format: 'misskey:id',
|
||||
} },
|
||||
aliases: { type: 'array', items: {
|
||||
type: 'string',
|
||||
} },
|
||||
},
|
||||
required: ['ids', 'aliases'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps) => {
|
||||
export default define(meta, paramDef, async (ps) => {
|
||||
const emojis = await Emojis.find({
|
||||
id: In(ps.ids),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import { Emojis } from '@/models/index';
|
||||
import { getConnection, In } from 'typeorm';
|
||||
import { ApiError } from '../../../error';
|
||||
|
|
@ -10,20 +8,23 @@ export const meta = {
|
|||
|
||||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
} as const;
|
||||
|
||||
params: {
|
||||
ids: {
|
||||
validator: $.arr($.type(ID)),
|
||||
},
|
||||
|
||||
aliases: {
|
||||
validator: $.arr($.str),
|
||||
},
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
ids: { type: 'array', items: {
|
||||
type: 'string', format: 'misskey:id',
|
||||
} },
|
||||
aliases: { type: 'array', items: {
|
||||
type: 'string',
|
||||
} },
|
||||
},
|
||||
required: ['ids', 'aliases'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps) => {
|
||||
export default define(meta, paramDef, async (ps) => {
|
||||
await Emojis.update({
|
||||
id: In(ps.ids),
|
||||
}, {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import { Emojis } from '@/models/index';
|
||||
import { getConnection, In } from 'typeorm';
|
||||
import { ApiError } from '../../../error';
|
||||
|
|
@ -10,20 +8,21 @@ export const meta = {
|
|||
|
||||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
} as const;
|
||||
|
||||
params: {
|
||||
ids: {
|
||||
validator: $.arr($.type(ID)),
|
||||
},
|
||||
|
||||
category: {
|
||||
validator: $.optional.nullable.str,
|
||||
},
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
ids: { type: 'array', items: {
|
||||
type: 'string', format: 'misskey:id',
|
||||
} },
|
||||
category: { type: 'string', nullable: true },
|
||||
},
|
||||
required: ['ids'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps) => {
|
||||
export default define(meta, paramDef, async (ps) => {
|
||||
await Emojis.update({
|
||||
id: In(ps.ids),
|
||||
}, {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import { Emojis } from '@/models/index';
|
||||
import { getConnection } from 'typeorm';
|
||||
import { ApiError } from '../../../error';
|
||||
|
|
@ -11,24 +9,6 @@ export const meta = {
|
|||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
id: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
|
||||
name: {
|
||||
validator: $.str,
|
||||
},
|
||||
|
||||
category: {
|
||||
validator: $.optional.nullable.str,
|
||||
},
|
||||
|
||||
aliases: {
|
||||
validator: $.arr($.str),
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchEmoji: {
|
||||
message: 'No such emoji.',
|
||||
|
|
@ -38,8 +18,21 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { type: 'string', format: 'misskey:id' },
|
||||
name: { type: 'string' },
|
||||
category: { type: 'string', nullable: true },
|
||||
aliases: { type: 'array', items: {
|
||||
type: 'string',
|
||||
} },
|
||||
},
|
||||
required: ['id', 'name', 'aliases'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps) => {
|
||||
export default define(meta, paramDef, async (ps) => {
|
||||
const emoji = await Emojis.findOne(ps.id);
|
||||
|
||||
if (emoji == null) throw new ApiError(meta.errors.noSuchEmoji);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { deleteFile } from '@/services/drive/delete-file';
|
||||
import { DriveFiles } from '@/models/index';
|
||||
|
|
@ -8,16 +7,18 @@ export const meta = {
|
|||
|
||||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
} as const;
|
||||
|
||||
params: {
|
||||
host: {
|
||||
validator: $.str,
|
||||
},
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
host: { type: 'string' },
|
||||
},
|
||||
required: ['host'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const files = await DriveFiles.find({
|
||||
userHost: ps.host,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { Instances } from '@/models/index';
|
||||
import { toPuny } from '@/misc/convert-host';
|
||||
|
|
@ -9,16 +8,18 @@ export const meta = {
|
|||
|
||||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
} as const;
|
||||
|
||||
params: {
|
||||
host: {
|
||||
validator: $.str,
|
||||
},
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
host: { type: 'string' },
|
||||
},
|
||||
required: ['host'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const instance = await Instances.findOne({ host: toPuny(ps.host) });
|
||||
|
||||
if (instance == null) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import deleteFollowing from '@/services/following/delete';
|
||||
import { Followings, Users } from '@/models/index';
|
||||
|
|
@ -8,16 +7,18 @@ export const meta = {
|
|||
|
||||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
} as const;
|
||||
|
||||
params: {
|
||||
host: {
|
||||
validator: $.str,
|
||||
},
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
host: { type: 'string' },
|
||||
},
|
||||
required: ['host'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const followings = await Followings.find({
|
||||
followerHost: ps.host,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { Instances } from '@/models/index';
|
||||
import { toPuny } from '@/misc/convert-host';
|
||||
|
|
@ -8,20 +7,19 @@ export const meta = {
|
|||
|
||||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
} as const;
|
||||
|
||||
params: {
|
||||
host: {
|
||||
validator: $.str,
|
||||
},
|
||||
|
||||
isSuspended: {
|
||||
validator: $.bool,
|
||||
},
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
host: { type: 'string' },
|
||||
isSuspended: { type: 'boolean' },
|
||||
},
|
||||
required: ['host', 'isSuspended'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const instance = await Instances.findOne({ host: toPuny(ps.host) });
|
||||
|
||||
if (instance == null) {
|
||||
|
|
|
|||
|
|
@ -6,13 +6,16 @@ export const meta = {
|
|||
requireModerator: true,
|
||||
|
||||
tags: ['admin'],
|
||||
} as const;
|
||||
|
||||
params: {
|
||||
},
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async () => {
|
||||
export default define(meta, paramDef, async () => {
|
||||
const stats = await
|
||||
getConnection().query(`SELECT * FROM pg_indexes;`)
|
||||
.then(recs => {
|
||||
|
|
|
|||
|
|
@ -7,9 +7,6 @@ export const meta = {
|
|||
|
||||
tags: ['admin'],
|
||||
|
||||
params: {
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
|
|
@ -22,8 +19,14 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async () => {
|
||||
export default define(meta, paramDef, async () => {
|
||||
const sizes = await
|
||||
getConnection().query(`
|
||||
SELECT relname AS "table", reltuples as "count", pg_total_relation_size(C.oid) AS "size"
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ export const meta = {
|
|||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
|
||||
params: {},
|
||||
|
||||
res: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
|
|
@ -26,8 +24,14 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async () => {
|
||||
export default define(meta, paramDef, async () => {
|
||||
const code = rndstr({
|
||||
length: 8,
|
||||
chars: '2-9A-HJ-NP-Z', // [0-9A-Z] w/o [01IO] (32 patterns)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../../define';
|
||||
import { Users } from '@/models/index';
|
||||
|
||||
|
|
@ -8,16 +6,18 @@ export const meta = {
|
|||
|
||||
requireCredential: true,
|
||||
requireAdmin: true,
|
||||
} as const;
|
||||
|
||||
params: {
|
||||
userId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
userId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['userId'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps) => {
|
||||
export default define(meta, paramDef, async (ps) => {
|
||||
const user = await Users.findOne(ps.userId as string);
|
||||
|
||||
if (user == null) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../../define';
|
||||
import { Users } from '@/models/index';
|
||||
|
||||
|
|
@ -8,16 +6,18 @@ export const meta = {
|
|||
|
||||
requireCredential: true,
|
||||
requireAdmin: true,
|
||||
} as const;
|
||||
|
||||
params: {
|
||||
userId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
userId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['userId'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps) => {
|
||||
export default define(meta, paramDef, async (ps) => {
|
||||
const user = await Users.findOne(ps.userId as string);
|
||||
|
||||
if (user == null) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../../define';
|
||||
import { ApiError } from '../../../error';
|
||||
import { getNote } from '../../../common/getters';
|
||||
|
|
@ -11,16 +9,6 @@ export const meta = {
|
|||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
|
||||
expiresAt: {
|
||||
validator: $.num.int(),
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchNote: {
|
||||
message: 'No such note.',
|
||||
|
|
@ -36,8 +24,17 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
expiresAt: { type: 'integer' },
|
||||
},
|
||||
required: ['noteId', 'expiresAt'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, user) => {
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const note = await getNote(ps.noteId).catch(e => {
|
||||
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
throw e;
|
||||
|
|
@ -51,7 +48,6 @@ export default define(meta, async (ps, user) => {
|
|||
|
||||
await PromoNotes.insert({
|
||||
noteId: note.id,
|
||||
createdAt: new Date(),
|
||||
expiresAt: new Date(ps.expiresAt),
|
||||
userId: note.userId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -7,12 +7,16 @@ export const meta = {
|
|||
|
||||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
} as const;
|
||||
|
||||
params: {},
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
destroy();
|
||||
|
||||
insertModerationLog(me, 'clearQueue');
|
||||
|
|
|
|||
|
|
@ -8,9 +8,6 @@ export const meta = {
|
|||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
|
|
@ -35,8 +32,14 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps) => {
|
||||
export default define(meta, paramDef, async (ps) => {
|
||||
const jobs = await deliverQueue.getJobs(['delayed']);
|
||||
|
||||
const res = [] as [string, number][];
|
||||
|
|
|
|||
|
|
@ -8,9 +8,6 @@ export const meta = {
|
|||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
|
|
@ -35,8 +32,14 @@ export const meta = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps) => {
|
||||
export default define(meta, paramDef, async (ps) => {
|
||||
const jobs = await inboxQueue.getJobs(['delayed']);
|
||||
|
||||
const res = [] as [string, number][];
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue