Add support for receiving attachments from CDN 2
This commit is contained in:
parent
4dc7631851
commit
a0e9791623
16 changed files with 156 additions and 64 deletions
|
@ -65,7 +65,7 @@ describe('Backup', () => {
|
|||
};
|
||||
const index = 0;
|
||||
const attachment = {
|
||||
id: '123',
|
||||
cdnId: '123',
|
||||
};
|
||||
const expected = '123';
|
||||
|
||||
|
@ -77,13 +77,13 @@ describe('Backup', () => {
|
|||
assert.strictEqual(actual, expected);
|
||||
});
|
||||
|
||||
it('uses filename and contentType if available', () => {
|
||||
it('uses attachment id and contentType if available', () => {
|
||||
const message = {
|
||||
body: 'something',
|
||||
};
|
||||
const index = 0;
|
||||
const attachment = {
|
||||
id: '123',
|
||||
cdnId: '123',
|
||||
contentType: 'image/jpeg',
|
||||
};
|
||||
const expected = '123.jpeg';
|
||||
|
@ -102,7 +102,7 @@ describe('Backup', () => {
|
|||
};
|
||||
const index = 0;
|
||||
const attachment = {
|
||||
id: '123',
|
||||
cdnId: '123',
|
||||
contentType: 'something',
|
||||
};
|
||||
const expected = '123.something';
|
||||
|
@ -114,6 +114,43 @@ describe('Backup', () => {
|
|||
);
|
||||
assert.strictEqual(actual, expected);
|
||||
});
|
||||
|
||||
it('uses CDN key if attachment ID not available', () => {
|
||||
const message = {
|
||||
body: 'something',
|
||||
};
|
||||
const index = 0;
|
||||
const attachment = {
|
||||
cdnKey: 'abc',
|
||||
};
|
||||
const expected = 'abc';
|
||||
|
||||
const actual = Signal.Backup._getExportAttachmentFileName(
|
||||
message,
|
||||
index,
|
||||
attachment
|
||||
);
|
||||
assert.strictEqual(actual, expected);
|
||||
});
|
||||
|
||||
it('uses CDN key and contentType if available', () => {
|
||||
const message = {
|
||||
body: 'something',
|
||||
};
|
||||
const index = 0;
|
||||
const attachment = {
|
||||
cdnKey: 'def',
|
||||
contentType: 'image/jpeg',
|
||||
};
|
||||
const expected = 'def.jpeg';
|
||||
|
||||
const actual = Signal.Backup._getExportAttachmentFileName(
|
||||
message,
|
||||
index,
|
||||
attachment
|
||||
);
|
||||
assert.strictEqual(actual, expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('_getAnonymousAttachmentFileName', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue