Skip to content

Commit 39f6c23

Browse files
author
Erika Perugachi
authored
Merge pull request #258 from JulianAdams4/fixes-0.5
Sent open event
2 parents 0b5471a + 99dd5c8 commit 39f6c23

File tree

19 files changed

+135
-52
lines changed

19 files changed

+135
-52
lines changed

electron_app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"electron-packager": "^10.1.2"
7676
},
7777
"dependencies": {
78-
"@criptext/email-http-client": "^0.8.1",
78+
"@criptext/email-http-client": "^0.8.2",
7979
"knex": "^0.14.2",
8080
"sqlite3": "^3.1.13",
8181
"websocket": "^1.0.25"

electron_app/src/DBManager.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const { db, cleanDataBase, createTables, Table } = require('./models.js');
22
const { formContactsRow } = require('./utils/dataTableUtils.js');
3+
const { noNulls } = require('./utils/ObjectUtils');
34

45
/* Account
56
----------------------------- */
@@ -564,16 +565,19 @@ const deleteEmailLabelAndContactByEmailId = (id, optionalEmailToSave) => {
564565
});
565566
};
566567

567-
const updateEmail = ({ id, key, threadId, date, isMuted, unread }) => {
568-
const params = {};
569-
if (key) params.key = key;
570-
if (threadId) params.threadId = threadId;
571-
if (date) params.date = date;
572-
if (typeof unread === 'boolean') params.unread = unread;
573-
if (typeof isMuted === 'boolean') params.isMuted = isMuted;
568+
const updateEmail = ({ id, key, threadId, date, isMuted, unread, status }) => {
569+
const params = noNulls({
570+
key,
571+
threadId,
572+
date,
573+
unread: typeof unread === 'boolean' ? unread : undefined,
574+
isMuted: typeof isMuted === 'boolean' ? isMuted : undefined,
575+
status
576+
});
577+
const whereParam = id ? { id } : { key };
574578
return db
575579
.table(Table.EMAIL)
576-
.where({ id })
580+
.where(whereParam)
577581
.update(params);
578582
};
579583

electron_app/src/clientManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ class ClientManager {
6464
return client.postKeyBundle(params);
6565
}
6666

67-
postOpenEvent(params) {
68-
return client.postOpenEvent(params);
67+
postOpenEvent(metadataKeys) {
68+
return client.postOpenEvent(metadataKeys);
6969
}
7070

7171
postUser(params) {

electron_app/yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
lodash "^4.2.0"
9797
to-fast-properties "^2.0.0"
9898

99-
"@criptext/email-http-client@^0.8.1":
99+
"@criptext/email-http-client@^0.8.2":
100100
version "0.8.2"
101101
resolved "https://registry.yarnpkg.com/@criptext/email-http-client/-/email-http-client-0.8.2.tgz#6e788b0ea3e2e959b7b6bd46829ede7caaa20ec4"
102102
dependencies:

email_composer/src/containers/Composer.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
myAccount,
1212
throwError,
1313
updateEmail,
14-
updateEmailLabel,
1514
saveDraftChanges,
1615
errors,
1716
deleteEmailsByIds,
@@ -26,6 +25,7 @@ import {
2625
} from './../utils/ArrayUtils';
2726
import signal from './../libs/signal';
2827
import {
28+
EmailStatus,
2929
formOutgoingEmailFromData,
3030
formDataToEditDraft,
3131
formDataToReply
@@ -280,7 +280,7 @@ class ComposerWrapper extends Component {
280280
this.setState({ status: Status.WAITING });
281281
const { data, to, subject, body } = formOutgoingEmailFromData(
282282
this.state,
283-
LabelType.draft.id
283+
LabelType.sent.id
284284
);
285285
let emailId, key;
286286
try {
@@ -310,15 +310,14 @@ class ComposerWrapper extends Component {
310310
const { metadataKey, date } = res.body;
311311
const threadId = this.state.threadId || res.body.threadId;
312312
key = metadataKey;
313-
const emailParams = { id: emailId, key, threadId, date };
314-
await updateEmail(emailParams);
315-
316-
const emailLabelParams = {
317-
emailId,
318-
oldLabelId: LabelType.draft.id,
319-
newLabelId: LabelType.sent.id
313+
const emailParams = {
314+
id: emailId,
315+
key,
316+
threadId,
317+
date,
318+
status: EmailStatus.SENT
320319
};
321-
await updateEmailLabel(emailLabelParams);
320+
await updateEmail(emailParams);
322321

323322
closeComposerWindow(emailId);
324323
} catch (e) {

email_composer/src/utils/EmailUtils.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ const getCriptextRecipients = (recipients, type) => {
3333
}));
3434
};
3535

36+
export const EmailStatus = {
37+
FAIL: 1,
38+
UNSENT: 2,
39+
NONE: 3,
40+
SENDING: 4,
41+
SENT: 5,
42+
DELIVERED: 6,
43+
READ: 7
44+
};
45+
3646
export const formOutgoingEmailFromData = (composerData, labelId) => {
3747
const recipients = {
3848
to: composerData.toEmails,
@@ -52,7 +62,7 @@ export const formOutgoingEmailFromData = (composerData, labelId) => {
5262
content: body,
5363
preview: removeHTMLTags(body).slice(0, 21),
5464
date: Date.now(),
55-
status: 1,
65+
status: EmailStatus.SENDING,
5666
unread: false,
5767
secure: true,
5868
isMuted: false

email_composer/src/utils/__tests__/__snapshots__/EmailUtils.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Object {
3030
"preview": "
3131
",
3232
"secure": true,
33-
"status": 1,
33+
"status": 4,
3434
"subject": "Subject",
3535
"unread": false,
3636
},

email_mailbox/src/actions/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import {
2020
selectThreads,
2121
removeThreads,
2222
removeThreadsLabel,
23-
sendOpenEvent
23+
sendOpenEvent,
24+
updateStatusThread
2425
} from './threads';
2526
import {
2627
addEmails,
@@ -90,6 +91,7 @@ export {
9091
updateFeedItemSuccess,
9192
updateLabel,
9293
updateLabelSuccess,
94+
updateStatusThread,
9395
updateUnreadEmails,
9496
updateUnreadThread,
9597
updateUnreadThreads

email_mailbox/src/actions/threads.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ export const moveThreads = (threadIds, labelId) => ({
106106
labelId
107107
});
108108

109+
export const updateStatusThread = (threadId, status) => ({
110+
type: Thread.UPDATE_STATUS,
111+
threadId,
112+
status
113+
});
114+
109115
export const updateUnreadThread = thread => {
110116
return {
111117
type: Thread.UPDATE_UNREAD_THREAD,
@@ -308,8 +314,7 @@ export const sendOpenEvent = threadId => {
308314
const unreadEmails = await getUnreadEmailsByThreadId(threadId);
309315
if (unreadEmails.length > 0) {
310316
const metadataKeys = unreadEmails.map(item => Number(item.key));
311-
const params = { metadataKeys };
312-
await postOpenEvent(params);
317+
await postOpenEvent(metadataKeys);
313318
}
314319
} catch (e) {
315320
// TO DO

email_mailbox/src/actions/types.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export const Thread = {
1818
MOVE_THREADS: 'MOVE_THREADS',
1919
UPDATE_UNREAD_THREADS: 'UPDATE_UNREAD_THREADS',
2020
UPDATE_UNREAD_THREAD: 'UPDATE_UNREAD_THREAD',
21-
ADD_EMAIL: 'UPDATE_THREAD_EMAIL_IDS'
21+
ADD_EMAIL: 'UPDATE_THREAD_EMAIL_IDS',
22+
UPDATE_STATUS: 'UPDATE_STATUS'
2223
};
2324

2425
export const Contact = {

0 commit comments

Comments
 (0)