diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /comm/mail/components/about-support/content/chat.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | comm/mail/components/about-support/content/chat.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/comm/mail/components/about-support/content/chat.js b/comm/mail/components/about-support/content/chat.js new file mode 100644 index 0000000000..50c34b9ba0 --- /dev/null +++ b/comm/mail/components/about-support/content/chat.js @@ -0,0 +1,73 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +var { IMServices } = ChromeUtils.importESModule( + "resource:///modules/IMServices.sys.mjs" +); + +/** + * Populates the "Chat" section of the troubleshooting information page with + * the chat accounts. + */ +function populateChatSection() { + let table = document.getElementById("chat-table"); + let rowTmpl = document.getElementById("chat-table-row-template"); + let dateTimeFormatter = new Services.intl.DateTimeFormat(undefined, { + dateStyle: "short", + timeStyle: "long", + }); + let formatDebugMessage = dbgMsg => { + let m = dbgMsg.message; + let time = new Date(m.timeStamp); + time = dateTimeFormatter.format(time); + let level = dbgMsg.logLevel; + if (!level) { + return "(" + m.errorMessage + ")"; + } + if (level == dbgMsg.LEVEL_ERROR) { + level = "ERROR"; + } else if (level == dbgMsg.LEVEL_WARNING) { + level = "WARN."; + } else if (level == dbgMsg.LEVEL_LOG) { + level = "LOG "; + } else { + level = "DEBUG"; + } + return ( + "[" + + time + + "] " + + level + + " (@ " + + m.sourceLine + + " " + + m.sourceName + + ":" + + m.lineNumber + + ")\n" + + m.errorMessage + ); + }; + + let chatAccounts = IMServices.accounts.getAccounts(); + if (!chatAccounts.length) { + return; + } + table.querySelector("tbody").append( + ...chatAccounts.map(account => { + const row = rowTmpl.content.cloneNode(true).querySelector("tr"); + row.cells[0].textContent = account.id; + row.cells[1].textContent = account.protocol.id; + row.cells[2].textContent = account.name; + row.cells[3].addEventListener("click", () => { + const text = account + .getDebugMessages() + .map(formatDebugMessage) + .join("\n"); + navigator.clipboard.writeText(text); + }); + return row; + }) + ); +} |