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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
86418c47
Commit
86418c47
authored
Mar 29, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove useless Notification model
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
08b3d7f6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
28 deletions
+17
-28
app/models/member.rb
app/models/member.rb
+2
-2
app/models/notification.rb
app/models/notification.rb
+0
-13
app/models/user.rb
app/models/user.rb
+0
-4
app/services/notification_service.rb
app/services/notification_service.rb
+15
-9
No files found.
app/models/member.rb
View file @
86418c47
...
...
@@ -171,8 +171,8 @@ class Member < ActiveRecord::Base
end
end
def
notification
@notification
||=
user
.
notification_settings
.
find_by
(
source:
source
)
def
notification
_setting
@notification
_setting
||=
user
.
notification_settings
.
find_by
(
source:
source
)
end
private
...
...
app/models/notification.rb
deleted
100644 → 0
View file @
08b3d7f6
class
Notification
attr_accessor
:target
delegate
:disabled?
,
:participating?
,
:watch?
,
:global?
,
:mention?
,
to: :target
def
initialize
(
target
)
@target
=
target
end
def
level
target
.
notification_level
end
end
app/models/user.rb
View file @
86418c47
...
...
@@ -357,10 +357,6 @@ class User < ActiveRecord::Base
"
#{
self
.
class
.
reference_prefix
}#{
username
}
"
end
def
notification
@notification
||=
Notification
.
new
(
self
)
end
def
generate_password
if
self
.
force_random_password
self
.
password
=
self
.
password_confirmation
=
Devise
.
friendly_token
.
first
(
8
)
...
...
app/services/notification_service.rb
View file @
86418c47
...
...
@@ -329,25 +329,31 @@ class NotificationService
# Remove users with disabled notifications from array
# Also remove duplications and nil recipients
def
reject_muted_users
(
users
,
project
=
nil
)
reject_users
(
users
,
:disabled
?
,
project
)
reject_users
(
users
,
:disabled
,
project
)
end
# Remove users with notification level 'Mentioned'
def
reject_mention_users
(
users
,
project
=
nil
)
reject_users
(
users
,
:mention
?
,
project
)
reject_users
(
users
,
:mention
,
project
)
end
# Reject users which
method_name from notification object returns true.
# Reject users which
has certain notification level
#
# Example:
# reject_users(users, :watch
?
, project)
# reject_users(users, :watch, project)
#
def
reject_users
(
users
,
method_name
,
project
=
nil
)
def
reject_users
(
users
,
level
,
project
=
nil
)
level
=
level
.
to_s
unless
NotificationSetting
.
levels
.
keys
.
include?
(
level
)
raise
'Invalid notification level'
end
users
=
users
.
to_a
.
compact
.
uniq
users
=
users
.
reject
(
&
:blocked?
)
users
.
reject
do
|
user
|
next
user
.
notification
.
send
(
method_name
)
unless
project
next
user
.
notification
_level
==
level
unless
project
setting
=
user
.
notification_settings
.
find_by
(
source:
project
)
...
...
@@ -356,13 +362,13 @@ class NotificationService
end
# reject users who globally set mention notification and has no setting per project/group
next
user
.
notification
.
send
(
method_name
)
unless
setting
next
user
.
notification
_level
==
level
unless
setting
# reject users who set mention notification in project
next
true
if
setting
.
send
(
method_name
)
next
true
if
setting
.
level
==
level
# reject users who have mention level in project and disabled in global settings
setting
.
global?
&&
user
.
notification
.
send
(
method_name
)
setting
.
global?
&&
user
.
notification
_level
==
level
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