lint
This commit is contained in:
977 files changed
+198426
-158324
No files matched your search
@@ -11,79 +11,85 @@ import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { pb, pb_repeated, uint_32, uint_64 } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type {
|
||||
OidbDoubtGetReq, OidbDoubtGetResp,
|
||||
OidbDoubtGetReq,
|
||||
OidbDoubtGetResp,
|
||||
} from '@snowluma/proto-defs/oidb-actions/doubt-buddy';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
interface OidbDoubtItemAccountOnTag1 {
|
||||
uin?: pb<1, uint_64>;
|
||||
uin?: pb<1, uint_64>;
|
||||
}
|
||||
interface OidbDoubtGetRespAccountOnTag1Body {
|
||||
list?: pb_repeated<1, OidbDoubtItemAccountOnTag1>;
|
||||
list?: pb_repeated<1, OidbDoubtItemAccountOnTag1>;
|
||||
}
|
||||
interface OidbDoubtGetRespAccountOnTag1 {
|
||||
status?: pb<1, uint_32>;
|
||||
body?: pb<2, OidbDoubtGetRespAccountOnTag1Body>;
|
||||
status?: pb<1, uint_32>;
|
||||
body?: pb<2, OidbDoubtGetRespAccountOnTag1Body>;
|
||||
}
|
||||
type DecodedDoubtItem = NonNullable<NonNullable<OidbDoubtGetResp['body']>['list']>[number] & {
|
||||
uin?: bigint;
|
||||
uin?: bigint;
|
||||
};
|
||||
interface DecodedDoubtGetResp extends Omit<OidbDoubtGetResp, 'body'> {
|
||||
body?: Omit<NonNullable<OidbDoubtGetResp['body']>, 'list'> & { list?: DecodedDoubtItem[] };
|
||||
body?: Omit<NonNullable<OidbDoubtGetResp['body']>, 'list'> & { list?: DecodedDoubtItem[] };
|
||||
}
|
||||
|
||||
export interface DoubtBuddyRequest {
|
||||
[key: string]: import('@snowluma/common/json').JsonValue;
|
||||
/** Opaque uid — pass back as `flag` to set_doubt_friends_add_request. */
|
||||
uid: string;
|
||||
user_id: number;
|
||||
nick: string;
|
||||
source: string;
|
||||
reason: string;
|
||||
msg: string;
|
||||
group_code: string;
|
||||
reqTime: number;
|
||||
[key: string]: import('@snowluma/common/json').JsonValue;
|
||||
/** Opaque uid — pass back as `flag` to set_doubt_friends_add_request. */
|
||||
uid: string;
|
||||
user_id: number;
|
||||
nick: string;
|
||||
source: string;
|
||||
reason: string;
|
||||
msg: string;
|
||||
group_code: string;
|
||||
reqTime: number;
|
||||
}
|
||||
|
||||
export namespace GetDoubtBuddyReq {
|
||||
export const command = 0xD69;
|
||||
export const subCommand = 0;
|
||||
export const uinForm = true;
|
||||
export const command = 0xd69;
|
||||
export const subCommand = 0;
|
||||
export const uinForm = true;
|
||||
|
||||
export interface Params { count: number; cookie?: string }
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const serialize = (_ctx: Deps, p: Params): OidbDoubtGetReq => ({
|
||||
field1: 1,
|
||||
inner: { num: p.count, uk: p.cookie ?? '' },
|
||||
});
|
||||
|
||||
export const deserialize = (_ctx: Deps, body: DecodedDoubtGetResp): DoubtBuddyRequest[] =>
|
||||
(body.body?.list ?? []).map((it) => ({
|
||||
uid: it.uid ?? '',
|
||||
user_id: Number(it.uin ?? 0),
|
||||
nick: it.nick ?? '',
|
||||
source: it.source ?? '',
|
||||
reason: it.reason ?? '',
|
||||
msg: it.msg ?? '',
|
||||
group_code: it.groupCode ? String(it.groupCode) : '',
|
||||
reqTime: Number(it.reqTime ?? 0),
|
||||
}));
|
||||
|
||||
export const encode = (env: OidbBase<OidbDoubtGetReq>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbDoubtGetReq>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<DecodedDoubtGetResp> => {
|
||||
const decoded = protobuf_decode<OidbBase<OidbDoubtGetResp>>(bytes);
|
||||
const numeric = protobuf_decode<OidbBase<OidbDoubtGetRespAccountOnTag1>>(bytes);
|
||||
const items = decoded.body?.body?.list ?? [];
|
||||
const numericItems = numeric.body?.body?.list ?? [];
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
(items[i] as DecodedDoubtItem).uin = numericItems[i]?.uin;
|
||||
export interface Params {
|
||||
count: number;
|
||||
cookie?: string;
|
||||
}
|
||||
return decoded as OidbBase<DecodedDoubtGetResp>;
|
||||
};
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<DoubtBuddyRequest[]> =>
|
||||
invokeOidb(deps, GetDoubtBuddyReq, params);
|
||||
export const serialize = (_ctx: Deps, p: Params): OidbDoubtGetReq => ({
|
||||
field1: 1,
|
||||
inner: { num: p.count, uk: p.cookie ?? '' },
|
||||
});
|
||||
|
||||
export const deserialize = (_ctx: Deps, body: DecodedDoubtGetResp): DoubtBuddyRequest[] =>
|
||||
(body.body?.list ?? []).map((it) => ({
|
||||
uid: it.uid ?? '',
|
||||
user_id: Number(it.uin ?? 0),
|
||||
nick: it.nick ?? '',
|
||||
source: it.source ?? '',
|
||||
reason: it.reason ?? '',
|
||||
msg: it.msg ?? '',
|
||||
group_code: it.groupCode ? String(it.groupCode) : '',
|
||||
reqTime: Number(it.reqTime ?? 0),
|
||||
}));
|
||||
|
||||
export const encode = (env: OidbBase<OidbDoubtGetReq>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbDoubtGetReq>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<DecodedDoubtGetResp> => {
|
||||
const decoded = protobuf_decode<OidbBase<OidbDoubtGetResp>>(bytes);
|
||||
const numeric = protobuf_decode<OidbBase<OidbDoubtGetRespAccountOnTag1>>(bytes);
|
||||
const items = decoded.body?.body?.list ?? [];
|
||||
const numericItems = numeric.body?.body?.list ?? [];
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
(items[i] as DecodedDoubtItem).uin = numericItems[i]?.uin;
|
||||
}
|
||||
|
||||
return decoded as OidbBase<DecodedDoubtGetResp>;
|
||||
};
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<DoubtBuddyRequest[]> =>
|
||||
invokeOidb(deps, GetDoubtBuddyReq, params);
|
||||
}
|
||||
Reference in new issue
Block a user