mirror of
https://github.com/GAM-team/GAM.git
synced 2025-07-10 06:33:34 +00:00
Do not get settings for special groups abuse and postmaster (#334)
* In gam print groups settings, get gs service outside of loop * Do not get settings for special groups abuse and postmaster * Do not set settings for special groups abuse and postmaster
This commit is contained in:
21
src/gam.py
21
src/gam.py
@ -7019,6 +7019,9 @@ def doCreateUser():
|
|||||||
print u' Changing admin status for %s to %s' % (body[u'primaryEmail'], admin_body[u'status'])
|
print u' Changing admin status for %s to %s' % (body[u'primaryEmail'], admin_body[u'status'])
|
||||||
callGAPI(cd.users(), u'makeAdmin', userKey=body[u'primaryEmail'], body=admin_body)
|
callGAPI(cd.users(), u'makeAdmin', userKey=body[u'primaryEmail'], body=admin_body)
|
||||||
|
|
||||||
|
def GroupIsAbuseOrPostmaster(emailAddr):
|
||||||
|
return emailAddr.startswith(u'abuse@') or emailAddr.startswith(u'postmaster@')
|
||||||
|
|
||||||
def doCreateGroup():
|
def doCreateGroup():
|
||||||
cd = buildGAPIObject(u'directory')
|
cd = buildGAPIObject(u'directory')
|
||||||
body = {u'email': sys.argv[3]}
|
body = {u'email': sys.argv[3]}
|
||||||
@ -7077,7 +7080,7 @@ def doCreateGroup():
|
|||||||
body[u'name'] = body[u'email']
|
body[u'name'] = body[u'email']
|
||||||
print u"Creating group %s" % body[u'email']
|
print u"Creating group %s" % body[u'email']
|
||||||
callGAPI(cd.groups(), u'insert', body=body, fields=u'email')
|
callGAPI(cd.groups(), u'insert', body=body, fields=u'email')
|
||||||
if gs:
|
if gs and not GroupIsAbuseOrPostmaster(body[u'email']):
|
||||||
callGAPI(gs.groups(), u'patch', retry_reasons=[u'serviceLimit'], groupUniqueId=body[u'email'], body=gs_body)
|
callGAPI(gs.groups(), u'patch', retry_reasons=[u'serviceLimit'], groupUniqueId=body[u'email'], body=gs_body)
|
||||||
|
|
||||||
def doCreateAlias():
|
def doCreateAlias():
|
||||||
@ -7375,7 +7378,8 @@ def doUpdateGroup():
|
|||||||
if gs:
|
if gs:
|
||||||
if use_cd_api:
|
if use_cd_api:
|
||||||
group = cd_result[u'email']
|
group = cd_result[u'email']
|
||||||
callGAPI(gs.groups(), u'patch', retry_reasons=[u'serviceLimit'], groupUniqueId=group, body=gs_body)
|
if not GroupIsAbuseOrPostmaster(group):
|
||||||
|
callGAPI(gs.groups(), u'patch', retry_reasons=[u'serviceLimit'], groupUniqueId=group, body=gs_body)
|
||||||
print u'updated group %s' % group
|
print u'updated group %s' % group
|
||||||
|
|
||||||
def doUpdateAlias():
|
def doUpdateAlias():
|
||||||
@ -7894,11 +7898,12 @@ def doGetGroupInfo(group_name=None):
|
|||||||
elif group_name.find(u'@') == -1:
|
elif group_name.find(u'@') == -1:
|
||||||
group_name = group_name+u'@'+GC_Values[GC_DOMAIN]
|
group_name = group_name+u'@'+GC_Values[GC_DOMAIN]
|
||||||
basic_info = callGAPI(cd.groups(), u'get', groupKey=group_name)
|
basic_info = callGAPI(cd.groups(), u'get', groupKey=group_name)
|
||||||
try:
|
if not GroupIsAbuseOrPostmaster(basic_info[u'email']):
|
||||||
settings = callGAPI(gs.groups(), u'get', retry_reasons=[u'serviceLimit'], throw_reasons=u'authError',
|
try:
|
||||||
groupUniqueId=basic_info[u'email']) # Use email address retrieved from cd since GS API doesn't support uid
|
settings = callGAPI(gs.groups(), u'get', retry_reasons=[u'serviceLimit'], throw_reasons=u'authError',
|
||||||
except googleapiclient.errors.HttpError:
|
groupUniqueId=basic_info[u'email']) # Use email address retrieved from cd since GS API doesn't support uid
|
||||||
pass
|
except googleapiclient.errors.HttpError:
|
||||||
|
pass
|
||||||
print u''
|
print u''
|
||||||
print u'Group Settings:'
|
print u'Group Settings:'
|
||||||
for key, value in basic_info.items():
|
for key, value in basic_info.items():
|
||||||
@ -9182,7 +9187,7 @@ def doPrintGroups():
|
|||||||
group[u'Managers'] = memberDelimiter.join(allManagers)
|
group[u'Managers'] = memberDelimiter.join(allManagers)
|
||||||
if owners:
|
if owners:
|
||||||
group[u'Owners'] = memberDelimiter.join(allOwners)
|
group[u'Owners'] = memberDelimiter.join(allOwners)
|
||||||
if getSettings:
|
if getSettings and not GroupIsAbuseOrPostmaster(groupEmail):
|
||||||
sys.stderr.write(u" Retrieving Settings for group %s (%s/%s)...\r\n" % (groupEmail, i, count))
|
sys.stderr.write(u" Retrieving Settings for group %s (%s/%s)...\r\n" % (groupEmail, i, count))
|
||||||
settings = callGAPI(gs.groups(), u'get',
|
settings = callGAPI(gs.groups(), u'get',
|
||||||
retry_reasons=[u'serviceLimit'],
|
retry_reasons=[u'serviceLimit'],
|
||||||
|
Reference in New Issue
Block a user