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
@@ -3,6 +3,7 @@ import {
|
||||
GROUP_NOTICE_TYPE_NEW_MEMBERS,
|
||||
calculateBkn,
|
||||
getGroupNoticeWebAPI,
|
||||
groupNoticeImageUrl,
|
||||
parseGroupNoticeImageUploadResponse,
|
||||
resolveGroupNoticeOptions,
|
||||
setGroupNoticeWebAPI,
|
||||
@@ -103,6 +104,19 @@ describe('group-notice / publish HTTP layer', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('group-notice / image download url', () => {
|
||||
it('builds the public CDN url from a picture id', () => {
|
||||
expect(groupNoticeImageUrl('pic-1')).toBe('https://gdynamic.qpic.cn/gdynamic/pic-1/0');
|
||||
});
|
||||
|
||||
it('rejects empty or path-like ids', () => {
|
||||
expect(() => groupNoticeImageUrl('')).toThrow('empty');
|
||||
expect(() => groupNoticeImageUrl(' ')).toThrow('empty');
|
||||
expect(() => groupNoticeImageUrl('a/b')).toThrow('malformed');
|
||||
expect(() => groupNoticeImageUrl('a?x=1')).toThrow('malformed');
|
||||
});
|
||||
});
|
||||
|
||||
describe('group-notice / image upload response', () => {
|
||||
it('parses HTML-escaped image metadata', () => {
|
||||
expect(parseGroupNoticeImageUploadResponse(JSON.stringify({
|
||||
|
||||
Reference in new issue
Block a user