Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
HyperKitty
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
GNU Mailman
HyperKitty
Commits
1755122c
Commit
1755122c
authored
9 years ago
by
Aurélien Bompard
Browse files
Options
Downloads
Patches
Plain Diff
Add a hook on social auth to associate secondary addresses
parent
87223280
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hyperkitty/lib/mailman.py
+32
-0
32 additions, 0 deletions
hyperkitty/lib/mailman.py
with
32 additions
and
0 deletions
hyperkitty/lib/mailman.py
+
32
−
0
View file @
1755122c
...
...
@@ -21,6 +21,8 @@
from
__future__
import
absolute_import
,
unicode_literals
from
urllib2
import
HTTPError
from
django.conf
import
settings
from
django.utils.timezone
import
now
from
mailmanclient
import
Client
,
MailmanConnectionError
...
...
@@ -135,3 +137,33 @@ def sync_with_mailman(overwrite=False):
upper_bound
+=
buffer_size
prev_count
=
count
logger
.
info
(
"
%d emails left to refresh, checked %d
"
,
count
,
lower_bound
)
def
add_user_to_mailman
(
user
,
details
,
*
args
,
**
kwargs
):
# pylint: disable-msg=unused-argument
"""
On social_auth login, create the Mailman user and associate any secondary
email addresses with it.
"""
from
hyperkitty.models
import
Profile
try
:
profile
=
Profile
.
objects
.
get
(
user_id
=
user
.
id
)
except
Profile
.
DoesNotExist
:
# Create the profile if it does not exist. There's a signal receiver
# that creates it for new users, but HyperKitty may be added to an
# existing Django project with existing users.
profile
=
Profile
.
objects
.
create
(
user
=
user
)
mm_user
=
profile
.
get_mailman_user
()
if
mm_user
is
None
:
return
try
:
secondary_email
=
details
[
"
secondary_email
"
]
except
KeyError
:
return
if
secondary_email
not
in
[
unicode
(
a
)
for
a
in
mm_user
.
addresses
]:
try
:
mm_user
.
add_address
(
secondary_email
,
force_existing
=
True
)
logger
.
debug
(
"
Associated secondary address %s with %s
"
,
secondary_email
,
user
.
username
)
except
HTTPError
as
e
:
logger
.
warning
(
"
Can
'
t add %s to %s: %s
"
,
secondary_email
,
user
.
username
,
e
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment