gmail-processor icon indicating copy to clipboard operation
gmail-processor copied to clipboard

User Rate Limit Reached

Open verneide opened this issue 4 years ago • 3 comments

I'm getting a user/rate limited reached. I believe its because I have an email with attachment that shows up in the inbox every hour, then the script is run every 30 minutes. Looking at the log, it processes all the messages in the thread instead of just the most recent one. So if its hour 12 of the day, it is going to process the last 12 attachments. Is there any way to make it only process the last message and not all the messages in the thread?

Thanks.

verneide avatar Apr 21 '20 18:04 verneide

HI @verneide , you have thread growing up forever with a new email every hour?

maxsnet avatar May 13 '20 20:05 maxsnet

Yes, I have a report emailed to my dedicated inbox each hour. The file then gets updated in Google Drive upon the email. But when I look at the triggered execution the time elapsed is very long. Looking at the log, it seems to go through every email within the thread but saving the last one. So for example, as it goes through the day it on hour 20 it would go through 20 emails. I even tried to program in a trash/archive after the attachement is saved but still wants to look at the whole thread. The only way I’ve been able to decrease the time it takes is by emptying the trash, deleting the thread for good.

From: Max Prat-Carrabin [email protected] Reply-To: ahochsteger/gmail2gdrive [email protected] Date: Wednesday, May 13, 2020 at 3:17 PM To: ahochsteger/gmail2gdrive [email protected] Cc: Chase Sabers [email protected], Mention [email protected] Subject: Re: [ahochsteger/gmail2gdrive] User Rate Limit Reached (#38)

HI @verneidehttps://github.com/verneide , you have thread growing up forever with a new email every hour?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/ahochsteger/gmail2gdrive/issues/38#issuecomment-628222434, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJQ4FMYCBEA6IDHJM3QALY3RRL533ANCNFSM4MNQT32A.

verneide avatar May 13 '20 21:05 verneide

@verneide you can avoid taking messages in the trash, cf following updates of

  • function processThreadToHtml (replace with below)
  • function Gmail2Drive (update from // Process all messages of a thread: until // Mark a thread as processed
function processThreadToHtml(thread) {
  Logger.log("INFO:   Generating HTML code of thread '" + thread.getFirstMessageSubject() + "'");
  var messages = thread.getMessages();
  var html = "";
  for (var msgIdx=0; msgIdx<messages.length; msgIdx++) {
    var message = messages[msgIdx];
    var message_isintrash = message.isInTrash();
    Logger.log("INFO:     Message in trash:" + message_isintrash );
        if ( message_isintrash !== true ) {
          Logger.log("INFO:     Message not in trash: processing." );
          html += "From: " + message.getFrom() + "<br />\n";
          html += "To: " + message.getTo() + "<br />\n";
          html += "Date: " + message.getDate() + "<br />\n";
          html += "Subject: " + message.getSubject() + "<br />\n";
          html += "<hr />\n";
          html += message.getBody() + "\n";
          html += "<hr />\n";
         }        
      }
  return html;
}
      // Process all messages of a thread:
      var messages = thread.getMessages();
      for (var msgIdx=0; msgIdx<messages.length; msgIdx++) {
        var message = messages[msgIdx];
        var message_isintrash = message.isInTrash();
        Logger.log("INFO:     Message in trash:" + message_isintrash );
        if (  message_isintrash !== true ) { processMessage(message, rule, config); }        
      }
      if (doPDF) { // Generate a PDF document of a thread:
        processThreadToPdf(thread, rule);
      }

This is what I have done in my pull request.

Does that solve your issue ?

maxsnet avatar May 14 '20 14:05 maxsnet

I'm closing this issue since GMail2GDrive is discontinued and has been superseded by the much improved Gmail Processor. It provides a way to process threads with multiple emails to solve this issue. See the Getting Started Guide as well as the Reference Docs for more information

ahochsteger avatar Sep 20 '23 20:09 ahochsteger