Skip to content

Commit 3b45582

Browse files
committed
feat(User#mail_notification): returns normalized value
1 parent 0c4c25e commit 3b45582

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

app/models/user.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,17 @@ class User < Principal
157157
end
158158
end)
159159

160+
def mail_notification
161+
notification = read_attribute(:mail_notification)
162+
if MAIL_NOTIFICATION_OPTIONS.any? { |option_value, _label| option_value == notification }
163+
notification
164+
else
165+
'none'
166+
end
167+
end
168+
160169
def set_mail_notification
161-
self.mail_notification = Setting.default_notification_option if self.mail_notification.blank?
170+
self.mail_notification = Setting.default_notification_option if self[:mail_notification].blank?
162171
true
163172
end
164173

0 commit comments

Comments
 (0)