feat(onebot): include download urls on group notice images
_get_group_notice already returned picture ids. Add a fetchable url on each image so callers do not need a separate action. Fixes #440
This commit is contained in:
8 files changed
+39
-9
No files matched your search
@@ -10,6 +10,7 @@ import {
|
||||
GROUP_NOTICE_TYPE_NEW_MEMBERS,
|
||||
GROUP_NOTICE_TYPE_NORMAL,
|
||||
getGroupNoticeWebAPI,
|
||||
groupNoticeImageUrl,
|
||||
setGroupNoticeWebAPI,
|
||||
uploadGroupNoticeImage,
|
||||
type SetNoticeRetSuccess,
|
||||
@@ -43,8 +44,8 @@ export interface WebNoticeInfo {
|
||||
publish_time: number;
|
||||
message: {
|
||||
text: string;
|
||||
image: Array<{ id: string; height: number; width: number }>;
|
||||
images: Array<{ id: string; height: number; width: number }>;
|
||||
image: Array<{ id: string; url: string; height: number; width: number }>;
|
||||
images: Array<{ id: string; url: string; height: number; width: number }>;
|
||||
};
|
||||
settings: import('@snowluma/common/json').JsonValue;
|
||||
read_num: number;
|
||||
@@ -104,6 +105,7 @@ function mapGroupNoticeFeed(feed: WebApiGroupNoticeFeed, sendToNewMembers: boole
|
||||
}
|
||||
return {
|
||||
id: pic.id,
|
||||
url: groupNoticeImageUrl(pic.id),
|
||||
height: finiteNumber(pic.h, `feed ${feed.fid} image ${index}.h`),
|
||||
width: finiteNumber(pic.w, `feed ${feed.fid} image ${index}.w`),
|
||||
};
|
||||
|
||||
@@ -33,8 +33,8 @@ describe('mapGroupNoticeResponse', () => {
|
||||
publish_time: 1_700_000_000,
|
||||
message: {
|
||||
text: 'regular',
|
||||
image: [{ id: 'pic', width: 640, height: 360 }],
|
||||
images: [{ id: 'pic', width: 640, height: 360 }],
|
||||
image: [{ id: 'pic', url: 'https://gdynamic.qpic.cn/gdynamic/pic/0', width: 640, height: 360 }],
|
||||
images: [{ id: 'pic', url: 'https://gdynamic.qpic.cn/gdynamic/pic/0', width: 640, height: 360 }],
|
||||
},
|
||||
settings: {},
|
||||
read_num: 2,
|
||||
@@ -75,5 +75,9 @@ describe('mapGroupNoticeResponse', () => {
|
||||
ec: 0,
|
||||
feeds: [feed('bad', { msg: { text: 'bad', pics: [{ id: 'x', w: 'wide', h: 20 }] } })],
|
||||
})).toThrow('image 0.w');
|
||||
expect(() => mapGroupNoticeResponse({
|
||||
ec: 0,
|
||||
feeds: [feed('bad-id', { msg: { text: 'bad', pics: [{ id: 'a/b', w: 20, h: 20 }] } })],
|
||||
})).toThrow('malformed');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user