refactor(api): move 6 group-album methods to GroupAlbumApi (#6 commit 5/13)
Inlines `actions/group-album.ts` (OIDB sendRawPacket via QunAlbum.trpc.*) and `web-actions/group-album.ts` (HTTP cookie-based) into `apis/group-album.ts::GroupAlbumApi`. Both action files deleted. Pure HTTP helpers in `web/group-album.ts` stay where they are — they're transport-layer code. Method renaming follows the now-standard "drop the redundant suffix" rule (the Api namespace already says `groupAlbum`): getGroupAlbumList → list (HTTP) uploadImageToGroupAlbum → upload (HTTP slice-upload) getGroupAlbumMediaList → getMediaList commentGroupAlbumMedia → comment likeGroupAlbumMedia → like deleteGroupAlbumMedia → delete Callers updated: `instance-context.ts`. `web-actions/index.ts` no longer re-exports the deleted album functions. No tests existed for this surface area, so no test churn. 587/587 tests pass.
This commit is contained in:
1 parent
dad501ebc0
commit
c92daa56df
8 files changed
+302
-358
No files matched your search
@@ -1,281 +0,0 @@
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { Bridge } from '../bridge';
|
||||
import type {
|
||||
DeleteMediasRequest,
|
||||
DeleteMediasResponse,
|
||||
DoQunCommentRequest,
|
||||
DoQunCommentResponse,
|
||||
DoQunLikeRequest,
|
||||
DoQunLikeResponse,
|
||||
GetMediaListRequest,
|
||||
GetMediaListResponse,
|
||||
} from '@snowluma/proto-defs/oidb-actions/group-album';
|
||||
|
||||
export interface GroupAlbumMediaResult {
|
||||
mediaList: any[];
|
||||
nextAttachInfo: string;
|
||||
}
|
||||
|
||||
export interface GroupAlbumCommentResult {
|
||||
id: string;
|
||||
user: { uin: string };
|
||||
content: Array<{ type: number; content: string }>;
|
||||
time: string;
|
||||
clientKey: string;
|
||||
}
|
||||
|
||||
function convertBigIntToString(obj: any): any {
|
||||
if (obj === null || obj === undefined) return obj;
|
||||
if (typeof obj === 'bigint') return obj.toString();
|
||||
if (Array.isArray(obj)) return obj.map(convertBigIntToString);
|
||||
if (typeof obj === 'object') {
|
||||
const result: any = {};
|
||||
for (const key in obj) {
|
||||
result[key] = convertBigIntToString(obj[key]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
export async function getGroupAlbumMediaList(
|
||||
bridge: Bridge,
|
||||
groupId: number,
|
||||
albumId: string,
|
||||
attachInfo: string = ''
|
||||
): Promise<GroupAlbumMediaResult> {
|
||||
const traceId = `_${Date.now()}_${Math.floor(Math.random() * 100000)}`;
|
||||
|
||||
const body = protobuf_encode<GetMediaListRequest>({
|
||||
field1: 0,
|
||||
field2: new Uint8Array(0),
|
||||
field3: new Uint8Array(0),
|
||||
reqInfo: {
|
||||
groupId: groupId.toString(),
|
||||
albumId: albumId,
|
||||
field3: 0,
|
||||
attachInfo: attachInfo,
|
||||
field5: '',
|
||||
},
|
||||
traceId: traceId,
|
||||
extMap: [{ key: 'fc-appid', value: '100' }],
|
||||
});
|
||||
|
||||
const result = await bridge.sendRawPacket(
|
||||
'QunAlbum.trpc.qzone.webapp_qun_media.QunMedia.GetMediaList',
|
||||
body,
|
||||
15000
|
||||
);
|
||||
|
||||
if (!result.success || !result.gotResponse || !result.responseData) {
|
||||
throw new Error(result.errorMessage || 'failed to get album media list');
|
||||
}
|
||||
|
||||
const resp = protobuf_decode<GetMediaListResponse>(result.responseData);
|
||||
|
||||
if (resp.field1 !== 0) {
|
||||
throw new Error(`fetch album media list error: retCode ${resp.field1 ?? 'unknown'}`);
|
||||
}
|
||||
|
||||
const data = resp.data ?? {};
|
||||
const mediaList = data.mediaList ?? [];
|
||||
const nextAttachInfo = data.nextAttachInfo ?? '';
|
||||
|
||||
return convertBigIntToString({
|
||||
mediaList,
|
||||
nextAttachInfo,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
export async function commentGroupAlbumMedia(
|
||||
bridge: Bridge,
|
||||
groupId: number,
|
||||
albumId: string,
|
||||
lloc: string,
|
||||
content: string
|
||||
): Promise<GroupAlbumCommentResult> {
|
||||
const traceId = `_${Date.now()}_${Math.floor(Math.random() * 100000)}`;
|
||||
const clientKey = Date.now().toString();
|
||||
const uin = bridge.identity.uin;
|
||||
|
||||
const body = protobuf_encode<DoQunCommentRequest>({
|
||||
field1: 8527,
|
||||
field2: new Uint8Array(0),
|
||||
field3: new Uint8Array(0),
|
||||
body: {
|
||||
groupId: groupId.toString(),
|
||||
field3: 2,
|
||||
reqBody: {
|
||||
field1: { field3: 0, field4: "" },
|
||||
field2: {
|
||||
field1: { uin }
|
||||
},
|
||||
field5: {
|
||||
field1: {
|
||||
field2: {
|
||||
field1: 0, field2: "",
|
||||
lloc,
|
||||
field4: "", field6: "", field7: 0, field8: 0, field9: 0, field14: 0, field15: 0, field17: 0
|
||||
}
|
||||
},
|
||||
albumId,
|
||||
field5: 0
|
||||
},
|
||||
},
|
||||
field5: {
|
||||
field2: { uin },
|
||||
field3: {
|
||||
field1: 0,
|
||||
field2: content,
|
||||
field3: "", field4: "", field5: 0, field6: ""
|
||||
},
|
||||
clientKey,
|
||||
}
|
||||
},
|
||||
traceId,
|
||||
extMap: [{ key: 'fc-appid', value: '100' }],
|
||||
});
|
||||
|
||||
const result = await bridge.sendRawPacket(
|
||||
'QunAlbum.trpc.qzone.webapp_qun_operation.FeedsWriter.DoQunComment',
|
||||
body,
|
||||
15000
|
||||
);
|
||||
|
||||
if (!result.success || !result.gotResponse || !result.responseData) {
|
||||
throw new Error(result.errorMessage || 'failed to comment on album media');
|
||||
}
|
||||
|
||||
const resp = protobuf_decode<DoQunCommentResponse>(result.responseData);
|
||||
|
||||
const resCode = resp.field1;
|
||||
if (resCode !== 0 && resCode !== 8527 && !resp.comment) {
|
||||
throw new Error(`comment album media error: retCode ${resCode ?? 'unknown'}`);
|
||||
}
|
||||
|
||||
const commentData = resp.comment?.data ?? {};
|
||||
|
||||
return convertBigIntToString({
|
||||
id: commentData.id ?? '',
|
||||
user: { uin: commentData.user?.uin ?? '' },
|
||||
content: commentData.content ?? [],
|
||||
time: commentData.time ?? '0',
|
||||
clientKey: commentData.clientKey ?? '',
|
||||
});
|
||||
}
|
||||
|
||||
export async function likeGroupAlbumMedia(
|
||||
bridge: Bridge,
|
||||
groupId: number,
|
||||
albumId: string,
|
||||
batchId: string,
|
||||
lloc: string | undefined,
|
||||
isLike: boolean
|
||||
): Promise<any> {
|
||||
const uin = bridge.identity.uin;
|
||||
const clientKey = `${uin}_${Date.now()}_${Math.floor(Math.random() * 100000)}`;
|
||||
|
||||
const type = isLike ? 2 : 1;
|
||||
const status = isLike ? 0 : 1;
|
||||
|
||||
let id = '';
|
||||
if (lloc) {
|
||||
id = `421_1_0_${groupId}|${albumId}|${batchId}^||^421_1_0_${groupId}|${albumId}|${lloc}^||^0`;
|
||||
} else {
|
||||
id = `421_1_0_${groupId}|${albumId}|${batchId}`;
|
||||
}
|
||||
|
||||
const body = protobuf_encode<DoQunLikeRequest>({
|
||||
field1: 5495,
|
||||
field2: "h5_test",
|
||||
field3: "h5_test",
|
||||
body: {
|
||||
type,
|
||||
like: { id, status },
|
||||
publish: {
|
||||
cellCommon: {
|
||||
time: BigInt(Date.now()),
|
||||
feedId: `422_0_${batchId}`
|
||||
},
|
||||
cellUserInfo: {
|
||||
user: { uin }
|
||||
},
|
||||
cellMedia: {
|
||||
albumId: albumId,
|
||||
batchId: BigInt(batchId)
|
||||
},
|
||||
cellQunInfo: {
|
||||
qunId: groupId.toString()
|
||||
}
|
||||
},
|
||||
clientKey
|
||||
},
|
||||
extMap: [{ key: 'fc-appid', value: '100' }],
|
||||
});
|
||||
|
||||
const result = await bridge.sendRawPacket(
|
||||
'QunAlbum.trpc.qzone.webapp_qun_operation.FeedsWriter.DoQunLike',
|
||||
body,
|
||||
15000
|
||||
);
|
||||
|
||||
if (!result.success || !result.gotResponse || !result.responseData) {
|
||||
throw new Error(result.errorMessage || 'failed to like album media');
|
||||
}
|
||||
|
||||
const resp = protobuf_decode<DoQunLikeResponse>(result.responseData);
|
||||
const resCode = resp.field1;
|
||||
|
||||
if (resCode !== 5495) {
|
||||
throw new Error(`like album media error: retCode ${resCode ?? 'unknown'}`);
|
||||
}
|
||||
|
||||
return convertBigIntToString(resp.body?.like ?? {});
|
||||
}
|
||||
|
||||
export async function deleteGroupAlbumMedia(
|
||||
bridge: Bridge,
|
||||
groupId: number,
|
||||
albumId: string,
|
||||
lloc: string
|
||||
): Promise<any> {
|
||||
const uin = bridge.identity.uin;
|
||||
const clientKey = `${uin}_${Date.now()}_${Math.floor(Math.random() * 100000)}`;
|
||||
|
||||
const body = protobuf_encode<DeleteMediasRequest>({
|
||||
field1: 8694,
|
||||
field2: "h5_test",
|
||||
field3: "h5_test",
|
||||
body: {
|
||||
groupId: groupId.toString(),
|
||||
albumId: albumId,
|
||||
lloc: lloc,
|
||||
},
|
||||
traceId: clientKey,
|
||||
extMap: [{ key: 'fc-appid', value: '100' }],
|
||||
});
|
||||
|
||||
const result = await bridge.sendRawPacket(
|
||||
'QunAlbum.trpc.qzone.webapp_qun_media.QunMedia.DeleteMedias',
|
||||
body,
|
||||
15000
|
||||
);
|
||||
|
||||
if (!result.success || !result.gotResponse || !result.responseData) {
|
||||
throw new Error(result.errorMessage || 'failed to delete album media');
|
||||
}
|
||||
|
||||
const resp = protobuf_decode<DeleteMediasResponse>(result.responseData);
|
||||
const resCode = resp.field1;
|
||||
const errCode = resp.field2;
|
||||
const errMsg = resp.field3;
|
||||
|
||||
if (resCode !== 8694 || errCode) {
|
||||
throw new Error(`delete album media error [${errCode ?? 'unknown'}]: ${errMsg ?? 'unknown'}`);
|
||||
}
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
// GroupAlbumApi — group photo album operations (list/upload/comment/
|
||||
// like/delete + media listing). Inlined from `actions/group-album.ts`
|
||||
// and `web-actions/group-album.ts` (both deleted alongside actions/*
|
||||
// in commit 13). The pure-HTTP helpers in `web/group-album.ts` stay
|
||||
// where they are — they're transport-layer code, not Bridge actions.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type {
|
||||
DeleteMediasRequest,
|
||||
DeleteMediasResponse,
|
||||
DoQunCommentRequest,
|
||||
DoQunCommentResponse,
|
||||
DoQunLikeRequest,
|
||||
DoQunLikeResponse,
|
||||
GetMediaListRequest,
|
||||
GetMediaListResponse,
|
||||
} from '@snowluma/proto-defs/oidb-actions/group-album';
|
||||
import type { BridgeContext } from '../bridge-context';
|
||||
import type { Bridge } from '../bridge';
|
||||
import { getGroupAlbumList, uploadImageToGroupAlbum } from '../web/group-album';
|
||||
import { getCookies } from '../web-actions/cookies';
|
||||
|
||||
function asBridge(ctx: BridgeContext): Bridge { return ctx as unknown as Bridge; }
|
||||
|
||||
export interface GroupAlbumMediaResult {
|
||||
mediaList: any[];
|
||||
nextAttachInfo: string;
|
||||
}
|
||||
|
||||
export interface GroupAlbumCommentResult {
|
||||
id: string;
|
||||
user: { uin: string };
|
||||
content: Array<{ type: number; content: string }>;
|
||||
time: string;
|
||||
clientKey: string;
|
||||
}
|
||||
|
||||
function convertBigIntToString(obj: any): any {
|
||||
if (obj === null || obj === undefined) return obj;
|
||||
if (typeof obj === 'bigint') return obj.toString();
|
||||
if (Array.isArray(obj)) return obj.map(convertBigIntToString);
|
||||
if (typeof obj === 'object') {
|
||||
const result: any = {};
|
||||
for (const key in obj) {
|
||||
result[key] = convertBigIntToString(obj[key]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
export class GroupAlbumApi {
|
||||
constructor(private readonly ctx: BridgeContext) {}
|
||||
|
||||
/** List a group's albums (HTTP-cookie-based, qzone.qq.com). */
|
||||
async list(groupId: number): Promise<any> {
|
||||
const bridge = asBridge(this.ctx);
|
||||
const groupCode = groupId.toString();
|
||||
const uin = this.ctx.identity.uin;
|
||||
const cookieObject = await getCookies(bridge, 'qzone.qq.com');
|
||||
const albumData = await getGroupAlbumList(cookieObject, groupCode, uin);
|
||||
return albumData?.album || [];
|
||||
}
|
||||
|
||||
/** Upload an image into an existing album (HTTP slice-upload). */
|
||||
async upload(groupId: number, albumId: string, albumName: string, filePath: string): Promise<void> {
|
||||
const bridge = asBridge(this.ctx);
|
||||
const groupCode = groupId.toString();
|
||||
const uin = this.ctx.identity.uin;
|
||||
const cookieObject = await getCookies(bridge, 'qzone.qq.com');
|
||||
await uploadImageToGroupAlbum(cookieObject, groupCode, albumId, albumName, filePath, uin);
|
||||
}
|
||||
|
||||
async getMediaList(groupId: number, albumId: string, attachInfo = ''): Promise<GroupAlbumMediaResult> {
|
||||
const traceId = `_${Date.now()}_${Math.floor(Math.random() * 100000)}`;
|
||||
|
||||
const body = protobuf_encode<GetMediaListRequest>({
|
||||
field1: 0,
|
||||
field2: new Uint8Array(0),
|
||||
field3: new Uint8Array(0),
|
||||
reqInfo: {
|
||||
groupId: groupId.toString(),
|
||||
albumId,
|
||||
field3: 0,
|
||||
attachInfo,
|
||||
field5: '',
|
||||
},
|
||||
traceId,
|
||||
extMap: [{ key: 'fc-appid', value: '100' }],
|
||||
});
|
||||
|
||||
const result = await this.ctx.sendRawPacket(
|
||||
'QunAlbum.trpc.qzone.webapp_qun_media.QunMedia.GetMediaList',
|
||||
body,
|
||||
15000,
|
||||
);
|
||||
|
||||
if (!result.success || !result.gotResponse || !result.responseData) {
|
||||
throw new Error(result.errorMessage || 'failed to get album media list');
|
||||
}
|
||||
|
||||
const resp = protobuf_decode<GetMediaListResponse>(result.responseData);
|
||||
|
||||
if (resp.field1 !== 0) {
|
||||
throw new Error(`fetch album media list error: retCode ${resp.field1 ?? 'unknown'}`);
|
||||
}
|
||||
|
||||
const data = resp.data ?? {};
|
||||
const mediaList = data.mediaList ?? [];
|
||||
const nextAttachInfo = data.nextAttachInfo ?? '';
|
||||
|
||||
return convertBigIntToString({ mediaList, nextAttachInfo });
|
||||
}
|
||||
|
||||
async comment(groupId: number, albumId: string, lloc: string, content: string): Promise<GroupAlbumCommentResult> {
|
||||
const traceId = `_${Date.now()}_${Math.floor(Math.random() * 100000)}`;
|
||||
const clientKey = Date.now().toString();
|
||||
const uin = this.ctx.identity.uin;
|
||||
|
||||
const body = protobuf_encode<DoQunCommentRequest>({
|
||||
field1: 8527,
|
||||
field2: new Uint8Array(0),
|
||||
field3: new Uint8Array(0),
|
||||
body: {
|
||||
groupId: groupId.toString(),
|
||||
field3: 2,
|
||||
reqBody: {
|
||||
field1: { field3: 0, field4: '' },
|
||||
field2: {
|
||||
field1: { uin },
|
||||
},
|
||||
field5: {
|
||||
field1: {
|
||||
field2: {
|
||||
field1: 0, field2: '',
|
||||
lloc,
|
||||
field4: '', field6: '', field7: 0, field8: 0, field9: 0, field14: 0, field15: 0, field17: 0,
|
||||
},
|
||||
},
|
||||
albumId,
|
||||
field5: 0,
|
||||
},
|
||||
},
|
||||
field5: {
|
||||
field2: { uin },
|
||||
field3: {
|
||||
field1: 0,
|
||||
field2: content,
|
||||
field3: '', field4: '', field5: 0, field6: '',
|
||||
},
|
||||
clientKey,
|
||||
},
|
||||
},
|
||||
traceId,
|
||||
extMap: [{ key: 'fc-appid', value: '100' }],
|
||||
});
|
||||
|
||||
const result = await this.ctx.sendRawPacket(
|
||||
'QunAlbum.trpc.qzone.webapp_qun_operation.FeedsWriter.DoQunComment',
|
||||
body,
|
||||
15000,
|
||||
);
|
||||
|
||||
if (!result.success || !result.gotResponse || !result.responseData) {
|
||||
throw new Error(result.errorMessage || 'failed to comment on album media');
|
||||
}
|
||||
|
||||
const resp = protobuf_decode<DoQunCommentResponse>(result.responseData);
|
||||
|
||||
const resCode = resp.field1;
|
||||
if (resCode !== 0 && resCode !== 8527 && !resp.comment) {
|
||||
throw new Error(`comment album media error: retCode ${resCode ?? 'unknown'}`);
|
||||
}
|
||||
|
||||
const commentData = resp.comment?.data ?? {};
|
||||
|
||||
return convertBigIntToString({
|
||||
id: commentData.id ?? '',
|
||||
user: { uin: commentData.user?.uin ?? '' },
|
||||
content: commentData.content ?? [],
|
||||
time: commentData.time ?? '0',
|
||||
clientKey: commentData.clientKey ?? '',
|
||||
});
|
||||
}
|
||||
|
||||
async like(groupId: number, albumId: string, batchId: string, lloc: string | undefined, isLike: boolean): Promise<any> {
|
||||
const uin = this.ctx.identity.uin;
|
||||
const clientKey = `${uin}_${Date.now()}_${Math.floor(Math.random() * 100000)}`;
|
||||
|
||||
const type = isLike ? 2 : 1;
|
||||
const status = isLike ? 0 : 1;
|
||||
|
||||
let id = '';
|
||||
if (lloc) {
|
||||
id = `421_1_0_${groupId}|${albumId}|${batchId}^||^421_1_0_${groupId}|${albumId}|${lloc}^||^0`;
|
||||
} else {
|
||||
id = `421_1_0_${groupId}|${albumId}|${batchId}`;
|
||||
}
|
||||
|
||||
const body = protobuf_encode<DoQunLikeRequest>({
|
||||
field1: 5495,
|
||||
field2: 'h5_test',
|
||||
field3: 'h5_test',
|
||||
body: {
|
||||
type,
|
||||
like: { id, status },
|
||||
publish: {
|
||||
cellCommon: {
|
||||
time: BigInt(Date.now()),
|
||||
feedId: `422_0_${batchId}`,
|
||||
},
|
||||
cellUserInfo: {
|
||||
user: { uin },
|
||||
},
|
||||
cellMedia: {
|
||||
albumId,
|
||||
batchId: BigInt(batchId),
|
||||
},
|
||||
cellQunInfo: {
|
||||
qunId: groupId.toString(),
|
||||
},
|
||||
},
|
||||
clientKey,
|
||||
},
|
||||
extMap: [{ key: 'fc-appid', value: '100' }],
|
||||
});
|
||||
|
||||
const result = await this.ctx.sendRawPacket(
|
||||
'QunAlbum.trpc.qzone.webapp_qun_operation.FeedsWriter.DoQunLike',
|
||||
body,
|
||||
15000,
|
||||
);
|
||||
|
||||
if (!result.success || !result.gotResponse || !result.responseData) {
|
||||
throw new Error(result.errorMessage || 'failed to like album media');
|
||||
}
|
||||
|
||||
const resp = protobuf_decode<DoQunLikeResponse>(result.responseData);
|
||||
const resCode = resp.field1;
|
||||
|
||||
if (resCode !== 5495) {
|
||||
throw new Error(`like album media error: retCode ${resCode ?? 'unknown'}`);
|
||||
}
|
||||
|
||||
return convertBigIntToString(resp.body?.like ?? {});
|
||||
}
|
||||
|
||||
async delete(groupId: number, albumId: string, lloc: string): Promise<any> {
|
||||
const uin = this.ctx.identity.uin;
|
||||
const clientKey = `${uin}_${Date.now()}_${Math.floor(Math.random() * 100000)}`;
|
||||
|
||||
const body = protobuf_encode<DeleteMediasRequest>({
|
||||
field1: 8694,
|
||||
field2: 'h5_test',
|
||||
field3: 'h5_test',
|
||||
body: {
|
||||
groupId: groupId.toString(),
|
||||
albumId,
|
||||
lloc,
|
||||
},
|
||||
traceId: clientKey,
|
||||
extMap: [{ key: 'fc-appid', value: '100' }],
|
||||
});
|
||||
|
||||
const result = await this.ctx.sendRawPacket(
|
||||
'QunAlbum.trpc.qzone.webapp_qun_media.QunMedia.DeleteMedias',
|
||||
body,
|
||||
15000,
|
||||
);
|
||||
|
||||
if (!result.success || !result.gotResponse || !result.responseData) {
|
||||
throw new Error(result.errorMessage || 'failed to delete album media');
|
||||
}
|
||||
|
||||
const resp = protobuf_decode<DeleteMediasResponse>(result.responseData);
|
||||
const resCode = resp.field1;
|
||||
const errCode = resp.field2;
|
||||
const errMsg = resp.field3;
|
||||
|
||||
if (resCode !== 8694 || errCode) {
|
||||
throw new Error(`delete album media error [${errCode ?? 'unknown'}]: ${errMsg ?? 'unknown'}`);
|
||||
}
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@
|
||||
import type { BridgeContext } from '../bridge-context';
|
||||
import { ContactsApi } from './contacts';
|
||||
import { GroupAdminApi } from './group-admin';
|
||||
import { GroupAlbumApi } from './group-album';
|
||||
import { GroupFileApi } from './group-file';
|
||||
import { MessageApi } from './message';
|
||||
|
||||
@@ -35,8 +36,9 @@ export interface ApiHub {
|
||||
readonly groupAdmin: GroupAdminApi;
|
||||
/** Group file CRUD + private (c2c) file upload + media URL resolvers. */
|
||||
readonly groupFile: GroupFileApi;
|
||||
/** Group photo album: list/upload/comment/like/delete + media listing. */
|
||||
readonly groupAlbum: GroupAlbumApi;
|
||||
// Pending — added as later commits land:
|
||||
// readonly groupAlbum: GroupAlbumApi;
|
||||
// readonly friend: FriendApi;
|
||||
// readonly interaction: InteractionApi;
|
||||
// readonly profile: ProfileApi;
|
||||
@@ -60,6 +62,7 @@ export function buildApiHub(ctx: BridgeContext): ApiHub {
|
||||
contacts: new ContactsApi(ctx),
|
||||
groupAdmin: new GroupAdminApi(ctx),
|
||||
groupFile: new GroupFileApi(ctx),
|
||||
groupAlbum: new GroupAlbumApi(ctx),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -68,5 +71,6 @@ export function buildApiHub(ctx: BridgeContext): ApiHub {
|
||||
// signature use. Concrete instances always come from `bridge.apis.*`.
|
||||
export { ContactsApi } from './contacts';
|
||||
export { GroupAdminApi } from './group-admin';
|
||||
export { GroupAlbumApi } from './group-album';
|
||||
export { GroupFileApi } from './group-file';
|
||||
export { MessageApi } from './message';
|
||||
@@ -62,13 +62,8 @@ export interface BridgeInterface {
|
||||
rememberUploadedFile(meta: UploadedFileMeta): void;
|
||||
recallUploadedFile(fileId: string): UploadedFileMeta | undefined;
|
||||
|
||||
// ─── Group Album ───
|
||||
getGroupAlbumList(groupId: number): Promise<any>;
|
||||
uploadImageToGroupAlbum(groupId: number, albumId: string, albumName: string, filePath: string): Promise<void>;
|
||||
getGroupAlbumMediaList(groupId: number, albumId: string, attachInfo?: string): Promise<any>;
|
||||
commentGroupAlbumMedia(groupId: number, albumId: string, lloc: string, content: string): Promise<any>;
|
||||
deleteGroupAlbumMedia(groupId: number, albumId: string, lloc: string): Promise<any>;
|
||||
likeGroupAlbumMedia(groupId: number, albumId: string, batchId: string, lloc: string | undefined, isLike: boolean): Promise<any>;
|
||||
// ─── Group Album (moved to apis.groupAlbum) ───
|
||||
// - list / upload / getMediaList / comment / like / delete
|
||||
|
||||
// ─── Forward ───
|
||||
uploadForwardNodes(nodes: ForwardNodePayload[], groupId?: number, userId?: number): Promise<string>;
|
||||
|
||||
@@ -32,12 +32,7 @@ import {
|
||||
setFriendRemark as setFriendRemark_,
|
||||
} from './actions/friend';
|
||||
// actions/group-admin.ts removed — moved to `apis/group-admin.ts::GroupAdminApi`.
|
||||
import {
|
||||
commentGroupAlbumMedia as commentGroupAlbumMedia_,
|
||||
deleteGroupAlbumMedia as deleteGroupAlbumMedia_,
|
||||
getGroupAlbumMediaList as getGroupAlbumMediaList_,
|
||||
likeGroupAlbumMedia as likeGroupAlbumMedia_,
|
||||
} from './actions/group-album';
|
||||
// actions/group-album.ts removed — moved to `apis/group-album.ts::GroupAlbumApi`.
|
||||
// Group file CRUD + private c2c upload + media URL resolvers moved to
|
||||
// `apis.groupFile` (see `apis/group-file.ts::GroupFileApi`). The shared
|
||||
// result type still lives here because the OneBot side imports it
|
||||
@@ -79,13 +74,11 @@ import {
|
||||
getCookiesStr as getCookiesStr_,
|
||||
getCredentials as getCredentials_,
|
||||
getCsrfToken as getCsrfToken_,
|
||||
getGroupAlbumListWeb as getGroupAlbumListWeb_,
|
||||
getGroupEssence as getGroupEssence_,
|
||||
getGroupEssenceAll as getGroupEssenceAll_,
|
||||
getGroupHonorInfo as getGroupHonorInfo_,
|
||||
getGroupNotice as getGroupNotice_,
|
||||
sendGroupNotice as sendGroupNotice_,
|
||||
uploadImageToGroupAlbumWeb as uploadImageToGroupAlbumWeb_,
|
||||
} from './web-actions';
|
||||
import type { WebHonorType } from './web/group-honor';
|
||||
export { AiVoiceChatType };
|
||||
@@ -355,29 +348,8 @@ export class Bridge implements BridgeInterface {
|
||||
return getGroupEssenceAll_(this, groupId);
|
||||
}
|
||||
|
||||
async getGroupAlbumList(groupId: number): Promise<any> {
|
||||
return getGroupAlbumListWeb_(this, groupId);
|
||||
}
|
||||
|
||||
async uploadImageToGroupAlbum(groupId: number, albumId: string, albumName: string, filePath: string): Promise<void> {
|
||||
return uploadImageToGroupAlbumWeb_(this, groupId, albumId, albumName, filePath);
|
||||
}
|
||||
|
||||
async getGroupAlbumMediaList(groupId: number, albumId: string, attachInfo?: string): Promise<any> {
|
||||
return getGroupAlbumMediaList_(this, groupId, albumId, attachInfo);
|
||||
}
|
||||
|
||||
async commentGroupAlbumMedia(groupId: number, albumId: string, lloc: string, content: string): Promise<any> {
|
||||
return commentGroupAlbumMedia_(this, groupId, albumId, lloc, content);
|
||||
}
|
||||
|
||||
async likeGroupAlbumMedia(groupId: number, albumId: string, batchId: string, lloc: string | undefined, isLike: boolean): Promise<any> {
|
||||
return likeGroupAlbumMedia_(this, groupId, albumId, batchId, lloc, isLike);
|
||||
}
|
||||
|
||||
async deleteGroupAlbumMedia(groupId: number, albumId: string, lloc: string): Promise<any> {
|
||||
return deleteGroupAlbumMedia_(this, groupId, albumId, lloc);
|
||||
}
|
||||
// GroupAlbum methods (list/upload/getMediaList/comment/like/delete)
|
||||
// moved to apis.groupAlbum (apis/group-album.ts::GroupAlbumApi).
|
||||
|
||||
async sendGroupNotice(groupId: number, content: string, options?: any) {
|
||||
return sendGroupNotice_(this, groupId, content, options);
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
import type { Bridge } from '../bridge';
|
||||
import { getGroupAlbumList, uploadImageToGroupAlbum } from '../web/group-album';
|
||||
import { getCookies } from './cookies';
|
||||
|
||||
export async function getGroupAlbumListWeb(bridge: Bridge, groupId: number) {
|
||||
const groupCode = groupId.toString();
|
||||
const uin = bridge.identity.uin;
|
||||
const cookieObject = await getCookies(bridge, 'qzone.qq.com');
|
||||
|
||||
const albumData = await getGroupAlbumList(cookieObject, groupCode, uin);
|
||||
|
||||
return albumData?.album || [];
|
||||
}
|
||||
|
||||
export async function uploadImageToGroupAlbumWeb(
|
||||
bridge: Bridge,
|
||||
groupId: number,
|
||||
albumId: string,
|
||||
albumName: string,
|
||||
filePath: string
|
||||
): Promise<void> {
|
||||
const groupCode = groupId.toString();
|
||||
const uin = bridge.identity.uin;
|
||||
const cookieObject = await getCookies(bridge, 'qzone.qq.com');
|
||||
|
||||
await uploadImageToGroupAlbum(cookieObject, groupCode, albumId, albumName, filePath, uin);
|
||||
}
|
||||
@@ -13,8 +13,3 @@ export {
|
||||
deleteGroupNoticeByFid, getGroupNotice, sendGroupNotice
|
||||
} from './group-notice';
|
||||
|
||||
export {
|
||||
getGroupAlbumListWeb,
|
||||
uploadImageToGroupAlbumWeb
|
||||
} from './group-album';
|
||||
|
||||
@@ -186,12 +186,12 @@ export function buildApiContext(ref: OneBotInstanceContext): ApiActionContext {
|
||||
// Web-backed actions.
|
||||
getGroupHonorInfo: (groupId: number, type: WebHonorType | string) => bridge.getGroupHonorInfo(groupId, type),
|
||||
getGroupEssenceAll: (groupId) => bridge.getGroupEssenceAll(groupId),
|
||||
getGroupAlbumList: (groupId) => bridge.getGroupAlbumList(groupId),
|
||||
uploadImageToGroupAlbum: (groupId, albumId, albumName, filePath) => bridge.uploadImageToGroupAlbum(groupId, albumId, albumName, filePath),
|
||||
getGroupAlbumMediaList: (groupId, albumId, attachInfo) => bridge.getGroupAlbumMediaList(groupId, albumId, attachInfo),
|
||||
commentGroupAlbumMedia: (groupId, albumId, lloc, content) => bridge.commentGroupAlbumMedia(groupId, albumId, lloc, content),
|
||||
deleteGroupAlbumMedia: (groupId, albumId, lloc) => bridge.deleteGroupAlbumMedia(groupId, albumId, lloc),
|
||||
likeGroupAlbumMedia: (groupId, albumId, batchId, lloc, isLike) => bridge.likeGroupAlbumMedia(groupId, albumId, batchId, lloc, isLike),
|
||||
getGroupAlbumList: (groupId) => bridge.apis.groupAlbum.list(groupId),
|
||||
uploadImageToGroupAlbum: (groupId, albumId, albumName, filePath) => bridge.apis.groupAlbum.upload(groupId, albumId, albumName, filePath),
|
||||
getGroupAlbumMediaList: (groupId, albumId, attachInfo) => bridge.apis.groupAlbum.getMediaList(groupId, albumId, attachInfo),
|
||||
commentGroupAlbumMedia: (groupId, albumId, lloc, content) => bridge.apis.groupAlbum.comment(groupId, albumId, lloc, content),
|
||||
deleteGroupAlbumMedia: (groupId, albumId, lloc) => bridge.apis.groupAlbum.delete(groupId, albumId, lloc),
|
||||
likeGroupAlbumMedia: (groupId, albumId, batchId, lloc, isLike) => bridge.apis.groupAlbum.like(groupId, albumId, batchId, lloc, isLike),
|
||||
sendGroupNotice: (groupId, content, options) => bridge.sendGroupNotice(groupId, content, options),
|
||||
getGroupNotice: (groupId) => bridge.getGroupNotice(groupId),
|
||||
deleteGroupNotice: (groupId, fid) => bridge.deleteGroupNotice(groupId, fid),
|
||||
|
||||
Reference in new issue
Block a user