Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
215a0e9
wip
rrrooommmaaa Apr 4, 2022
1b0aeea
Merge remote-tracking branch 'origin/master' into issue-4269-message-…
rrrooommmaaa Apr 13, 2022
6e1a9ec
wip
rrrooommmaaa Apr 14, 2022
6e1c417
eslint fix
rrrooommmaaa Apr 14, 2022
a5d04c0
Merge remote-tracking branch 'origin/master' into issue-4269-message-…
rrrooommmaaa Apr 16, 2022
25f1bff
test rendering of recipients after successful sending
rrrooommmaaa Apr 16, 2022
1f7daf5
lint fix
rrrooommmaaa Apr 18, 2022
4460fb3
testing PWD-encrypted message in reply thread
rrrooommmaaa Apr 19, 2022
1135878
Merge remote-tracking branch 'origin/master' into issue-4269-message-…
rrrooommmaaa Apr 19, 2022
a4c9c8e
lint fix
rrrooommmaaa Apr 20, 2022
1498236
Merge remote-tracking branch 'origin/master' into issue-4269-message-…
rrrooommmaaa Apr 20, 2022
3f8c325
lint fix
rrrooommmaaa Apr 21, 2022
8b91084
wip
rrrooommmaaa Apr 21, 2022
56c69f3
fixes
rrrooommmaaa Apr 26, 2022
19b78a3
Merge remote-tracking branch 'origin/master' into issue-4269-message-…
rrrooommmaaa Apr 26, 2022
8f4bb5b
Merge remote-tracking branch 'origin/master' into issue-4269-message-…
rrrooommmaaa Apr 27, 2022
4ae00f2
removed extra test code
rrrooommmaaa Apr 27, 2022
6d6e241
use Reply-To to reply to PWD recipients from pubkey-encrypted message
rrrooommmaaa May 10, 2022
ecfc8ef
Merge remote-tracking branch 'origin/master' into issue-4269-message-…
rrrooommmaaa May 10, 2022
c8d98dc
Merge remote-tracking branch 'origin/master' into issue-4269-message-…
rrrooommmaaa May 10, 2022
dc88b3e
lint fix
rrrooommmaaa May 10, 2022
99f8908
Merge remote-tracking branch 'origin/master' into issue-4269-message-…
rrrooommmaaa May 10, 2022
66d0ebb
support for pwd-encrypted messages with no pubkey recipients
rrrooommmaaa May 14, 2022
054920c
Merge remote-tracking branch 'origin/master' into issue-4269-message-…
rrrooommmaaa May 14, 2022
e6acd9e
added tests for content of uploaded pwd-protected message
rrrooommmaaa May 15, 2022
f9475ce
Merge remote-tracking branch 'origin/master' into issue-4269-message-…
rrrooommmaaa May 17, 2022
c280407
returned legacy mode
rrrooommmaaa May 17, 2022
b26cde5
lint fix
rrrooommmaaa May 17, 2022
e8e59a4
Merge remote-tracking branch 'origin/master' into issue-4269-message-…
rrrooommmaaa May 21, 2022
7ac5e02
Merge remote-tracking branch 'origin/master' into issue-4269-message-…
rrrooommmaaa May 25, 2022
1dc81eb
error handling when sending multiple messages
rrrooommmaaa May 25, 2022
553612d
test fix / lint fix
rrrooommmaaa May 25, 2022
bfde164
Merge remote-tracking branch 'origin/master' into issue-4269-message-…
rrrooommmaaa May 25, 2022
3da55d4
lint fix
rrrooommmaaa May 25, 2022
25ad59a
Merge remote-tracking branch 'origin/master' into issue-4269-message-…
rrrooommmaaa May 25, 2022
82f610e
Merge remote-tracking branch 'origin/master' into issue-4269-message-…
rrrooommmaaa May 25, 2022
6d3df57
lint fix
rrrooommmaaa May 25, 2022
9f74a85
display a supplementary operation error as a toast
rrrooommmaaa Jun 2, 2022
4ea2be6
lint fix
rrrooommmaaa Jun 2, 2022
c10df8f
lint fix
rrrooommmaaa Jun 2, 2022
14a2d45
don't fail the test on reported 'Test error'
rrrooommmaaa Jun 2, 2022
44f54d3
simplify
rrrooommmaaa Jun 2, 2022
a6dea46
Merge remote-tracking branch 'origin/master' into issue-4269-message-…
rrrooommmaaa Jun 9, 2022
90d2f60
Refactored attempSendMsg and bindMessage into separate functions
rrrooommmaaa Jun 9, 2022
7f28d81
rename
rrrooommmaaa Jun 9, 2022
7e24a10
moved getEmailWithOptionalName to storage module
rrrooommmaaa Jun 9, 2022
0aa5ee1
Merge remote-tracking branch 'origin/master' into issue-4269-message-…
rrrooommmaaa Jun 10, 2022
a0189ac
using a type guard for RecipientType
rrrooommmaaa Jun 10, 2022
c2c5188
added comments
rrrooommmaaa Jun 10, 2022
2199b85
optimizing refactoring
rrrooommmaaa Jun 10, 2022
a327fac
tslint fix
rrrooommmaaa Jun 11, 2022
d38ffdd
refactored msg formatter
rrrooommmaaa Jun 11, 2022
08fc010
fix S/MIME drafts
rrrooommmaaa Jun 12, 2022
f1b2ca8
updated remarks
rrrooommmaaa Jun 12, 2022
cdf57d6
refactored pwd-related code to a separate method formatttSendablePwdMsgs
rrrooommmaaa Jun 12, 2022
00d330c
separate recipients and attachments to render into a separate renderS…
Jun 25, 2022
4e52adc
Merge remote-tracking branch 'origin/master' into issue-4269-message-…
Jun 25, 2022
62a826f
renamed createPgpMimeAttachments to formatEncryptedMimeDataAsPgpMimeM…
Jun 25, 2022
5cf0652
Use plain sendableNonPwdMsg for pubkey recipients
Jun 25, 2022
f86d149
lint fix
Jun 26, 2022
49fa0f8
corrected legacy pwd message
Jun 26, 2022
5d77514
fixed test setup
Jun 27, 2022
35ef46a
Added a test for one legacy pwd recipient and one pubkey recipient of…
Jun 27, 2022
a9978c5
fix
Jun 27, 2022
72c7819
Merge branch 'master' into issue-4269-message-gateway-update
flowcrypt-machine-user Jul 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extension/chrome/elements/attachment.htm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div id="header">
<span></span>
</div>
<div id="name"></div>
<div id="name" data-test="attachment-name"></div>

