firemail

标题: MailSpring源码分析--同步邮件 重试 邮件数据的处理 [打印本页]

作者: Qter    时间: 2020-10-12 15:27
标题: MailSpring源码分析--同步邮件 重试 邮件数据的处理
本帖最后由 Qter 于 2020-10-13 18:09 编辑

  1. app\internal_packages\notifications\lib\items\account-error-notif.tsx
  2. this._onCheckAgain([erroredAccount]),
  3.   _onCheckAgain(accounts) {
  4.   accounts.forEach(acct => AppEnv.mailsyncBridge.forceRelaunchClient(acct));
  5.   }
  6.   

  7. app\src\flux\mailsync-bridge.ts
  8. async forceRelaunchClient(account: Account) {
  9.   const keys = await KeyManager._getKeyHash();
  10.   this._launchClient(account, keys, { force: true });
  11. }

  12. async _launchClient(account: Account, keys, { force }: { force?: boolean } = {}) {
  13.   const client = new MailsyncProcess(this._getClientConfiguration());
  14.     const fullAccountJSON = (await KeyManager.insertAccountSecrets(account, keys)).toJSON();
  15.    client.account = fullAccountJSON;
  16.     client.identity = IdentityStore.identity();
  17.     client.sync();
  18.     client.on('deltas', this._onIncomingMessages);
  19. }

  20. _onIncomingMessages = msgs => {
  21. for (const msg of msgs) {
  22.       const models = modelJSONs.map(Utils.convertToModel);
  23.       this._onIncomingChangeRecord(
  24.         new DatabaseChangeRecord({
  25.           type, // TODO BG move to "model" naming style, finding all uses might be tricky
  26.           objectClass: modelClass,
  27.           objects: models,
  28.           objectsRawJSON: modelJSONs,
  29.         })
  30.       );
  31. }
  32. }

  33. app\src\mailsync-process.ts
  34. sync() {
  35. this._spawnProcess('sync');
  36.   const msgs = outBuffer.split('\n');
  37.           outBuffer = msgs.pop();
  38.           this.emit('deltas', msgs);
  39. }
复制代码





欢迎光临 firemail (http://firemail.wang:8088/) Powered by Discuz! X3