From 83d464d16780bf71cffb8b2974eafad1d6c5789a Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Tue, 2 Apr 2024 10:38:35 -0700 Subject: [PATCH] Updated commands that send emails to not downshift `'First Last'` --- docs/GamUpdates.md | 4 ++ docs/How-to-Upgrade-from-Standard-GAM.md | 4 +- docs/Version-and-Help.md | 12 ++-- src/GamUpdate.txt | 4 ++ src/gam/__init__.py | 30 ++++----- src/gam/googleapiclient/discovery.py | 80 +++++++++++++++++++++++- src/gam/googleapiclient/version.py | 2 +- 7 files changed, 108 insertions(+), 28 deletions(-) diff --git a/docs/GamUpdates.md b/docs/GamUpdates.md index 6ac070f1..97ea9f70 100644 --- a/docs/GamUpdates.md +++ b/docs/GamUpdates.md @@ -10,6 +10,10 @@ Add the `-s` option to the end of the above commands to suppress creating the `g See [Downloads](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads) for Windows or other options, including manual installation +### 6.72.07 + +Updated commands that send emails to not downshift `'First Last'` to `'first last'`. + ### 6.72.06 Updated the following commands to properly handle emailaddress lists containing addresses of the form: `'First Last'`. diff --git a/docs/How-to-Upgrade-from-Standard-GAM.md b/docs/How-to-Upgrade-from-Standard-GAM.md index ad62aa0d..2a1a89e2 100644 --- a/docs/How-to-Upgrade-from-Standard-GAM.md +++ b/docs/How-to-Upgrade-from-Standard-GAM.md @@ -334,7 +334,7 @@ writes the credentials into the file oauth2.txt. admin@server:/Users/admin/bin/gamadv-xtd3$ rm -f /Users/admin/GAMConfig/oauth2.txt admin@server:/Users/admin/bin/gamadv-xtd3$ ./gam version WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found -GAMADV-XTD3 6.72.06 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.72.07 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.2 64-bit final MacOS Sonoma 14.2.1 x86_64 @@ -1006,7 +1006,7 @@ writes the credentials into the file oauth2.txt. C:\GAMADV-XTD3>del C:\GAMConfig\oauth2.txt C:\GAMADV-XTD3>gam version WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found -GAMADV-XTD3 6.72.06 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.72.07 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.2 64-bit final Windows-10-10.0.17134 AMD64 diff --git a/docs/Version-and-Help.md b/docs/Version-and-Help.md index d59e5926..219db774 100644 --- a/docs/Version-and-Help.md +++ b/docs/Version-and-Help.md @@ -3,7 +3,7 @@ Print the current version of Gam with details ``` gam version -GAMADV-XTD3 6.72.06 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.72.07 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.2 64-bit final MacOS Sonoma 14.2.1 x86_64 @@ -15,7 +15,7 @@ Time: 2023-06-02T21:10:00-07:00 Print the current version of Gam with details and time offset information ``` gam version timeoffset -GAMADV-XTD3 6.72.06 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.72.07 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.2 64-bit final MacOS Sonoma 14.2.1 x86_64 @@ -27,7 +27,7 @@ Your system time differs from www.googleapis.com by less than 1 second Print the current version of Gam with extended details and SSL information ``` gam version extended -GAMADV-XTD3 6.72.06 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.72.07 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.2 64-bit final MacOS Sonoma 14.2.1 x86_64 @@ -64,7 +64,7 @@ MacOS High Sierra 10.13.6 x86_64 Path: /Users/Admin/bin/gamadv-xtd3 Version Check: Current: 5.35.08 - Latest: 6.72.06 + Latest: 6.72.07 echo $? 1 ``` @@ -72,7 +72,7 @@ echo $? Print the current version number without details ``` gam version simple -6.72.06 +6.72.07 ``` In Linux/MacOS you can do: ``` @@ -82,7 +82,7 @@ echo $VER Print the current version of Gam and address of this Wiki ``` gam help -GAM 6.72.06 - https://github.com/taers232c/GAMADV-XTD3 +GAM 6.72.07 - https://github.com/taers232c/GAMADV-XTD3 Ross Scroggs Python 3.12.2 64-bit final MacOS Sonoma 14.2.1 x86_64 diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index bf3539a3..864be73b 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -2,6 +2,10 @@ Merged GAM-Team version +6.72.07 + +Updated commands that send emails to not downshift `'First Last'` to `'first last'`. + 6.72.06 Updated the following commands to properly handle emailaddress lists containing addresses of the form: `'First Last'`. diff --git a/src/gam/__init__.py b/src/gam/__init__.py index f4a276f8..b1f8469e 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -6975,8 +6975,8 @@ def getEntityList(item, shlexSplit=False): return getEntitySelection(entitySelector, shlexSplit) return convertEntityToList(getString(item, minLen=0), shlexSplit=shlexSplit) -def getNormalizedEmailAddressEntity(shlexSplit=False, noUid=True): - return [normalizeEmailAddressOrUID(emailAddress, noUid) for emailAddress in getEntityList(Cmd.OB_EMAIL_ADDRESS_ENTITY, shlexSplit)] +def getNormalizedEmailAddressEntity(shlexSplit=False, noUid=True, noLower=False): + return [normalizeEmailAddressOrUID(emailAddress, noUid=noUid, noLower=noLower) for emailAddress in getEntityList(Cmd.OB_EMAIL_ADDRESS_ENTITY, shlexSplit)] def getUserObjectEntity(clObject, itemType, shlexSplit=False): entity = {'item': itemType, 'list': getEntityList(clObject, shlexSplit), 'dict': None} @@ -7136,7 +7136,7 @@ def send_email(msgSubject, msgBody, msgTo, i=0, count=0, clientAccess=False, msg message[header] = value if mailBox is None: mailBox = msgFrom - mailBoxAddr = normalizeEmailAddressOrUID(cleanAddr(mailBox), noUid=True) + mailBoxAddr = normalizeEmailAddressOrUID(cleanAddr(mailBox), noUid=True, noLower=True) action = Act.Get() Act.Set(Act.SENDEMAIL) if not GC.Values[GC.SMTP_HOST]: @@ -7147,7 +7147,7 @@ def send_email(msgSubject, msgBody, msgTo, i=0, count=0, clientAccess=False, msg else: userId = mailBoxAddr gmail = buildGAPIObject(API.GMAIL) - message['To'] = (msgTo if msgTo else userId).lower() + message['To'] = msgTo if msgTo else userId try: result = callGAPI(gmail.users().messages(), 'send', throwReasons=[GAPI.SERVICE_NOT_AVAILABLE, GAPI.AUTH_ERROR, GAPI.DOMAIN_POLICY, @@ -7158,7 +7158,7 @@ def send_email(msgSubject, msgBody, msgTo, i=0, count=0, clientAccess=False, msg GAPI.invalid, GAPI.invalidArgument, GAPI.forbidden, GAPI.permissionDenied) as e: entityActionFailedWarning([Ent.RECIPIENT, msgTo, Ent.MESSAGE, msgSubject], str(e), i, count) else: - message['To'] = (msgTo if msgTo else mailBoxAddr).lower() + message['To'] = msgTo if msgTo else mailBoxAddr server = None try: server = smtplib.SMTP(GC.Values[GC.SMTP_HOST], 587, GC.Values[GC.SMTP_FQDN]) @@ -14504,6 +14504,12 @@ def sendCreateUpdateUserNotification(body, basenotify, tagReplacements, i=0, cou send_email(notify['subject'], notify['message'], recipient, i, count, msgFrom=msgFrom, msgReplyTo=msgReplyTo, html=notify['html'], charset=notify['charset'], mailBox=mailBox) +def getRecipients(): + if checkArgumentPresent('select'): + _, recipients = getEntityToModify(defaultEntityType=Cmd.ENTITY_USERS) + return [normalizeEmailAddressOrUID(emailAddress, noUid=True, noLower=True) for emailAddress in recipients] + return getNormalizedEmailAddressEntity(shlexSplit=True, noLower=True) + # gam sendemail [recipient|to] [from ] [mailbox ] [replyto ] # [cc ] [bcc ] [singlemessage] # [subject ] @@ -14529,12 +14535,6 @@ def sendCreateUpdateUserNotification(body, basenotify, tagReplacements, i=0, cou # [newuser firstname|givenname lastname|familyname password ] # (