diff --git a/js/main.js b/js/main.js index 4e8867c..35f552a 100644 --- a/js/main.js +++ b/js/main.js @@ -3,6 +3,7 @@ if (!root) return; const username = root.dataset.username; + const userEmail = (root.dataset.userEmail || "").trim(); const serverAddress = root.dataset.serverAddress; const apiBase = root.dataset.supportApiBase; const supportWsBaseOverride = (root.dataset.supportWsBase || "").trim(); @@ -281,10 +282,14 @@ }; function clientIdentityHeaders() { - return { + const headers = { "X-F7cloud-User": username, "X-F7cloud-Server": serverAddress, }; + if (userEmail) { + headers["X-F7cloud-Email"] = userEmail; + } + return headers; } function revokeAttachmentUrls() { @@ -1471,12 +1476,16 @@ showError("Тема и обращение обязательны"); return; } - const result = await submitTicketWithRetry({ + const createPayload = { server_address: serverAddress, username, subject, body: TICKET_CREATE_BODY_PLACEHOLDER, - }); + }; + if (userEmail) { + createPayload.client_email = userEmail; + } + const result = await submitTicketWithRetry(createPayload); const ticketNo = result.ticket_number; let createdMsg; try { diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index ff70819..f088a80 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -72,8 +72,15 @@ class PageController extends Controller { Util::addStyle('f7support', 'f7support'); Util::addScript('f7support', 'main'); + $userEmail = ''; + if ($user !== null) { + $mail = $user->getEMailAddress(); + $userEmail = is_string($mail) ? trim($mail) : ''; + } + return new TemplateResponse('f7support', 'main', [ 'username' => $user ? $user->getUID() : '', + 'userEmail' => $userEmail, 'serverAddress' => $serverHost, 'supportApiBase' => $supportApiBase, 'supportApiOrigin' => $supportApiOrigin, diff --git a/templates/main.php b/templates/main.php index be2a635..cb9f395 100644 --- a/templates/main.php +++ b/templates/main.php @@ -2,6 +2,7 @@