Add setting for contact roster name
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

And only exchange contacts when ejabberd integration is enabled
This commit is contained in:
Râu Cao 2023-03-15 15:48:27 +07:00 committed by Gitea
parent 8da297811b
commit 8d90847896
4 changed files with 13 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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 %>
</ul>

View File

@ -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