Mail merge sample silently picks the first draft when several drafts share the subject

オープン 初心者向け
#666 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript
領域
backend

調査の方向性

solutions/automations/mail-merge/Code.js の getGmailTemplateFromDrafts_() から始め、sendEmails() が選択された下書きをどのように処理するかを追ってください。Gmail と Sheets のテストダブルを使うテストを追加するか、既存のテストを見つけてください。条件に一致する下書きが2件ある場合は送信呼び出しが0回となり、1件の場合は通常どおり送信されることを確認してください。一致する下書きが複数ある場合に送信前に処理を止め、一意の件名を求めるメッセージを表示すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

getGmailTemplateFromDrafts_() in solutions/automations/mail-merge/Code.js selects the template with:

const draft = drafts.filter(subjectFilter_(subject_line))[0];

If the sender has two drafts with the same subject, for example an internal and a customer version of "Monthly update", the script uses whichever Gmail returns first, with its body and attachments, for every row in the sheet. Nothing tells the sender a choice was made.

We ran sendEmails() with Gmail and Sheets replaced by test doubles, using two drafts with the same subject and different attachments. Reversing the draft order changed which body and attachment went to every recipient. No real email was sent.

Proposed change: count the matching drafts and stop before sending if there is more than one, with a message asking the sender to make the subject unique. A test would check that two matches lead to zero send calls and one match sends normally.

Happy to send a pull request if this approach works for you.

— Emails.help

主要言語
JavaScript
スター
5.3k
フォーク
2k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

googleworkspace/apps-script-samples のほかの issue

googleworkspace/apps-script-samples の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。