Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ranmocy/gmail-automata
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a6fb5b255a69b709915994ddbc099182cb2cb7ac
Choose a base ref
..
head repository: ranmocy/gmail-automata
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3e6fa8d860390e60d56b34283612bb0e0b1cc3a9
Choose a head ref
Showing with 8 additions and 0 deletions.
  1. +8 −0 index.ts
8 changes: 8 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -77,6 +77,12 @@ if (typeof Object.assign !== 'function') {

// Top level functions

function ensurePermissionsEstablished() {
// Some Gmail configurations do not initiate asking for Gmail
// permissions when Gmail APIs are used behind withTimer(). See Issue#63.
Session.getActiveUser();
}

// Triggered when Spreadsheet is opened
// noinspection JSUnusedGlobalSymbols
function onOpen(e: { authMode: GoogleAppsScript.Script.AuthMode }) {
@@ -100,6 +106,7 @@ function onOpen(e: { authMode: GoogleAppsScript.Script.AuthMode }) {

// Triggered when time-driven trigger or click via Spreadsheet menu
function processEmails() {
ensurePermissionsEstablished();
Utils.withFailureEmailed("processEmails", () => Processor.processAllUnprocessedThreads());
}

@@ -110,6 +117,7 @@ function sanityChecking() {
}

function setupTriggers() {
ensurePermissionsEstablished();
cancelTriggers();

Utils.withFailureEmailed("setupTriggers", () => {