Merge pull request 'Add user preferences and configurable notifications' (#113) from feature/user_preferences into master
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: #113
Reviewed-by: galfert <garret.alfert@gmail.com>
This commit was merged in pull request #113.
This commit is contained in:
2023-04-11 21:04:46 +00:00
33 changed files with 384 additions and 136 deletions

View File

@@ -1,6 +1,8 @@
class User < ApplicationRecord
include EmailValidatable
serialize :preferences, UserPreferences
# Relations
has_many :invitations, dependent: :destroy
has_one :invitation, inverse_of: :invitee, foreign_key: 'invited_user_id'
@@ -56,13 +58,16 @@ class User < ApplicationRecord
end
def devise_after_confirmation
enable_service %w[ discourse ejabberd gitea mediawiki ]
enable_service %w[ discourse gitea mediawiki xmpp ]
#TODO enable in development when we have easy setup of ejabberd etc.
return if Rails.env.development?
if inviter.present?
exchange_xmpp_contact_with_inviter if Setting.ejabberd_enabled?
if Setting.ejabberd_enabled? &&
inviter.preferences[:xmpp_exchange_contacts_with_invitees]
exchange_xmpp_contact_with_inviter
end
end
end
@@ -135,8 +140,8 @@ class User < ApplicationRecord
end
def exchange_xmpp_contact_with_inviter
return unless inviter.services_enabled.include?("ejabberd") &&
services_enabled.include?("ejabberd")
return unless inviter.services_enabled.include?("xmpp") &&
services_enabled.include?("xmpp")
XmppExchangeContactsJob.perform_later(inviter, self.cn, self.ou)
end