<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ export class ComposeDraftModule extends ViewModule<ComposeView> {
if (this.hasBodyChanged(this.view.inputModule.squire.getHTML()) || this.hasSubjectChanged(String(this.view.S.cached('input_subject').val())) || forceSave) {
this.currentlySavingDraft = true;
try {
const msgData = this.view.inputModule.extractAll();
const { pubkeys } = await this.view.storageModule.collectSingleFamilyKeys([], msgData.from, true);
const msgData = await this.view.inputModule.extractAll();
const { pubkeys } = await this.view.storageModule.collectSingleFamilyKeys([], msgData.from.email, true);
// collectSingleFamilyKeys filters out bad keys, but only if there are any good keys available
// if no good keys available, it leaves bad keys so we can explain the issue here
if (pubkeys.some(pub => pub.pubkey.expiration && pub.pubkey.expiration < Date.now())) {
Expand All @@ -133,7 +133,7 @@ export class ComposeDraftModule extends ViewModule<ComposeView> {
throw new UnreportableError('Your account keys are not usable for encryption');
}
msgData.pwd = undefined; // not needed for drafts
const sendable = await new EncryptedMsgMailFormatter(this.view, true).sendableMsg(msgData, pubkeys);
const sendable = await new EncryptedMsgMailFormatter(this.view, true).sendableNonPwdMsg(msgData, pubkeys);
if (this.view.replyParams?.inReplyTo) {
sendable.headers.References = this.view.replyParams.inReplyTo;
sendable.headers['In-Reply-To'] = this.view.replyParams.inReplyTo;
Expand Down
31 changes: 24 additions & 7 deletions extension/chrome/elements/compose-modules/compose-err-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { Browser } from '../../../js/common/browser/browser.js';
import { BrowserEventErrHandler, Ui } from '../../../js/common/browser/ui.js';
import { Catch } from '../../../js/common/platform/catch.js';
import { NewMsgData, SendBtnTexts } from './compose-types.js';
import { NewMsgData, SendBtnTexts, SendMsgsResult } from './compose-types.js';
import { ApiErr } from '../../../js/common/api/shared/api-error.js';
import { BrowserExtension } from '../../../js/common/browser/browser-extension.js';
import { BrowserMsg } from '../../../js/common/browser/browser-msg.js';
Expand All @@ -27,6 +27,11 @@ export class ComposeErrModule extends ViewModule<ComposeView> {

private debugId = Str.sloppyRandom();

private static getErrSayingSomeMessagesHaveBeenSent = (sendMsgsResult: SendMsgsResult) => {
return 'Messages to some recipients were sent successfully, while messages to ' +
Str.formatEmailList(sendMsgsResult.failures.map(el => el.recipient)) + ' encountered ';
};

public handle = (couldNotDoWhat: string): BrowserEventErrHandler => {
return {
network: async () => await Ui.modal.info(`Could not ${couldNotDoWhat} (network error). Please try again.`),
Expand Down Expand Up @@ -61,22 +66,34 @@ export class ComposeErrModule extends ViewModule<ComposeView> {
}
};

public handleSendErr = async (e: any) => {
public handleSendErr = async (e: any, sendMsgsResult?: SendMsgsResult) => {
this.view.errModule.debug(`handleSendErr: ${String(e)}`);
if (ApiErr.isNetErr(e)) {
let netErrMsg = 'Could not send message due to network error. Please check your internet connection and try again.\n';
netErrMsg += '(This may also be caused by <a href="https://flowcrypt.com/docs/help/network-error.html" target="_blank">missing extension permissions</a>).';
let netErrMsg: string | undefined;
if (sendMsgsResult?.success.length) {
// there were some successful sends
netErrMsg = ComposeErrModule.getErrSayingSomeMessagesHaveBeenSent(sendMsgsResult) +
'network errors. Please check your internet connection and try again.';
} else {
netErrMsg = 'Could not send message due to network error. Please check your internet connection and try again.\n' +
'(This may also be caused by <a href="https://flowcrypt.com/docs/help/network-error.html" target="_blank">missing extension permissions</a>).';
}
await Ui.modal.error(netErrMsg, true);
} else if (ApiErr.isAuthErr(e)) {
BrowserMsg.send.notificationShowAuthPopupNeeded(this.view.parentTabId, { acctEmail: this.view.acctEmail });
Settings.offerToLoginWithPopupShowModalOnErr(this.view.acctEmail);
} else if (ApiErr.isReqTooLarge(e)) {
await Ui.modal.error(`Could not send: message or attachments too large.`);
} else if (ApiErr.isBadReq(e)) {
let gmailErrMsg: string | undefined;
if (sendMsgsResult?.success.length) {
gmailErrMsg = ComposeErrModule.getErrSayingSomeMessagesHaveBeenSent(sendMsgsResult) + 'error(s) from Gmail';
}
if (e.resMsg === AjaxErrMsgs.GOOGLE_INVALID_TO_HEADER || e.resMsg === AjaxErrMsgs.GOOGLE_RECIPIENT_ADDRESS_REQUIRED) {
await Ui.modal.error('Error from google: Invalid recipients\n\nPlease remove recipients, add them back and re-send the message.');
await Ui.modal.error((gmailErrMsg || 'Error from google') + ': Invalid recipients\n\nPlease remove recipients, add them back and re-send the message.');
} else {
if (await Ui.modal.confirm(`Google returned an error when sending message. Please help us improve FlowCrypt by reporting the error to us.`)) {
if (await Ui.modal.confirm((gmailErrMsg || 'Google returned an error when sending message') +
`. Please help us improve FlowCrypt by reporting the error to us.`)) {
const page = '/chrome/settings/modules/help.htm';
const pageUrlParams = { bugReport: BrowserExtension.prepareBugReport(`composer: send: bad request (errMsg: ${e.resMsg})`, {}, e) };
await Browser.openSettingsPage('index.htm', this.view.acctEmail, page, pageUrlParams);
Expand Down Expand Up @@ -126,7 +143,7 @@ export class ComposeErrModule extends ViewModule<ComposeView> {
if (!subject && ! await Ui.modal.confirm('Send without a subject?')) {
throw new ComposerResetBtnTrigger();
}
let footer = await this.view.footerModule.getFooterFromStorage(from);
let footer = await this.view.footerModule.getFooterFromStorage(from.email);
if (footer) { // format footer the way it would be in outgoing plaintext
footer = Xss.htmlUnescape(Xss.htmlSanitizeAndStripAllTags(this.view.footerModule.createFooterHtml(footer), '\n')).trim();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ export class ComposeInputModule extends ViewModule<ComposeView> {
return this.view.S.cached('fineuploader').find('.qq-upload-file').toArray().map((el) => $(el).text().trim());
};

public extractAll = (): NewMsgData => {
public extractAll = async (): Promise<NewMsgData> => {
const recipients = this.mapRecipients(this.view.recipientsModule.getValidRecipients());
const subject = this.view.isReplyBox && this.view.replyParams ? this.view.replyParams.subject : String($('#input_subject').val() || '');
const plaintext = this.view.inputModule.extract('text', 'input_text');
const plainhtml = this.view.inputModule.extract('html', 'input_text');
const password = this.view.S.cached('input_password').val();
const pwd = typeof password === 'string' && password ? password : undefined;
const from = this.view.senderModule.getSender();
const from = await this.view.storageModule.getEmailWithOptionalName(this.view.senderModule.getSender());
return { recipients, subject, plaintext, plainhtml, pwd, from };
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

'use strict';

import { ChunkedCb, EmailProviderContact, RecipientType } from '../../../js/common/api/shared/api.js';
import { Api, ChunkedCb, EmailProviderContact, RecipientType } from '../../../js/common/api/shared/api.js';
import { ContactInfoWithSortedPubkeys, KeyUtil, PubkeyInfo } from '../../../js/common/core/crypto/key.js';
import { PUBKEY_LOOKUP_RESULT_FAIL } from './compose-err-module.js';
import { ProviderContactsQuery, Recipients } from '../../../js/common/api/email-provider/email-provider-api.js';
Expand Down Expand Up @@ -160,9 +160,8 @@ export class ComposeRecipientsModule extends ViewModule<ComposeView> {

public addRecipients = async (recipients: Recipients, triggerCallback: boolean = true) => {
const newRecipients: ValidRecipientElement[] = [];
for (const [key, value] of Object.entries(recipients)) {
if (['to', 'cc', 'bcc'].includes(key)) {
const sendingType = key as RecipientType;
for (const [sendingType, value] of Object.entries(recipients)) {
if (Api.isRecipientHeaderNameType(sendingType)) {
if (value?.length) {
const recipientsContainer = this.view.S.cached('input_addresses_container_outer').find(`#input-container-${sendingType}`);
for (const email of value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import { BrowserMsg } from '../../../js/common/browser/browser-msg.js';
import { Catch } from '../../../js/common/platform/catch.js';
import { KeyImportUi } from '../../../js/common/ui/key-import-ui.js';
import { Lang } from '../../../js/common/lang.js';
import { Recipients } from '../../../js/common/api/email-provider/email-provider-api.js';
import { SendableMsg } from '../../../js/common/api/email-provider/sendable-msg.js';
import { ParsedRecipients, Recipients } from '../../../js/common/api/email-provider/email-provider-api.js';
import { Str } from '../../../js/common/core/common.js';
import { Ui } from '../../../js/common/browser/ui.js';
import { Xss } from '../../../js/common/platform/xss.js';
Expand Down Expand Up @@ -114,7 +113,7 @@ export class ComposeRenderModule extends ViewModule<ComposeView> {
}
};

public renderReplySuccess = (msg: SendableMsg, msgId: string) => {
public renderReplySuccess = (attachments: Attachment[], recipients: ParsedRecipients, msgId: string) => {
this.view.renderModule.renderReinsertReplyBox(msgId);
if (!this.view.sendBtnModule.popover.choices.encrypt) {
this.view.S.cached('replied_body').removeClass('pgp_secure');
Expand All @@ -125,13 +124,13 @@ export class ComposeRenderModule extends ViewModule<ComposeView> {
this.view.S.cached('replied_body').css('width', ($('table#compose').width() || 500) - 30);
this.view.S.cached('compose_table').css('display', 'none');
this.view.S.cached('reply_msg_successful').find('div.replied_from').text(this.view.senderModule.getSender());
this.view.S.cached('reply_msg_successful').find('div.replied_to span').text(msg.headers.To.replace(/,/g, ', '));
if (msg.recipients.cc !== undefined && msg.recipients.cc.length > 0) {
this.view.S.cached('reply_msg_successful').find('div.replied_cc span').text(msg.recipients.cc.join(', '));
this.view.S.cached('reply_msg_successful').find('div.replied_to span').text(Str.formatEmailList(recipients.to || []));
if (recipients.cc !== undefined && recipients.cc.length > 0) {
this.view.S.cached('reply_msg_successful').find('div.replied_cc span').text(Str.formatEmailList(recipients.cc));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fixes #4497

$('.replied_cc').show();
}
if (msg.recipients.bcc !== undefined && msg.recipients.bcc.length > 0) {
this.view.S.cached('reply_msg_successful').find('div.replied_bcc span').text(msg.recipients.bcc.join(', '));
if (recipients.bcc !== undefined && recipients.bcc.length > 0) {
this.view.S.cached('reply_msg_successful').find('div.replied_bcc span').text(Str.formatEmailList(recipients.bcc));
$('.replied_bcc').show();
}
const repliedBodyEl = this.view.S.cached('reply_msg_successful').find('div.replied_body');
Expand All @@ -141,7 +140,7 @@ export class ComposeRenderModule extends ViewModule<ComposeView> {
this.renderReplySuccessMimeAttachments(this.view.inputModule.extractAttachments());
} else {
Xss.sanitizeRender(repliedBodyEl, Str.escapeTextAsRenderableHtml(this.view.inputModule.extract('text', 'input_text', 'SKIP-ADDONS')));
this.renderReplySuccessAttachments(msg.attachments, msgId, this.view.sendBtnModule.popover.choices.encrypt);
this.renderReplySuccessAttachments(attachments, msgId, this.view.sendBtnModule.popover.choices.encrypt);
}
const t = new Date();
const time = ((t.getHours() !== 12) ? (t.getHours() % 12) : 12) + ':' + (t.getMinutes() < 10 ? '0' : '') + t.getMinutes() + ((t.getHours() >= 12) ? ' PM ' : ' AM ') + '(0 minutes ago)';
Expand Down
Loading