Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7367431d
Commit
7367431d
authored
Sep 19, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor emails service
parent
40c2dcb3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
14 deletions
+54
-14
app/services/emails/base_service.rb
app/services/emails/base_service.rb
+1
-7
app/services/emails/create_service.rb
app/services/emails/create_service.rb
+3
-5
app/services/emails/destroy_service.rb
app/services/emails/destroy_service.rb
+2
-2
ee/app/services/ee/emails/base_service.rb
ee/app/services/ee/emails/base_service.rb
+18
-0
ee/app/services/ee/emails/create_service.rb
ee/app/services/ee/emails/create_service.rb
+15
-0
ee/app/services/ee/emails/destroy_service.rb
ee/app/services/ee/emails/destroy_service.rb
+15
-0
No files found.
app/services/emails/base_service.rb
View file @
7367431d
module
Emails
class
BaseService
def
initialize
(
current_user
,
user
,
opts
)
@current_user
=
current_user
def
initialize
(
user
,
opts
)
@user
=
user
@email
=
opts
[
:email
]
end
def
log_audit_event
(
options
=
{})
AuditEventService
.
new
(
@current_user
,
@user
,
options
)
.
for_email
(
@email
).
security_event
end
end
end
app/services/emails/create_service.rb
View file @
7367431d
module
Emails
class
CreateService
<
::
Emails
::
BaseService
def
execute
email
=
@user
.
emails
.
create
(
email:
@email
)
log_audit_event
(
action: :create
)
prepend
EE
::
Emails
::
CreateService
email
def
execute
@user
.
emails
.
create
(
email:
@email
)
end
end
end
app/services/emails/destroy_service.rb
View file @
7367431d
module
Emails
class
DestroyService
<
::
Emails
::
BaseService
prepend
EE
::
Emails
::
DestroyService
def
execute
Email
.
find_by_email!
(
@email
).
destroy
&&
update_secondary_emails!
log_audit_event
(
action: :destroy
)
end
private
...
...
ee/app/services/ee/emails/base_service.rb
0 → 100644
View file @
7367431d
module
EE
module
Emails
module
BaseService
def
initialize
(
current_user
,
user
,
opts
)
@current_user
=
current_user
super
(
user
,
opts
)
end
private
def
log_audit_event
(
options
=
{})
AuditEventService
.
new
(
@current_user
,
@user
,
options
)
.
for_email
(
@email
).
security_event
end
end
end
end
ee/app/services/ee/emails/create_service.rb
0 → 100644
View file @
7367431d
module
EE
module
Emails
module
CreateService
include
EE
::
Emails
::
BaseService
def
execute
email
=
super
log_audit_event
(
action: :create
)
if
email
.
persisted?
email
end
end
end
end
ee/app/services/ee/emails/destroy_service.rb
0 → 100644
View file @
7367431d
module
EE
module
Emails
module
DestroyService
include
EE
::
Emails
::
BaseService
def
execute
result
=
super
log_audit_event
(
action: :destroy
)
result
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment