Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Roman Karwacik
website
Commits
32a9ed19
Commit
32a9ed19
authored
7 years ago
by
Julian Rother
Browse files
Options
Downloads
Patches
Plain Diff
Fixed some issues in mail.py
parent
ff053365
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mail.py
+18
-17
18 additions, 17 deletions
mail.py
with
18 additions
and
17 deletions
mail.py
+
18
−
17
View file @
32a9ed19
...
...
@@ -14,23 +14,22 @@ def send_message(msgtype, recipients, **kwargs):
try
:
msg
[
'
Subject
'
]
=
render_template
(
'
mails/
'
+
msgtype
+
'
.subject
'
,
**
kwargs
)
msg
.
set_content
(
render_template
(
'
mails/
'
+
msgtype
+
'
.body
'
,
**
kwargs
))
except
:
traceback
.
print_exc
()
return
if
'
MAIL_SERVER
'
not
in
config
:
return
s
=
smtplib
.
SMTP
(
config
[
'
MAIL_SERVER
'
])
s
.
send_message
(
msg
)
s
.
quit
()
except
:
traceback
.
print_exc
()
def
notify_users
(
msgtype
,
uids
,
**
kwargs
):
recipients
=
[]
exclude
=
kwargs
.
pop
(
'
exclude_uids
'
,
[])
for
uid
in
uids
:
user
=
query
(
'
SELECT * FROM users WHERE id = ?
'
,
uid
)
if
user
[
0
][
'
id
'
]
in
exclude
:
if
not
user
or
user
[
0
][
'
id
'
]
in
exclude
:
continue
if
not
user
or
not
user
[
0
][
'
fsacc
'
]
or
not
user
[
0
][
'
mail_notifications
'
]:
if
not
user
[
0
][
'
fsacc
'
]
or
not
user
[
0
][
'
mail_notifications
'
]:
continue
if
msgtype
in
user
[
0
]
and
not
user
[
0
][
msgtype
]:
continue
...
...
@@ -39,14 +38,17 @@ def notify_users(msgtype, uids, **kwargs):
config
[
'
MAIL_SUFFIX
'
]))
else
:
recipients
.
append
(
'
%s@%s
'
%
(
user
[
0
][
'
fsacc
'
],
config
[
'
MAIL_SUFFIX
'
]))
if
recipients
:
if
kwargs
.
pop
(
'
importend
'
,
False
):
kwargs
[
'
cc
'
]
=
[
config
[
'
MAIL_DEFAULT
'
]]
else
:
cc
=
kwargs
.
get
(
'
cc
'
,
[])
if
kwargs
.
pop
(
'
importend
'
,
False
):
recipients
=
[
config
[
'
MAIL_DEFAULT
'
]]
else
:
cc
.
append
(
config
[
'
MAIL_DEFAULT
'
])
if
kwargs
.
pop
(
'
notify_admins
'
,
False
):
cc
.
append
(
config
[
'
MAIL_ADMINS
'
])
if
not
recipients
:
recipients
=
cc
cc
=
[]
if
not
recipients
:
return
kwargs
[
'
cc
'
]
=
cc
send_message
(
msgtype
,
recipients
,
**
kwargs
)
def
notify_mods
(
msgtype
,
course_id
,
**
kwargs
):
...
...
@@ -63,5 +65,4 @@ def notify_admins(msgtype, **kwargs):
send_message
(
msgtype
,
[
config
[
'
MAIL_ADMINS
'
]],
**
kwargs
)
except
:
traceback
.
print_exc
()
pass
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