Send related emoji along with Sticker, fix SendMessage types
This commit is contained in:
parent
3c91dce993
commit
bd380086a4
35 changed files with 522 additions and 376 deletions
|
@ -10,6 +10,7 @@ import {
|
|||
Section,
|
||||
} from '../../../components/conversation/media-gallery/groupMediaItemsByDate';
|
||||
import { MediaItemType } from '../../../types/MediaItem';
|
||||
import { fakeAttachment } from '../../../test-both/helpers/fakeAttachment';
|
||||
|
||||
const testDate = (
|
||||
year: number,
|
||||
|
@ -31,11 +32,11 @@ const toMediaItem = (date: Date): MediaItemType => ({
|
|||
attachments: [],
|
||||
sent_at: date.getTime(),
|
||||
},
|
||||
attachment: {
|
||||
attachment: fakeAttachment({
|
||||
fileName: 'fileName',
|
||||
contentType: IMAGE_JPEG,
|
||||
url: 'url',
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
describe('groupMediaItemsByDate', () => {
|
||||
|
@ -74,11 +75,11 @@ describe('groupMediaItemsByDate', () => {
|
|||
attachments: [],
|
||||
sent_at: 1523534400000,
|
||||
},
|
||||
attachment: {
|
||||
attachment: fakeAttachment({
|
||||
fileName: 'fileName',
|
||||
contentType: IMAGE_JPEG,
|
||||
url: 'url',
|
||||
},
|
||||
}),
|
||||
},
|
||||
{
|
||||
objectURL: 'Thu, 12 Apr 2018 00:01:00 GMT',
|
||||
|
@ -91,11 +92,11 @@ describe('groupMediaItemsByDate', () => {
|
|||
attachments: [],
|
||||
sent_at: 1523491260000,
|
||||
},
|
||||
attachment: {
|
||||
attachment: fakeAttachment({
|
||||
fileName: 'fileName',
|
||||
contentType: IMAGE_JPEG,
|
||||
url: 'url',
|
||||
},
|
||||
}),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -113,11 +114,11 @@ describe('groupMediaItemsByDate', () => {
|
|||
attachments: [],
|
||||
sent_at: 1523491140000,
|
||||
},
|
||||
attachment: {
|
||||
attachment: fakeAttachment({
|
||||
fileName: 'fileName',
|
||||
contentType: IMAGE_JPEG,
|
||||
url: 'url',
|
||||
},
|
||||
}),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -135,11 +136,11 @@ describe('groupMediaItemsByDate', () => {
|
|||
attachments: [],
|
||||
sent_at: 1523232060000,
|
||||
},
|
||||
attachment: {
|
||||
attachment: fakeAttachment({
|
||||
fileName: 'fileName',
|
||||
contentType: IMAGE_JPEG,
|
||||
url: 'url',
|
||||
},
|
||||
}),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -157,11 +158,11 @@ describe('groupMediaItemsByDate', () => {
|
|||
attachments: [],
|
||||
sent_at: 1523231940000,
|
||||
},
|
||||
attachment: {
|
||||
attachment: fakeAttachment({
|
||||
fileName: 'fileName',
|
||||
contentType: IMAGE_JPEG,
|
||||
url: 'url',
|
||||
},
|
||||
}),
|
||||
},
|
||||
{
|
||||
objectURL: 'Sun, 01 Apr 2018 00:01:00 GMT',
|
||||
|
@ -174,11 +175,11 @@ describe('groupMediaItemsByDate', () => {
|
|||
attachments: [],
|
||||
sent_at: 1522540860000,
|
||||
},
|
||||
attachment: {
|
||||
attachment: fakeAttachment({
|
||||
fileName: 'fileName',
|
||||
contentType: IMAGE_JPEG,
|
||||
url: 'url',
|
||||
},
|
||||
}),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -198,11 +199,11 @@ describe('groupMediaItemsByDate', () => {
|
|||
attachments: [],
|
||||
sent_at: 1522540740000,
|
||||
},
|
||||
attachment: {
|
||||
attachment: fakeAttachment({
|
||||
fileName: 'fileName',
|
||||
contentType: IMAGE_JPEG,
|
||||
url: 'url',
|
||||
},
|
||||
}),
|
||||
},
|
||||
{
|
||||
objectURL: 'Thu, 01 Mar 2018 14:00:00 GMT',
|
||||
|
@ -215,11 +216,11 @@ describe('groupMediaItemsByDate', () => {
|
|||
attachments: [],
|
||||
sent_at: 1519912800000,
|
||||
},
|
||||
attachment: {
|
||||
attachment: fakeAttachment({
|
||||
fileName: 'fileName',
|
||||
contentType: IMAGE_JPEG,
|
||||
url: 'url',
|
||||
},
|
||||
}),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -239,11 +240,11 @@ describe('groupMediaItemsByDate', () => {
|
|||
attachments: [],
|
||||
sent_at: 1298937540000,
|
||||
},
|
||||
attachment: {
|
||||
attachment: fakeAttachment({
|
||||
fileName: 'fileName',
|
||||
contentType: IMAGE_JPEG,
|
||||
url: 'url',
|
||||
},
|
||||
}),
|
||||
},
|
||||
{
|
||||
objectURL: 'Tue, 01 Feb 2011 10:00:00 GMT',
|
||||
|
@ -256,11 +257,11 @@ describe('groupMediaItemsByDate', () => {
|
|||
attachments: [],
|
||||
sent_at: 1296554400000,
|
||||
},
|
||||
attachment: {
|
||||
attachment: fakeAttachment({
|
||||
fileName: 'fileName',
|
||||
contentType: IMAGE_JPEG,
|
||||
url: 'url',
|
||||
},
|
||||
}),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -9,6 +9,8 @@ import { SignalService } from '../../protobuf';
|
|||
import * as Bytes from '../../Bytes';
|
||||
import * as logger from '../../logging/log';
|
||||
|
||||
import { fakeAttachment } from '../../test-both/helpers/fakeAttachment';
|
||||
|
||||
describe('Attachment', () => {
|
||||
describe('getUploadSizeLimitKb', () => {
|
||||
const { getUploadSizeLimitKb } = Attachment;
|
||||
|
@ -37,18 +39,18 @@ describe('Attachment', () => {
|
|||
|
||||
describe('getFileExtension', () => {
|
||||
it('should return file extension from content type', () => {
|
||||
const input: Attachment.AttachmentType = {
|
||||
const input: Attachment.AttachmentType = fakeAttachment({
|
||||
data: Bytes.fromString('foo'),
|
||||
contentType: MIME.IMAGE_GIF,
|
||||
};
|
||||
});
|
||||
assert.strictEqual(Attachment.getFileExtension(input), 'gif');
|
||||
});
|
||||
|
||||
it('should return file extension for QuickTime videos', () => {
|
||||
const input: Attachment.AttachmentType = {
|
||||
const input: Attachment.AttachmentType = fakeAttachment({
|
||||
data: Bytes.fromString('foo'),
|
||||
contentType: MIME.VIDEO_QUICKTIME,
|
||||
};
|
||||
});
|
||||
assert.strictEqual(Attachment.getFileExtension(input), 'mov');
|
||||
});
|
||||
});
|
||||
|
@ -56,11 +58,11 @@ describe('Attachment', () => {
|
|||
describe('getSuggestedFilename', () => {
|
||||
context('for attachment with filename', () => {
|
||||
it('should return existing filename if present', () => {
|
||||
const attachment: Attachment.AttachmentType = {
|
||||
const attachment: Attachment.AttachmentType = fakeAttachment({
|
||||
fileName: 'funny-cat.mov',
|
||||
data: Bytes.fromString('foo'),
|
||||
contentType: MIME.VIDEO_QUICKTIME,
|
||||
};
|
||||
});
|
||||
const actual = Attachment.getSuggestedFilename({ attachment });
|
||||
const expected = 'funny-cat.mov';
|
||||
assert.strictEqual(actual, expected);
|
||||
|
@ -68,10 +70,10 @@ describe('Attachment', () => {
|
|||
});
|
||||
context('for attachment without filename', () => {
|
||||
it('should generate a filename based on timestamp', () => {
|
||||
const attachment: Attachment.AttachmentType = {
|
||||
const attachment: Attachment.AttachmentType = fakeAttachment({
|
||||
data: Bytes.fromString('foo'),
|
||||
contentType: MIME.VIDEO_QUICKTIME,
|
||||
};
|
||||
});
|
||||
const timestamp = new Date(new Date(0).getTimezoneOffset() * 60 * 1000);
|
||||
const actual = Attachment.getSuggestedFilename({
|
||||
attachment,
|
||||
|
@ -83,10 +85,10 @@ describe('Attachment', () => {
|
|||
});
|
||||
context('for attachment with index', () => {
|
||||
it('should generate a filename based on timestamp', () => {
|
||||
const attachment: Attachment.AttachmentType = {
|
||||
const attachment: Attachment.AttachmentType = fakeAttachment({
|
||||
data: Bytes.fromString('foo'),
|
||||
contentType: MIME.VIDEO_QUICKTIME,
|
||||
};
|
||||
});
|
||||
const timestamp = new Date(new Date(0).getTimezoneOffset() * 60 * 1000);
|
||||
const actual = Attachment.getSuggestedFilename({
|
||||
attachment,
|
||||
|
@ -101,107 +103,107 @@ describe('Attachment', () => {
|
|||
|
||||
describe('isVisualMedia', () => {
|
||||
it('should return true for images', () => {
|
||||
const attachment: Attachment.AttachmentType = {
|
||||
const attachment: Attachment.AttachmentType = fakeAttachment({
|
||||
fileName: 'meme.gif',
|
||||
data: Bytes.fromString('gif'),
|
||||
contentType: MIME.IMAGE_GIF,
|
||||
};
|
||||
});
|
||||
assert.isTrue(Attachment.isVisualMedia(attachment));
|
||||
});
|
||||
|
||||
it('should return true for videos', () => {
|
||||
const attachment: Attachment.AttachmentType = {
|
||||
const attachment: Attachment.AttachmentType = fakeAttachment({
|
||||
fileName: 'meme.mp4',
|
||||
data: Bytes.fromString('mp4'),
|
||||
contentType: MIME.VIDEO_MP4,
|
||||
};
|
||||
});
|
||||
assert.isTrue(Attachment.isVisualMedia(attachment));
|
||||
});
|
||||
|
||||
it('should return false for voice message attachment', () => {
|
||||
const attachment: Attachment.AttachmentType = {
|
||||
const attachment: Attachment.AttachmentType = fakeAttachment({
|
||||
fileName: 'Voice Message.aac',
|
||||
flags: SignalService.AttachmentPointer.Flags.VOICE_MESSAGE,
|
||||
data: Bytes.fromString('voice message'),
|
||||
contentType: MIME.AUDIO_AAC,
|
||||
};
|
||||
});
|
||||
assert.isFalse(Attachment.isVisualMedia(attachment));
|
||||
});
|
||||
|
||||
it('should return false for other attachments', () => {
|
||||
const attachment: Attachment.AttachmentType = {
|
||||
const attachment: Attachment.AttachmentType = fakeAttachment({
|
||||
fileName: 'foo.json',
|
||||
data: Bytes.fromString('{"foo": "bar"}'),
|
||||
contentType: MIME.APPLICATION_JSON,
|
||||
};
|
||||
});
|
||||
assert.isFalse(Attachment.isVisualMedia(attachment));
|
||||
});
|
||||
});
|
||||
|
||||
describe('isFile', () => {
|
||||
it('should return true for JSON', () => {
|
||||
const attachment: Attachment.AttachmentType = {
|
||||
const attachment: Attachment.AttachmentType = fakeAttachment({
|
||||
fileName: 'foo.json',
|
||||
data: Bytes.fromString('{"foo": "bar"}'),
|
||||
contentType: MIME.APPLICATION_JSON,
|
||||
};
|
||||
});
|
||||
assert.isTrue(Attachment.isFile(attachment));
|
||||
});
|
||||
|
||||
it('should return false for images', () => {
|
||||
const attachment: Attachment.AttachmentType = {
|
||||
const attachment: Attachment.AttachmentType = fakeAttachment({
|
||||
fileName: 'meme.gif',
|
||||
data: Bytes.fromString('gif'),
|
||||
contentType: MIME.IMAGE_GIF,
|
||||
};
|
||||
});
|
||||
assert.isFalse(Attachment.isFile(attachment));
|
||||
});
|
||||
|
||||
it('should return false for videos', () => {
|
||||
const attachment: Attachment.AttachmentType = {
|
||||
const attachment: Attachment.AttachmentType = fakeAttachment({
|
||||
fileName: 'meme.mp4',
|
||||
data: Bytes.fromString('mp4'),
|
||||
contentType: MIME.VIDEO_MP4,
|
||||
};
|
||||
});
|
||||
assert.isFalse(Attachment.isFile(attachment));
|
||||
});
|
||||
|
||||
it('should return false for voice message attachment', () => {
|
||||
const attachment: Attachment.AttachmentType = {
|
||||
const attachment: Attachment.AttachmentType = fakeAttachment({
|
||||
fileName: 'Voice Message.aac',
|
||||
flags: SignalService.AttachmentPointer.Flags.VOICE_MESSAGE,
|
||||
data: Bytes.fromString('voice message'),
|
||||
contentType: MIME.AUDIO_AAC,
|
||||
};
|
||||
});
|
||||
assert.isFalse(Attachment.isFile(attachment));
|
||||
});
|
||||
});
|
||||
|
||||
describe('isVoiceMessage', () => {
|
||||
it('should return true for voice message attachment', () => {
|
||||
const attachment: Attachment.AttachmentType = {
|
||||
const attachment: Attachment.AttachmentType = fakeAttachment({
|
||||
fileName: 'Voice Message.aac',
|
||||
flags: SignalService.AttachmentPointer.Flags.VOICE_MESSAGE,
|
||||
data: Bytes.fromString('voice message'),
|
||||
contentType: MIME.AUDIO_AAC,
|
||||
};
|
||||
});
|
||||
assert.isTrue(Attachment.isVoiceMessage(attachment));
|
||||
});
|
||||
|
||||
it('should return true for legacy Android voice message attachment', () => {
|
||||
const attachment: Attachment.AttachmentType = {
|
||||
const attachment: Attachment.AttachmentType = fakeAttachment({
|
||||
data: Bytes.fromString('voice message'),
|
||||
contentType: MIME.AUDIO_MP3,
|
||||
};
|
||||
});
|
||||
assert.isTrue(Attachment.isVoiceMessage(attachment));
|
||||
});
|
||||
|
||||
it('should return false for other attachments', () => {
|
||||
const attachment: Attachment.AttachmentType = {
|
||||
const attachment: Attachment.AttachmentType = fakeAttachment({
|
||||
fileName: 'foo.gif',
|
||||
data: Bytes.fromString('foo'),
|
||||
contentType: MIME.IMAGE_GIF,
|
||||
};
|
||||
});
|
||||
assert.isFalse(Attachment.isVoiceMessage(attachment));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -15,6 +15,7 @@ import {
|
|||
getName,
|
||||
parseAndWriteAvatar,
|
||||
} from '../../types/EmbeddedContact';
|
||||
import { fakeAttachment } from '../../test-both/helpers/fakeAttachment';
|
||||
|
||||
describe('Contact', () => {
|
||||
const NUMBER = '+12025550099';
|
||||
|
@ -127,10 +128,10 @@ describe('Contact', () => {
|
|||
organization: 'Somewhere, Inc.',
|
||||
avatar: {
|
||||
isProfile: true,
|
||||
avatar: {
|
||||
avatar: fakeAttachment({
|
||||
error: true,
|
||||
contentType: IMAGE_GIF,
|
||||
},
|
||||
}),
|
||||
},
|
||||
};
|
||||
const expected = {
|
||||
|
@ -164,10 +165,10 @@ describe('Contact', () => {
|
|||
organization: 'Somewhere, Inc.',
|
||||
avatar: {
|
||||
isProfile: true,
|
||||
avatar: {
|
||||
avatar: fakeAttachment({
|
||||
pending: true,
|
||||
contentType: IMAGE_GIF,
|
||||
},
|
||||
}),
|
||||
},
|
||||
};
|
||||
const expected = {
|
||||
|
@ -179,11 +180,11 @@ describe('Contact', () => {
|
|||
organization: 'Somewhere, Inc.',
|
||||
avatar: {
|
||||
isProfile: true,
|
||||
avatar: {
|
||||
avatar: fakeAttachment({
|
||||
pending: true,
|
||||
path: undefined,
|
||||
contentType: IMAGE_GIF,
|
||||
},
|
||||
}),
|
||||
},
|
||||
firstNumber,
|
||||
isNumberOnSignal,
|
||||
|
@ -208,10 +209,10 @@ describe('Contact', () => {
|
|||
organization: 'Somewhere, Inc.',
|
||||
avatar: {
|
||||
isProfile: true,
|
||||
avatar: {
|
||||
avatar: fakeAttachment({
|
||||
path: 'somewhere',
|
||||
contentType: IMAGE_GIF,
|
||||
},
|
||||
}),
|
||||
},
|
||||
};
|
||||
const expected = {
|
||||
|
@ -223,10 +224,10 @@ describe('Contact', () => {
|
|||
organization: 'Somewhere, Inc.',
|
||||
avatar: {
|
||||
isProfile: true,
|
||||
avatar: {
|
||||
avatar: fakeAttachment({
|
||||
path: 'absolute:somewhere',
|
||||
contentType: IMAGE_GIF,
|
||||
},
|
||||
}),
|
||||
},
|
||||
firstNumber,
|
||||
isNumberOnSignal: true,
|
||||
|
@ -363,10 +364,10 @@ describe('Contact', () => {
|
|||
|
||||
it('writes avatar to disk', async () => {
|
||||
const upgradeAttachment = async () => {
|
||||
return {
|
||||
return fakeAttachment({
|
||||
path: 'abc/abcdefg',
|
||||
contentType: IMAGE_PNG,
|
||||
};
|
||||
});
|
||||
};
|
||||
const upgradeVersion = parseAndWriteAvatar(upgradeAttachment);
|
||||
|
||||
|
@ -430,10 +431,10 @@ describe('Contact', () => {
|
|||
avatar: {
|
||||
otherKey: 'otherValue',
|
||||
isProfile: false,
|
||||
avatar: {
|
||||
avatar: fakeAttachment({
|
||||
contentType: IMAGE_PNG,
|
||||
path: 'abc/abcdefg',
|
||||
},
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue