From ce9939b4c0ea0f0c5d15dbd2210d5181ec9cc9a2 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan <hypolite@mrpetovan.com>
Date: Sun, 23 Apr 2023 16:31:29 -0400
Subject: [PATCH] Separate JSON output of contact lists in message_recipient
 template

---
 src/Core/ACL.php                         | 5 +++--
 view/templates/acl/message_recipient.tpl | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/Core/ACL.php b/src/Core/ACL.php
index f7b8924055..aa5e2221b7 100644
--- a/src/Core/ACL.php
+++ b/src/Core/ACL.php
@@ -66,8 +66,9 @@ class ACL
 
 		$tpl = Renderer::getMarkupTemplate('acl/message_recipient.tpl');
 		$o = Renderer::replaceMacros($tpl, [
-			'$contacts' => json_encode($contacts),
-			'$selected' => $selected,
+			'$contacts'      => $contacts,
+			'$contacts_json' => json_encode($contacts),
+			'$selected'      => $selected,
 		]);
 
 		Hook::callAll(DI::args()->getModuleName() . '_post_recipient', $o);
diff --git a/view/templates/acl/message_recipient.tpl b/view/templates/acl/message_recipient.tpl
index b8aabf8c7f..701ba23a60 100644
--- a/view/templates/acl/message_recipient.tpl
+++ b/view/templates/acl/message_recipient.tpl
@@ -9,7 +9,7 @@
 		let $recipient_input = $('[name="recipient"]');
 
 		let acl = new Bloodhound({
-			local: {{$contacts nofilter}},
+			local: {{$contacts_json nofilter}},
 			identify: function(obj) { return obj.id.toString(); },
 			datumTokenizer: Bloodhound.tokenizers.obj.whitespace(['name', 'addr']),
 			queryTokenizer: Bloodhound.tokenizers.whitespace,