Skip to content
Snippets Groups Projects
Verified Commit d14190e9 authored by nd's avatar nd
Browse files

handle multiple mail addresses and cancle any subscription requests for...

handle multiple mail addresses and cancle any subscription requests for addresses we try to subscribe
parent 1fef9503
No related branches found
No related tags found
No related merge requests found
......@@ -83,20 +83,25 @@ class Command(BaseCommand):
# user might not be subscribed but should be subscribed -> subscribe
# we do not test if he is subscibed already because the mailman api is inconsistent and reports wrong state information for this...
# instead we always try to subscribe and catch the error if we are subscribed already
user_mail = mm_user.addresses[0].email
if membership_type == 'member':
mm_list.subscribe(user_mail,
display_name=displayname,
pre_verified=True,
pre_confirmed=True,
pre_approved=True)
elif membership_type == 'moderator':
mm_list.add_moderator(user_mail,
display_name=displayname)
elif membership_type == 'owner':
mm_list.add_moderator(user_mail,
display_name=displayname)
logger.warning("subscribe {} ( {} ) as {} on {}".format(username, user_mail, membership_type, list_name))
for address in mm_user.addresses[0]:
user_mail = address.email
if membership_type == 'member':
# discard a subscription request before trying to subscribe else it will fail
for request in mm_list.requests:
if request['email'] == user_mail:
mm_list.discard_request(request['token'])
mm_list.subscribe(user_mail,
display_name=displayname,
pre_verified=True,
pre_confirmed=True,
pre_approved=True)
elif membership_type == 'moderator':
mm_list.add_moderator(user_mail,
display_name=displayname)
elif membership_type == 'owner':
mm_list.add_moderator(user_mail,
display_name=displayname)
logger.warning("subscribe {} ( {} ) as {} on {}".format(username, user_mail, membership_type, list_name))
except HTTPError as e:
# We get a http error if the user is already subscribed.
# It is silently ignored
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment