This commit is contained in:
DrSmoothl committed 2026-10-12 15:43:34 +08:00
1 parent effeb66554
commit 7c0519f75f
977 files changed
+198426 -158324

No files matched your search

@@ -1,6 +1,9 @@
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { SendPacketResult } from '@snowluma/common/packet-sender';
import type { QidianCorpInfoRequest, QidianCorpInfoResponse } from '@snowluma/proto-defs/qidian-corp';
import type {
QidianCorpInfoRequest,
QidianCorpInfoResponse,
} from '@snowluma/proto-defs/qidian-corp';
// 企点企业资料卡(trpc.basic.corp.Datacard.SsoCorpInfo)。
// 请求体为 protobuf field1 = 目标账号 UIN(varint)
@@ -8,17 +11,21 @@ import type { QidianCorpInfoRequest, QidianCorpInfoResponse } from '@snowluma/pr
export const QIDIAN_CORP_INFO_CMD = 'trpc.basic.corp.Datacard.SsoCorpInfo';
export interface QidianCorpInfo {
name: string;
intro: string;
website: string;
slogan: string;
address: string;
phone: string;
email: string;
name: string;
intro: string;
website: string;
slogan: string;
address: string;
phone: string;
email: string;
}
export interface RawSender {
sendRawPacket(serviceCmd: string, body: Uint8Array, timeoutMs?: number): Promise<SendPacketResult>;
sendRawPacket(
serviceCmd: string,
body: Uint8Array,
timeoutMs?: number,
): Promise<SendPacketResult>;
}
/**
@@ -28,25 +35,36 @@ export interface RawSender {
* whole profile read if this lookup throws / returns null.
*/
export async function fetchQidianCorpInfo(
sender: RawSender,
uin: number,
timeoutMs?: number,
sender: RawSender,
uin: number,
timeoutMs?: number,
): Promise<QidianCorpInfo | null> {
const req = protobuf_encode<QidianCorpInfoRequest>({ uin });
const result = await sender.sendRawPacket(QIDIAN_CORP_INFO_CMD, req, timeoutMs);
if (!result.success || !result.gotResponse || !result.responseData || result.responseData.length === 0) {
return null;
}
const decoded = protobuf_decode<QidianCorpInfoResponse>(result.responseData);
const name = decoded?.corpName ?? '';
if (!name) return null;
return {
name,
intro: decoded?.intro ?? '',
website: decoded?.website ?? '',
slogan: decoded?.slogan ?? '',
address: decoded?.address ?? '',
phone: decoded?.phone ?? '',
email: decoded?.email ?? '',
};
const req = protobuf_encode<QidianCorpInfoRequest>({ uin });
const result = await sender.sendRawPacket(QIDIAN_CORP_INFO_CMD, req, timeoutMs);
if (
!result.success ||
!result.gotResponse ||
!result.responseData ||
result.responseData.length === 0
) {
return null;
}
const decoded = protobuf_decode<QidianCorpInfoResponse>(result.responseData);
const name = decoded?.corpName ?? '';
if (!name) {
return null;
}
return {
name,
intro: decoded?.intro ?? '',
website: decoded?.website ?? '',
slogan: decoded?.slogan ?? '',
address: decoded?.address ?? '',
phone: decoded?.phone ?? '',
email: decoded?.email ?? '',
};
}