From 35d61da0a0ac62caaf5cc5f0aa910fe43c89de4b Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Fri, 20 Jun 2025 10:21:32 -0700 Subject: [PATCH] Added option `labelids ` to all commands that process messages --- src/GamCommands.txt | 18 ++++++++++++++++-- src/GamUpdate.txt | 3 +++ src/gam/__init__.py | 6 +++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/GamCommands.txt b/src/GamCommands.txt index 2b636b0d..e964b476 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -7615,48 +7615,61 @@ gam insert message gam archive messages (((query [querytime ]*) (matchlabel ) [or|and])+ + [labelids ] [quick|notquick] [doit] [max_to_archive ])|(ids ) [csv [todrive *]] gam delete messages|threads (((query [querytime ]*) (matchlabel ) [or|and])+ + [labelids ] [quick|notquick] [doit] [max_to_delete ])|(ids ) [csv [todrive *]] gam modify messages|threads (((query [querytime ]*) (matchlabel ) [or|and])+ + [labelids ] [quick|notquick] [doit] [max_to_modify ])|(ids ) ((addlabel )|(removelabel ))+ [csv [todrive *]] gam spam messages|threads (((query [querytime ]*) (matchlabel ) [or|and])+ + [labelids ] [quick|notquick] [doit] [max_to_spam ])|(ids ) [csv [todrive *]] gam trash messages|threads (((query [querytime ]*) (matchlabel ) [or|and])+ + [labelids ] [quick|notquick] [doit] [max_to_trash ])|(ids ) [csv [todrive *]] gam untrash messages|threads (((query [querytime ]*) (matchlabel ) [or|and])+ + [labelids ] [quick|notquick] [doit] [max_to_untrash ])|(ids ) [csv [todrive *]] gam export message|messages - (((query [querytime ]*) (matchlabel ) [or|and])+ [quick|notquick] [doit] [max_to_export ])|(ids ) + (((query [querytime ]*) (matchlabel ) [or|and])+ + [labelids ] + [quick|notquick] [doit] [max_to_export ])|(ids ) [targetfolder ] [targetname ] [overwrite []] gam export thread|threads - (((query [querytime ]*) (matchlabel ) [or|and])+ [quick|notquick] [doit] [max_to_export ])|(ids ) + (((query [querytime ]*) (matchlabel ) [or|and])+ + [labelids ] + [quick|notquick] [doit] [max_to_export ])|(ids ) [targetfolder ] [targetname ] [overwrite []] gam forward message|messages recipient|to (((query [querytime ]*) (matchlabel ) [or|and])+ + [labelids ] [quick|notquick] [doit] [max_to_forward ])|(ids ) [subject ] [addorigfieldstosubject []] [altcharset ] gam forward thread|thtreads recipient|to (((query [querytime ]*) (matchlabel ) [or|and])+ + [labelids ] quick|notquick] [doit] [max_to_forward ])|(ids ) [subject ] [addorigfieldstosubject []] [altcharset ] gam show messages|threads (((query [querytime ]*) (matchlabel ) [or|and])* + [labelids ] [quick|notquick] [max_to_show ] [includespamtrash])|(ids ) [labelmatchpattern ] [sendermatchpattern ] [countsonly|positivecountsonly] [useronly] @@ -7669,6 +7682,7 @@ gam show messages|threads [uploadattachments []]] gam print messages|threads [todrive *] (((query [querytime ]*) (matchlabel ) [or|and])* + [labelids ] [quick|notquick] [max_to_print ] [includespamtrash])|(ids ) [labelmatchpattern ] [sendermatchpattern ] [countsonly|positivecountsonly] [useronly] diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index d333b14c..be0fd877 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -1,5 +1,8 @@ 7.10.02 +Added option `labelids ` to all commands that process messages; +this option causes GAM to only return messages with labels that match all of the specified label IDs. + Updated `gam print|show forms` to always display `isPublished` and `isAcceptingResponses` in `publishSettings/publishState` regardless of their value; the API doesn't return these values when they are False. diff --git a/src/gam/__init__.py b/src/gam/__init__.py index 1638f473..ec451af5 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -70133,6 +70133,7 @@ def _initMessageThreadParameters(entityType, doIt, maxToProcess): 'query': '', 'queryTimes': {}, 'entityType': entityType, 'messageEntity': None, 'doIt': doIt, 'quick': True, 'labelMatchPattern': None, 'senderMatchPattern': None, + 'labelIds': [], 'maxToProcess': maxToProcess, 'maxItems': 0, 'maxMessagesPerThread': 0, 'maxToKeywords': [MESSAGES_MAX_TO_KEYWORDS[Act.Get()], 'maxtoprocess'], 'listType': listType, 'fields': f'nextPageToken,{listType}(id)'} @@ -70165,6 +70166,8 @@ def _getMessageSelectParameters(myarg, parameters): parameters['labelMatchPattern'] = getREPattern(re.IGNORECASE) elif myarg == 'sendermatchpattern': parameters['senderMatchPattern'] = getREPattern(re.IGNORECASE) + elif myarg == 'labelids': + parameters['labelIds'].extend(getEntityList(Cmd.OB_LABEL_ID_LIST)) elif myarg == 'ids': parameters['messageEntity'] = getUserObjectEntity(Cmd.OB_MESSAGE_ID, parameters['entityType']) elif myarg == 'quick': @@ -71809,7 +71812,8 @@ def printShowMessagesThreads(users, entityType): listResult = callGAPIpages(service, 'list', parameters['listType'], pageMessage=getPageMessageForWhom(), maxItems=parameters['maxItems'], throwReasons=GAPI.GMAIL_THROW_REASONS+GAPI.GMAIL_LIST_THROW_REASONS, - userId='me', q=parameters['query'], fields=parameters['fields'], includeSpamTrash=includeSpamTrash, + userId='me', q=parameters['query'], labelIds=parameters['labelIds'], + fields=parameters['fields'], includeSpamTrash=includeSpamTrash, maxResults=GC.Values[GC.MESSAGE_MAX_RESULTS]) messageIds = [message['id'] for message in listResult] else: