diff --git a/app/jobs/xmpp_exchange_contacts_job.rb b/app/jobs/xmpp_exchange_contacts_job.rb index 01f64f1..50f6fa2 100644 --- a/app/jobs/xmpp_exchange_contacts_job.rb +++ b/app/jobs/xmpp_exchange_contacts_job.rb @@ -7,12 +7,12 @@ class XmppExchangeContactsJob < ApplicationJob ejabberd.add_rosteritem({ "localuser": username, "localhost": domain, "user": inviter.cn, "host": inviter.ou, - "nick": inviter.cn, "group": "Friends", "subs": "both" + "nick": inviter.cn, "group": Setting.ejabberd_buddy_roster, "subs": "both" }) ejabberd.add_rosteritem({ "localuser": inviter.cn, "localhost": inviter.ou, "user": username, "host": domain, - "nick": username, "group": "Friends", "subs": "both" + "nick": username, "group": Setting.ejabberd_buddy_roster, "subs": "both" }) end end diff --git a/app/services/create_account.rb b/app/services/create_account.rb index c5cb69a..bc05e50 100644 --- a/app/services/create_account.rb +++ b/app/services/create_account.rb @@ -15,7 +15,7 @@ class CreateAccount < ApplicationService if @invitation.present? update_invitation(user.id) - exchange_xmpp_contacts + exchange_xmpp_contacts if Setting.ejabberd_enabled end end diff --git a/app/views/admin/settings/services/_ejabberd.html.erb b/app/views/admin/settings/services/_ejabberd.html.erb index 16dfc58..46e3ca6 100644 --- a/app/views/admin/settings/services/_ejabberd.html.erb +++ b/app/views/admin/settings/services/_ejabberd.html.erb @@ -18,5 +18,13 @@ value: Setting.ejabberd_admin_url, class: "w-full", disabled: true %> <% end %> + <%= render FormElements::FieldsetComponent.new( + title: "Contact roster name", + description: "Used when exchanging contacts after signup from invitation" + ) do %> + <%= f.text_field :ejabberd_buddy_roster, + value: Setting.ejabberd_buddy_roster, + class: "w-full" %> + <% end %> <% end %> diff --git a/spec/jobs/xmpp_exchange_contacts_job_spec.rb b/spec/jobs/xmpp_exchange_contacts_job_spec.rb index 0064b69..f7732dc 100644 --- a/spec/jobs/xmpp_exchange_contacts_job_spec.rb +++ b/spec/jobs/xmpp_exchange_contacts_job_spec.rb @@ -17,9 +17,9 @@ RSpec.describe XmppExchangeContactsJob, type: :job do perform_enqueued_jobs { job } expect(WebMock).to have_requested(:post, "http://xmpp.example.com/api/add_rosteritem") - .with { |req| req.body == '{"localuser":"isaacnewton","localhost":"kosmos.org","user":"willherschel","host":"kosmos.org","nick":"willherschel","group":"Friends","subs":"both"}' } + .with { |req| req.body == '{"localuser":"isaacnewton","localhost":"kosmos.org","user":"willherschel","host":"kosmos.org","nick":"willherschel","group":"Buddies","subs":"both"}' } expect(WebMock).to have_requested(:post, "http://xmpp.example.com/api/add_rosteritem") - .with { |req| req.body == '{"localuser":"willherschel","localhost":"kosmos.org","user":"isaacnewton","host":"kosmos.org","nick":"isaacnewton","group":"Friends","subs":"both"}' } + .with { |req| req.body == '{"localuser":"willherschel","localhost":"kosmos.org","user":"isaacnewton","host":"kosmos.org","nick":"isaacnewton","group":"Buddies","subs":"both"}' } end after do