mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-04 04:41:35 +00:00
Handle user error in update labels (#412)
* Get only required fields when processing messages * Handle customer id in group add/delete/sync/clear I always wondered what this was: if user_email != u'*' * Allow * to mean all users in group operations * Make pylon happy, handle user error in update labels
This commit is contained in:
@@ -4714,7 +4714,7 @@ def doProcessMessagesOrThreads(users, function, unit=u'messages'):
|
|||||||
for my_key in body:
|
for my_key in body:
|
||||||
kwargs[u'body'][my_key] = labelsToLabelIds(gmail, body[my_key])
|
kwargs[u'body'][my_key] = labelsToLabelIds(gmail, body[my_key])
|
||||||
if not kwargs[u'body']:
|
if not kwargs[u'body']:
|
||||||
del(kwargs[u'body'])
|
del kwargs[u'body']
|
||||||
i = 0
|
i = 0
|
||||||
if unit == u'messages' and function in [u'delete', u'modify']:
|
if unit == u'messages' and function in [u'delete', u'modify']:
|
||||||
batchFunction = u'batch%s' % function.title()
|
batchFunction = u'batch%s' % function.title()
|
||||||
@@ -4963,7 +4963,11 @@ def renameLabels(users):
|
|||||||
continue
|
continue
|
||||||
match_result = re.search(pattern, label[u'name'])
|
match_result = re.search(pattern, label[u'name'])
|
||||||
if match_result is not None:
|
if match_result is not None:
|
||||||
|
try:
|
||||||
new_label_name = replace % match_result.groups()
|
new_label_name = replace % match_result.groups()
|
||||||
|
except TypeError:
|
||||||
|
print u'ERROR: The number of subfields ({0}) in search "{1}" does not match the number of subfields ({2}) in replace "{3}"'.format(len(match_result.groups()), search, replace.count(u'%s'), replace)
|
||||||
|
sys.exit(2)
|
||||||
print u' Renaming "%s" to "%s"' % (label[u'name'], new_label_name)
|
print u' Renaming "%s" to "%s"' % (label[u'name'], new_label_name)
|
||||||
try:
|
try:
|
||||||
callGAPI(gmail.users().labels(), u'patch', soft_errors=True, throw_reasons=[u'aborted'], id=label[u'id'], userId=user, body={u'name': new_label_name})
|
callGAPI(gmail.users().labels(), u'patch', soft_errors=True, throw_reasons=[u'aborted'], id=label[u'id'], userId=user, body={u'name': new_label_name})
|
||||||
|
|||||||
Reference in New Issue
Block a user