2018-05-05 01:57:11 +00:00
|
|
|
// The idea with this file is to make it webpackable for the style guide
|
|
|
|
|
2018-05-23 18:09:37 +00:00
|
|
|
const Backbone = require('../../ts/backbone');
|
|
|
|
const Crypto = require('./crypto');
|
2018-07-25 22:02:27 +00:00
|
|
|
const Data = require('./data');
|
2018-05-23 18:09:37 +00:00
|
|
|
const Database = require('./database');
|
|
|
|
const Emoji = require('../../ts/util/emoji');
|
2018-10-18 01:01:21 +00:00
|
|
|
const IndexedDB = require('./indexeddb');
|
2018-05-23 18:09:37 +00:00
|
|
|
const Notifications = require('../../ts/notifications');
|
|
|
|
const OS = require('../../ts/OS');
|
|
|
|
const Settings = require('./settings');
|
|
|
|
const Util = require('../../ts/util');
|
2018-07-27 01:13:56 +00:00
|
|
|
const { migrateToSQL } = require('./migrate_to_sql');
|
2018-10-18 01:01:21 +00:00
|
|
|
const Metadata = require('./metadata/SecretSessionCipher');
|
|
|
|
const RefreshSenderCertificate = require('./refresh_sender_certificate');
|
2019-01-16 03:03:56 +00:00
|
|
|
const LinkPreviews = require('./link_previews');
|
2019-01-30 20:15:07 +00:00
|
|
|
const AttachmentDownloads = require('./attachment_downloads');
|
2018-05-05 01:57:11 +00:00
|
|
|
|
|
|
|
// Components
|
2018-12-02 01:48:53 +00:00
|
|
|
const {
|
|
|
|
AttachmentList,
|
|
|
|
} = require('../../ts/components/conversation/AttachmentList');
|
|
|
|
const { CaptionEditor } = require('../../ts/components/CaptionEditor');
|
2018-05-05 01:57:11 +00:00
|
|
|
const {
|
|
|
|
ContactDetail,
|
2018-05-23 18:09:37 +00:00
|
|
|
} = require('../../ts/components/conversation/ContactDetail');
|
2018-06-27 20:53:49 +00:00
|
|
|
const { ContactListItem } = require('../../ts/components/ContactListItem');
|
2018-05-23 18:09:37 +00:00
|
|
|
const { ContactName } = require('../../ts/components/conversation/ContactName');
|
2018-05-18 23:57:26 +00:00
|
|
|
const {
|
2018-07-09 21:29:13 +00:00
|
|
|
ConversationHeader,
|
|
|
|
} = require('../../ts/components/conversation/ConversationHeader');
|
2018-07-18 03:25:55 +00:00
|
|
|
const {
|
|
|
|
ConversationListItem,
|
|
|
|
} = require('../../ts/components/ConversationListItem');
|
2018-05-05 01:57:11 +00:00
|
|
|
const {
|
|
|
|
EmbeddedContact,
|
2018-05-23 18:09:37 +00:00
|
|
|
} = require('../../ts/components/conversation/EmbeddedContact');
|
|
|
|
const { Emojify } = require('../../ts/components/conversation/Emojify');
|
2018-07-09 21:29:13 +00:00
|
|
|
const {
|
|
|
|
GroupNotification,
|
|
|
|
} = require('../../ts/components/conversation/GroupNotification');
|
2018-05-23 18:09:37 +00:00
|
|
|
const { Lightbox } = require('../../ts/components/Lightbox');
|
|
|
|
const { LightboxGallery } = require('../../ts/components/LightboxGallery');
|
2018-05-05 01:57:11 +00:00
|
|
|
const {
|
|
|
|
MediaGallery,
|
2018-05-23 18:09:37 +00:00
|
|
|
} = require('../../ts/components/conversation/media-gallery/MediaGallery');
|
2018-09-29 00:42:13 +00:00
|
|
|
const { MainHeader } = require('../../ts/components/MainHeader');
|
2018-07-09 21:29:13 +00:00
|
|
|
const { Message } = require('../../ts/components/conversation/Message');
|
2018-05-23 18:09:37 +00:00
|
|
|
const { MessageBody } = require('../../ts/components/conversation/MessageBody');
|
2018-07-09 21:29:13 +00:00
|
|
|
const {
|
|
|
|
MessageDetail,
|
|
|
|
} = require('../../ts/components/conversation/MessageDetail');
|
2018-05-23 18:09:37 +00:00
|
|
|
const { Quote } = require('../../ts/components/conversation/Quote');
|
2018-07-09 21:29:13 +00:00
|
|
|
const {
|
|
|
|
ResetSessionNotification,
|
|
|
|
} = require('../../ts/components/conversation/ResetSessionNotification');
|
|
|
|
const {
|
|
|
|
SafetyNumberNotification,
|
|
|
|
} = require('../../ts/components/conversation/SafetyNumberNotification');
|
2019-01-16 03:03:56 +00:00
|
|
|
const {
|
|
|
|
StagedLinkPreview,
|
|
|
|
} = require('../../ts/components/conversation/StagedLinkPreview');
|
2018-07-09 21:29:13 +00:00
|
|
|
const {
|
|
|
|
TimerNotification,
|
|
|
|
} = require('../../ts/components/conversation/TimerNotification');
|
2018-11-14 19:10:32 +00:00
|
|
|
const {
|
|
|
|
TypingBubble,
|
|
|
|
} = require('../../ts/components/conversation/TypingBubble');
|
2018-07-09 21:29:13 +00:00
|
|
|
const {
|
|
|
|
VerificationNotification,
|
|
|
|
} = require('../../ts/components/conversation/VerificationNotification');
|
2018-05-05 01:57:11 +00:00
|
|
|
|
|
|
|
// Migrations
|
|
|
|
const {
|
|
|
|
getPlaceholderMigrations,
|
2018-09-21 01:47:19 +00:00
|
|
|
getCurrentVersion,
|
2018-05-23 18:09:37 +00:00
|
|
|
} = require('./migrations/get_placeholder_migrations');
|
2018-10-18 01:01:21 +00:00
|
|
|
const { run } = require('./migrations/migrations');
|
2018-05-05 01:57:11 +00:00
|
|
|
|
|
|
|
// Types
|
2018-05-23 18:09:37 +00:00
|
|
|
const AttachmentType = require('./types/attachment');
|
2018-07-09 21:29:13 +00:00
|
|
|
const VisualAttachment = require('./types/visual_attachment');
|
2018-05-23 18:09:37 +00:00
|
|
|
const Contact = require('../../ts/types/Contact');
|
2018-09-21 01:47:19 +00:00
|
|
|
const Conversation = require('./types/conversation');
|
2018-05-23 18:09:37 +00:00
|
|
|
const Errors = require('./types/errors');
|
|
|
|
const MediaGalleryMessage = require('../../ts/components/conversation/media-gallery/types/Message');
|
2018-07-09 21:29:13 +00:00
|
|
|
const MessageType = require('./types/message');
|
2018-05-23 18:09:37 +00:00
|
|
|
const MIME = require('../../ts/types/MIME');
|
2018-07-09 21:29:13 +00:00
|
|
|
const PhoneNumber = require('../../ts/types/PhoneNumber');
|
2018-05-23 18:09:37 +00:00
|
|
|
const SettingsType = require('../../ts/types/Settings');
|
2018-05-05 01:57:11 +00:00
|
|
|
|
|
|
|
// Views
|
2018-05-23 18:09:37 +00:00
|
|
|
const Initialization = require('./views/initialization');
|
2018-05-05 01:57:11 +00:00
|
|
|
|
|
|
|
// Workflow
|
2018-05-23 18:09:37 +00:00
|
|
|
const { IdleDetector } = require('./idle_detector');
|
|
|
|
const MessageDataMigrator = require('./messages_data_migrator');
|
2018-05-05 01:57:11 +00:00
|
|
|
|
2018-07-03 22:33:50 +00:00
|
|
|
function initializeMigrations({
|
|
|
|
userDataPath,
|
|
|
|
getRegionCode,
|
2018-07-09 21:29:13 +00:00
|
|
|
Attachments,
|
|
|
|
Type,
|
|
|
|
VisualType,
|
2018-07-21 19:00:08 +00:00
|
|
|
logger,
|
2018-07-03 22:33:50 +00:00
|
|
|
}) {
|
|
|
|
if (!Attachments) {
|
|
|
|
return null;
|
|
|
|
}
|
2018-07-09 21:29:13 +00:00
|
|
|
const {
|
|
|
|
getPath,
|
|
|
|
createReader,
|
|
|
|
createAbsolutePathGetter,
|
|
|
|
createWriterForNew,
|
|
|
|
createWriterForExisting,
|
|
|
|
} = Attachments;
|
|
|
|
const {
|
|
|
|
makeObjectUrl,
|
|
|
|
revokeObjectUrl,
|
|
|
|
getImageDimensions,
|
|
|
|
makeImageThumbnail,
|
|
|
|
makeVideoScreenshot,
|
|
|
|
} = VisualType;
|
|
|
|
|
|
|
|
const attachmentsPath = getPath(userDataPath);
|
|
|
|
const readAttachmentData = createReader(attachmentsPath);
|
2018-07-03 22:33:50 +00:00
|
|
|
const loadAttachmentData = Type.loadData(readAttachmentData);
|
2019-01-28 23:24:19 +00:00
|
|
|
const loadPreviewData = MessageType.loadPreviewData(loadAttachmentData);
|
|
|
|
const loadQuoteData = MessageType.loadQuoteData(loadAttachmentData);
|
2018-07-09 21:29:13 +00:00
|
|
|
const getAbsoluteAttachmentPath = createAbsolutePathGetter(attachmentsPath);
|
2018-07-24 18:55:24 +00:00
|
|
|
const deleteOnDisk = Attachments.createDeleter(attachmentsPath);
|
2019-01-30 20:15:07 +00:00
|
|
|
const writeNewAttachmentData = createWriterForNew(attachmentsPath);
|
2018-05-05 01:57:11 +00:00
|
|
|
|
2018-07-03 22:33:50 +00:00
|
|
|
return {
|
2018-05-05 01:57:11 +00:00
|
|
|
attachmentsPath,
|
2018-10-24 18:31:01 +00:00
|
|
|
deleteAttachmentData: deleteOnDisk,
|
2018-07-24 18:55:24 +00:00
|
|
|
deleteExternalMessageFiles: MessageType.deleteAllExternalFiles({
|
|
|
|
deleteAttachmentData: Type.deleteData(deleteOnDisk),
|
|
|
|
deleteOnDisk,
|
|
|
|
}),
|
2018-07-09 21:29:13 +00:00
|
|
|
getAbsoluteAttachmentPath,
|
2018-05-05 01:57:11 +00:00
|
|
|
getPlaceholderMigrations,
|
2018-09-21 01:47:19 +00:00
|
|
|
getCurrentVersion,
|
2018-05-05 01:57:11 +00:00
|
|
|
loadAttachmentData,
|
2018-07-09 21:29:13 +00:00
|
|
|
loadMessage: MessageType.createAttachmentLoader(loadAttachmentData),
|
2019-01-16 03:03:56 +00:00
|
|
|
loadPreviewData,
|
|
|
|
loadQuoteData,
|
2018-12-13 21:41:42 +00:00
|
|
|
readAttachmentData,
|
2018-10-18 01:01:21 +00:00
|
|
|
run,
|
2019-01-30 20:15:07 +00:00
|
|
|
processNewAttachment: attachment =>
|
|
|
|
MessageType.processNewAttachment(attachment, {
|
|
|
|
writeNewAttachmentData,
|
|
|
|
getAbsoluteAttachmentPath,
|
|
|
|
makeObjectUrl,
|
|
|
|
revokeObjectUrl,
|
|
|
|
getImageDimensions,
|
|
|
|
makeImageThumbnail,
|
|
|
|
makeVideoScreenshot,
|
|
|
|
logger,
|
|
|
|
}),
|
2018-07-27 02:19:34 +00:00
|
|
|
upgradeMessageSchema: (message, options = {}) => {
|
|
|
|
const { maxVersion } = options;
|
|
|
|
|
|
|
|
return MessageType.upgradeSchema(message, {
|
2019-01-30 20:15:07 +00:00
|
|
|
writeNewAttachmentData,
|
2018-05-09 01:03:02 +00:00
|
|
|
getRegionCode,
|
2018-07-09 21:29:13 +00:00
|
|
|
getAbsoluteAttachmentPath,
|
|
|
|
makeObjectUrl,
|
|
|
|
revokeObjectUrl,
|
|
|
|
getImageDimensions,
|
|
|
|
makeImageThumbnail,
|
|
|
|
makeVideoScreenshot,
|
2018-07-21 19:00:08 +00:00
|
|
|
logger,
|
2018-07-27 02:19:34 +00:00
|
|
|
maxVersion,
|
|
|
|
});
|
|
|
|
},
|
2018-07-21 19:00:08 +00:00
|
|
|
writeMessageAttachments: MessageType.createAttachmentDataWriter({
|
|
|
|
writeExistingAttachmentData: createWriterForExisting(attachmentsPath),
|
|
|
|
logger,
|
|
|
|
}),
|
2018-10-24 18:31:01 +00:00
|
|
|
writeNewAttachmentData: createWriterForNew(attachmentsPath),
|
2018-05-05 01:57:11 +00:00
|
|
|
};
|
2018-07-03 22:33:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
exports.setup = (options = {}) => {
|
2018-07-21 19:00:08 +00:00
|
|
|
const { Attachments, userDataPath, getRegionCode, logger } = options;
|
2018-07-03 22:33:50 +00:00
|
|
|
|
|
|
|
const Migrations = initializeMigrations({
|
|
|
|
userDataPath,
|
|
|
|
getRegionCode,
|
2018-07-09 21:29:13 +00:00
|
|
|
Attachments,
|
|
|
|
Type: AttachmentType,
|
|
|
|
VisualType: VisualAttachment,
|
2018-07-21 19:00:08 +00:00
|
|
|
logger,
|
2018-07-03 22:33:50 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const Components = {
|
2018-12-02 01:48:53 +00:00
|
|
|
AttachmentList,
|
|
|
|
CaptionEditor,
|
2018-07-03 22:33:50 +00:00
|
|
|
ContactDetail,
|
2018-06-27 20:53:49 +00:00
|
|
|
ContactListItem,
|
2018-07-03 22:33:50 +00:00
|
|
|
ContactName,
|
2018-07-09 21:29:13 +00:00
|
|
|
ConversationHeader,
|
2018-07-18 03:25:55 +00:00
|
|
|
ConversationListItem,
|
2018-07-03 22:33:50 +00:00
|
|
|
EmbeddedContact,
|
|
|
|
Emojify,
|
2018-07-09 21:29:13 +00:00
|
|
|
GroupNotification,
|
2018-07-03 22:33:50 +00:00
|
|
|
Lightbox,
|
|
|
|
LightboxGallery,
|
2018-09-29 00:42:13 +00:00
|
|
|
MainHeader,
|
2018-07-03 22:33:50 +00:00
|
|
|
MediaGallery,
|
2018-07-09 21:29:13 +00:00
|
|
|
Message,
|
2018-07-03 22:33:50 +00:00
|
|
|
MessageBody,
|
2018-07-09 21:29:13 +00:00
|
|
|
MessageDetail,
|
|
|
|
Quote,
|
|
|
|
ResetSessionNotification,
|
|
|
|
SafetyNumberNotification,
|
2019-01-16 03:03:56 +00:00
|
|
|
StagedLinkPreview,
|
2018-07-09 21:29:13 +00:00
|
|
|
TimerNotification,
|
2018-07-03 22:33:50 +00:00
|
|
|
Types: {
|
|
|
|
Message: MediaGalleryMessage,
|
|
|
|
},
|
2018-11-14 19:10:32 +00:00
|
|
|
TypingBubble,
|
2018-07-09 21:29:13 +00:00
|
|
|
VerificationNotification,
|
2018-07-03 22:33:50 +00:00
|
|
|
};
|
2018-05-05 01:57:11 +00:00
|
|
|
|
|
|
|
const Types = {
|
|
|
|
Attachment: AttachmentType,
|
|
|
|
Contact,
|
|
|
|
Conversation,
|
|
|
|
Errors,
|
2018-07-09 21:29:13 +00:00
|
|
|
Message: MessageType,
|
2018-05-05 01:57:11 +00:00
|
|
|
MIME,
|
2018-07-09 21:29:13 +00:00
|
|
|
PhoneNumber,
|
2018-05-05 01:57:11 +00:00
|
|
|
Settings: SettingsType,
|
2018-07-09 21:29:13 +00:00
|
|
|
VisualAttachment,
|
2018-05-05 01:57:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const Views = {
|
|
|
|
Initialization,
|
|
|
|
};
|
|
|
|
|
|
|
|
const Workflow = {
|
|
|
|
IdleDetector,
|
|
|
|
MessageDataMigrator,
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
2019-01-30 20:15:07 +00:00
|
|
|
AttachmentDownloads,
|
2018-05-05 01:57:11 +00:00
|
|
|
Backbone,
|
|
|
|
Components,
|
|
|
|
Crypto,
|
2018-07-25 22:02:27 +00:00
|
|
|
Data,
|
2018-05-05 01:57:11 +00:00
|
|
|
Database,
|
2018-05-18 19:00:46 +00:00
|
|
|
Emoji,
|
2018-10-18 01:01:21 +00:00
|
|
|
IndexedDB,
|
2019-01-16 03:03:56 +00:00
|
|
|
LinkPreviews,
|
|
|
|
Metadata,
|
|
|
|
migrateToSQL,
|
2018-05-05 01:57:11 +00:00
|
|
|
Migrations,
|
|
|
|
Notifications,
|
|
|
|
OS,
|
2018-10-18 01:01:21 +00:00
|
|
|
RefreshSenderCertificate,
|
2018-05-05 01:57:11 +00:00
|
|
|
Settings,
|
|
|
|
Types,
|
|
|
|
Util,
|
|
|
|
Views,
|
|
|
|
Workflow,
|
|
|
|
};
|
|
|
|
};
|