Skip to content

Commit a186381

Browse files
author
Erika Perugachi
authored
Merge pull request #1074 from erikaperugachi/spam
Spam
2 parents 18d2320 + 1778422 commit a186381

File tree

13 files changed

+225
-50
lines changed

13 files changed

+225
-50
lines changed

CHANGELOG.md

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,80 @@
11
# Change Log
22

3-
## [0.17.22](https://github.com/criptext/Criptext-Email-React-Client/tree/HEAD)
3+
## [0.20.0](https://github.com/criptext/Criptext-Email-React-Client/tree/HEAD)
44

5-
[Full Changelog](https://github.com/criptext/Criptext-Email-React-Client/compare/0.17.21...HEAD)
5+
[Full Changelog](https://github.com/criptext/Criptext-Email-React-Client/compare/0.19.1...HEAD)
6+
7+
**Closed issues:**
8+
9+
- Composer: Send new param \(type\) in postEmail\(\) [\#830](https://github.com/Criptext/Criptext-Email-React-Client/issues/830)
10+
- Composer: Detect enterprise domain to contact bubble [\#285](https://github.com/Criptext/Criptext-Email-React-Client/issues/285)
11+
12+
**Merged pull requests:**
13+
14+
- Domain [\#1072](https://github.com/Criptext/Criptext-Email-React-Client/pull/1072) ([erikaperugachi](https://github.com/erikaperugachi))
15+
- Composer: Send new param \(type\) in postEmail [\#1071](https://github.com/Criptext/Criptext-Email-React-Client/pull/1071) ([JulianAdams4](https://github.com/JulianAdams4))
16+
17+
## [0.19.1](https://github.com/criptext/Criptext-Email-React-Client/tree/0.19.1) (2019-07-15)
18+
[Full Changelog](https://github.com/criptext/Criptext-Email-React-Client/compare/0.17.22...0.19.1)
19+
20+
**Implemented enhancements:**
21+
22+
- Loading: Add color by theme [\#1047](https://github.com/Criptext/Criptext-Email-React-Client/issues/1047)
23+
- Mailbox Detail: Add suffix on every downloading attachment \(ever\) [\#1044](https://github.com/Criptext/Criptext-Email-React-Client/issues/1044)
24+
- Settings: Hidden delete account option to enterprise account [\#1036](https://github.com/Criptext/Criptext-Email-React-Client/issues/1036)
25+
- Composer: Add divisor line between subject and message [\#1035](https://github.com/Criptext/Criptext-Email-React-Client/issues/1035)
26+
- Email detail: Click to email address and open new composer [\#1033](https://github.com/Criptext/Criptext-Email-React-Client/issues/1033)
27+
- Composer: Edit contact tag [\#1022](https://github.com/Criptext/Criptext-Email-React-Client/issues/1022)
28+
- Thread item: Set visible state between check and avatar component [\#736](https://github.com/Criptext/Criptext-Email-React-Client/issues/736)
29+
30+
**Fixed bugs:**
31+
32+
- Email detail: Fix to open email sent from other email opened [\#1066](https://github.com/Criptext/Criptext-Email-React-Client/issues/1066)
33+
- Window: Fix close windows when this is fullscreen [\#1064](https://github.com/Criptext/Criptext-Email-React-Client/issues/1064)
34+
- Feed Item: Fix contact to external email notification [\#1053](https://github.com/Criptext/Criptext-Email-React-Client/issues/1053)
35+
- Login: Fix Signing Up on confirming another account [\#1042](https://github.com/Criptext/Criptext-Email-React-Client/issues/1042)
36+
- Settings: Fix enter in the signature [\#1039](https://github.com/Criptext/Criptext-Email-React-Client/issues/1039)
37+
- Email detail: Fix handle start download and stop download files. [\#1037](https://github.com/Criptext/Criptext-Email-React-Client/issues/1037)
38+
- Settings: Fix show email preview switch [\#1027](https://github.com/Criptext/Criptext-Email-React-Client/issues/1027)
39+
- Settings: Fix format email to set: Reply to option [\#1023](https://github.com/Criptext/Criptext-Email-React-Client/issues/1023)
40+
- Mailbox: Error to select all and next deselect one thread item [\#1019](https://github.com/Criptext/Criptext-Email-React-Client/issues/1019)
41+
- Events: Error to handle update labels by threadId [\#1007](https://github.com/Criptext/Criptext-Email-React-Client/issues/1007)
42+
- Mailbox: Fix click action on changing settings tab [\#838](https://github.com/Criptext/Criptext-Email-React-Client/issues/838)
43+
44+
**Closed issues:**
45+
46+
- Composer: Only add app signature to external emails. [\#1067](https://github.com/Criptext/Criptext-Email-React-Client/issues/1067)
47+
- Thread: Scroll to bottom position when thread has been replied [\#1063](https://github.com/Criptext/Criptext-Email-React-Client/issues/1063)
48+
- Email detail: Add tooltip to icon secure [\#1051](https://github.com/Criptext/Criptext-Email-React-Client/issues/1051)
49+
- File path: Fix path to enterprise users [\#1049](https://github.com/Criptext/Criptext-Email-React-Client/issues/1049)
50+
- Mailbox Detail: Add secure message to user guide [\#1045](https://github.com/Criptext/Criptext-Email-React-Client/issues/1045)
51+
- Composer: Fix contact list position [\#1032](https://github.com/Criptext/Criptext-Email-React-Client/issues/1032)
52+
- Thread Item, Email detail: show icon email encrypted [\#171](https://github.com/Criptext/Criptext-Email-React-Client/issues/171)
53+
54+
**Merged pull requests:**
55+
56+
- Handle email [\#1068](https://github.com/Criptext/Criptext-Email-React-Client/pull/1068) ([erikaperugachi](https://github.com/erikaperugachi))
57+
- Scroll and fullscreen [\#1065](https://github.com/Criptext/Criptext-Email-React-Client/pull/1065) ([erikaperugachi](https://github.com/erikaperugachi))
58+
- Feed [\#1054](https://github.com/Criptext/Criptext-Email-React-Client/pull/1054) ([erikaperugachi](https://github.com/erikaperugachi))
59+
- Add tooltip to icon secure. Close \#1051 [\#1052](https://github.com/Criptext/Criptext-Email-React-Client/pull/1052) ([erikaperugachi](https://github.com/erikaperugachi))
60+
- Path [\#1050](https://github.com/Criptext/Criptext-Email-React-Client/pull/1050) ([erikaperugachi](https://github.com/erikaperugachi))
61+
- Theme [\#1048](https://github.com/Criptext/Criptext-Email-React-Client/pull/1048) ([erikaperugachi](https://github.com/erikaperugachi))
62+
- Attachments Suffix & 'Secure Email' User Guide Step [\#1046](https://github.com/Criptext/Criptext-Email-React-Client/pull/1046) ([JulianAdams4](https://github.com/JulianAdams4))
63+
- Login: Fix Signing Up on confirming another account [\#1043](https://github.com/Criptext/Criptext-Email-React-Client/pull/1043) ([JulianAdams4](https://github.com/JulianAdams4))
64+
- Composer [\#1038](https://github.com/Criptext/Criptext-Email-React-Client/pull/1038) ([erikaperugachi](https://github.com/erikaperugachi))
65+
- Composer [\#1034](https://github.com/Criptext/Criptext-Email-React-Client/pull/1034) ([erikaperugachi](https://github.com/erikaperugachi))
66+
- Network [\#1031](https://github.com/Criptext/Criptext-Email-React-Client/pull/1031) ([erikaperugachi](https://github.com/erikaperugachi))
67+
- Fix show email preview settings. Fix \#1027 [\#1030](https://github.com/Criptext/Criptext-Email-React-Client/pull/1030) ([erikaperugachi](https://github.com/erikaperugachi))
68+
- Secure [\#1029](https://github.com/Criptext/Criptext-Email-React-Client/pull/1029) ([erikaperugachi](https://github.com/erikaperugachi))
69+
- Edit contac tag in composer. Close \#1022 [\#1026](https://github.com/Criptext/Criptext-Email-React-Client/pull/1026) ([erikaperugachi](https://github.com/erikaperugachi))
70+
- Fix: New password Change password on First login [\#1025](https://github.com/Criptext/Criptext-Email-React-Client/pull/1025) ([JulianAdams4](https://github.com/JulianAdams4))
71+
- Avatar [\#1021](https://github.com/Criptext/Criptext-Email-React-Client/pull/1021) ([erikaperugachi](https://github.com/erikaperugachi))
72+
- Popup settings [\#1020](https://github.com/Criptext/Criptext-Email-React-Client/pull/1020) ([erikaperugachi](https://github.com/erikaperugachi))
73+
- Fix update labels to thread, when emailId is repeated. Fix \#1007 [\#1018](https://github.com/Criptext/Criptext-Email-React-Client/pull/1018) ([erikaperugachi](https://github.com/erikaperugachi))
74+
- Props [\#726](https://github.com/Criptext/Criptext-Email-React-Client/pull/726) ([erikaperugachi](https://github.com/erikaperugachi))
75+
76+
## [0.17.22](https://github.com/criptext/Criptext-Email-React-Client/tree/0.17.22) (2019-06-27)
77+
[Full Changelog](https://github.com/criptext/Criptext-Email-React-Client/compare/0.17.21...0.17.22)
678

779
**Implemented enhancements:**
880

@@ -18,9 +90,11 @@
1890
**Closed issues:**
1991

2092
- Mailbox: Parse and Handle event: 217 [\#1013](https://github.com/Criptext/Criptext-Email-React-Client/issues/1013)
93+
- Composer: Don't show Criptext signature to Enterprise users [\#289](https://github.com/Criptext/Criptext-Email-React-Client/issues/289)
2194

2295
**Merged pull requests:**
2396

97+
- Sign [\#1017](https://github.com/Criptext/Criptext-Email-React-Client/pull/1017) ([erikaperugachi](https://github.com/erikaperugachi))
2498
- Handle event 207. Close \#1015 [\#1016](https://github.com/Criptext/Criptext-Email-React-Client/pull/1016) ([erikaperugachi](https://github.com/erikaperugachi))
2599
- Mailbox: Parse and Handle event: 217 \(Mailbox Sync\) [\#1014](https://github.com/Criptext/Criptext-Email-React-Client/pull/1014) ([JulianAdams4](https://github.com/JulianAdams4))
26100
- Enhancement queries to get emails. Close \#1011 [\#1012](https://github.com/Criptext/Criptext-Email-React-Client/pull/1012) ([erikaperugachi](https://github.com/erikaperugachi))

electron_app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "criptext",
3-
"version": "0.19.1",
3+
"version": "0.20.0",
44
"author": {
55
"name": "Criptext Inc",
66
"email": "[email protected]",

electron_app/src/DBManager.js

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,6 @@ const createContactsIfOrNotStore = async (contacts, trx) => {
117117
return emailAddresses;
118118
};
119119

120-
const updateContactScore = (emailId, trx) => {
121-
const subquery = trx
122-
.table(Table.EMAIL_CONTACT)
123-
.select('contactId')
124-
.where('emailId', emailId)
125-
.andWhere('type', '<>', EMAIL_CONTACT_TYPE_FROM);
126-
return trx
127-
.table(Table.CONTACT)
128-
.whereIn('id', subquery)
129-
.increment('score', 1);
130-
};
131-
132120
const filterUniqueContacts = contacts => {
133121
const contactsUnique = contacts.reduce(
134122
(result, contact) => {
@@ -155,7 +143,7 @@ const getAllContacts = () => {
155143
const getContactByEmails = (emails, trx) => {
156144
const knex = trx || db;
157145
return knex
158-
.select('id', 'email', 'score')
146+
.select('id', 'email', 'score', 'spamScore')
159147
.from(Table.CONTACT)
160148
.whereIn('email', emails);
161149
};
@@ -199,6 +187,38 @@ const updateContactByEmail = ({ email, name }, trx) => {
199187
.update({ name });
200188
};
201189

190+
const updateContactScore = (emailId, trx) => {
191+
const subquery = trx
192+
.table(Table.EMAIL_CONTACT)
193+
.select('contactId')
194+
.where('emailId', emailId)
195+
.andWhere('type', '<>', EMAIL_CONTACT_TYPE_FROM);
196+
return trx
197+
.table(Table.CONTACT)
198+
.whereIn('id', subquery)
199+
.increment('score', 1);
200+
};
201+
202+
const updateContactSpamScore = ({ emailIds, notEmailAddress, value }) => {
203+
return db
204+
.table(Table.EMAIL_CONTACT)
205+
.select(
206+
db.raw(
207+
`GROUP_CONCAT(DISTINCT(${Table.EMAIL_CONTACT}.contactId)) as contactIds`
208+
)
209+
)
210+
.whereIn('emailId', emailIds)
211+
.andWhere('type', EMAIL_CONTACT_TYPE_FROM)
212+
.then(result => {
213+
const contactIds = result[0].contactIds.split(',');
214+
return db
215+
.table(Table.CONTACT)
216+
.whereNot('email', notEmailAddress)
217+
.whereIn('id', contactIds)
218+
.update({ spamScore: db.raw(`spamScore + ${value}`) });
219+
});
220+
};
221+
202222
/* EmailContact
203223
----------------------------- */
204224
const createEmailContact = (emailContacts, trx) => {
@@ -226,8 +246,8 @@ const createEmailLabel = (emailLabels, prevTrx) => {
226246
});
227247
};
228248

229-
const deleteEmailLabel = ({ emailsId, labelIds }, prevTrx) => {
230-
const emailLabels = emailsId.map(item => {
249+
const deleteEmailLabel = ({ emailIds, labelIds }, prevTrx) => {
250+
const emailLabels = emailIds.map(item => {
231251
return {
232252
emailId: item,
233253
labelId: labelIds[0]
@@ -239,7 +259,7 @@ const deleteEmailLabel = ({ emailsId, labelIds }, prevTrx) => {
239259
return await trx
240260
.table(Table.EMAIL_LABEL)
241261
.whereIn('labelId', labelIds)
242-
.whereIn('emailId', emailsId)
262+
.whereIn('emailId', emailIds)
243263
.del();
244264
});
245265
};
@@ -977,9 +997,9 @@ const deleteLabelById = id => {
977997
.select('*')
978998
.from(Table.EMAIL_LABEL)
979999
.where('labelId', id);
980-
const emailsId = emailLabels.map(item => item.emailId);
981-
if (emailsId.length) {
982-
await deleteEmailLabel({ emailsId, labelId: id }, trx);
1000+
const emailIds = emailLabels.map(item => item.emailId);
1001+
if (emailIds.length) {
1002+
await deleteEmailLabel({ emailIds, labelId: id }, trx);
9831003
}
9841004
return trx
9851005
.table(Table.LABEL)
@@ -1341,6 +1361,7 @@ module.exports = {
13411361
getFilesByTokens,
13421362
updateAccount,
13431363
updateContactByEmail,
1364+
updateContactSpamScore,
13441365
updateEmail,
13451366
updateEmails,
13461367
updateFeedItems,

electron_app/src/__integrations__/DbExporter.integration.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ describe('Parse database: ', () => {
177177
it('Should parse Contacts to string', async () => {
178178
await insertContacts(contacts);
179179
const expectedString =
180-
`{"table":"contact","object":{"id":1,"email":"[email protected]","name":"Alice","isTrusted":false}}\n` +
181-
`{"table":"contact","object":{"id":2,"email":"[email protected]","name":"Bob","isTrusted":false}}\n` +
182-
`{"table":"contact","object":{"id":3,"email":"[email protected]","name":"Charlie","isTrusted":false}}`;
180+
`{"table":"contact","object":{"id":1,"email":"[email protected]","name":"Alice","isTrusted":false,"spamScore":0}}\n` +
181+
`{"table":"contact","object":{"id":2,"email":"[email protected]","name":"Bob","isTrusted":false,"spamScore":0}}\n` +
182+
`{"table":"contact","object":{"id":3,"email":"[email protected]","name":"Charlie","isTrusted":false,"spamScore":0}}`;
183183
const contactsString = await exportContactTable(dbConnection);
184184
expect(contactsString).toBe(expectedString);
185185
});

electron_app/src/__integrations__/parsed_sample_file.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
{"table":"contact","object":{"id":1,"email":"[email protected]","name":"Alice","isTrusted":false}}
2-
{"table":"contact","object":{"id":2,"email":"[email protected]","name":"Bob","isTrusted":false}}
3-
{"table":"contact","object":{"id":3,"email":"[email protected]","name":"Charlie","isTrusted":false}}
1+
{"table":"contact","object":{"id":1,"email":"[email protected]","name":"Alice","isTrusted":false,"spamScore":0}}
2+
{"table":"contact","object":{"id":2,"email":"[email protected]","name":"Bob","isTrusted":false,"spamScore":0}}
3+
{"table":"contact","object":{"id":3,"email":"[email protected]","name":"Charlie","isTrusted":false,"spamScore":0}}
44
{"table":"label","object":{"id":1,"text":"Sent","color":"000000","type":"custom","visible":true,"uuid":"00000000-0000-0000-0000-000000000001"}}
55
{"table":"label","object":{"id":2,"text":"Starred","color":"111111","type":"custom","visible":true,"uuid":"00000000-0000-0000-0000-000000000002"}}
66
{"table":"email","object":{"id":1,"key":1,"threadId":"threadA","s3Key":"s3KeyA","subject":"Greetings","content":"<p>Hello there</p>","preview":"Hello there","date":"2013-10-07 08:23:19","status":2,"unread":false,"secure":true,"isMuted":false,"messageId":"messageId1","fromAddress":"Alice <[email protected]>","replyTo":"","unsentDate":"2018-06-14 08:23:20"}}

electron_app/src/ipc/database.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ ipc.answerRenderer('db-update-contact-by-email', ({ email, name }) =>
179179
dbManager.updateContactByEmail({ email, name })
180180
);
181181

182+
ipc.answerRenderer('db-update-contact-spam-acore', params =>
183+
dbManager.updateContactSpamScore(params)
184+
);
185+
182186
ipc.answerRenderer('db-update-email', params => dbManager.updateEmail(params));
183187

184188
ipc.answerRenderer('db-update-emails', params =>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const { Table } = require('./../models');
2+
3+
const SPAM_SCORE_COLUMN = 'spamScore';
4+
5+
const createSpamScoreColumn = async knex => {
6+
const columnExists = await knex.schema.hasColumn(
7+
Table.CONTACT,
8+
SPAM_SCORE_COLUMN
9+
);
10+
if (!columnExists)
11+
await knex.schema.table(Table.CONTACT, table => {
12+
table.integer(SPAM_SCORE_COLUMN).default(0);
13+
});
14+
};
15+
16+
const deleteSpamScoreColumn = async knex => {
17+
const columnExists = await knex.schema.hasColumn(
18+
Table.CONTACT,
19+
SPAM_SCORE_COLUMN
20+
);
21+
if (columnExists)
22+
await knex.schema.table(Table.CONTACT, table => {
23+
table.dropColumn(SPAM_SCORE_COLUMN);
24+
});
25+
};
26+
27+
exports.up = async function(knex, Promise) {
28+
const addColumn = createSpamScoreColumn(knex);
29+
return await Promise.all([addColumn]);
30+
};
31+
32+
exports.down = async function(knex, Promise) {
33+
const dropColumn = deleteSpamScoreColumn(knex);
34+
return await Promise.all([dropColumn]);
35+
};

electron_app/src/utils/const.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require('dotenv').config();
33

44
const API_CLIENT_VERSION = '9.0.0';
5-
const LINK_DEVICES_FILE_VERSION = '3';
5+
const LINK_DEVICES_FILE_VERSION = '4';
66
const PROD_SOCKET_URL = 'wss://socket.criptext.com';
77
const PROD_SERVER_URL = 'https://api.criptext.com';
88
const PROD_DATA_TRANSFER_URL = 'https://transfer.criptext.com';

email_mailbox/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "email_mailbox",
3-
"version": "0.19.1",
3+
"version": "0.20.0",
44
"private": true,
55
"dependencies": {
66
"@criptext/electron-better-ipc": "^0.1.2-rc5",

email_mailbox/src/actions/threads.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ const formAddThreadLabelParams = (emails, labelId) => {
573573

574574
const formRemoveThreadLabelParams = (emails, labelId) => {
575575
return {
576-
emailsId: emails.map(email => email.id),
576+
emailIds: emails.map(email => email.id),
577577
labelIds: [labelId]
578578
};
579579
};

0 commit comments

Comments
 (0)