From 0f13ada300365b5eee02b7be949e9d249e1381e3 Mon Sep 17 00:00:00 2001
From: strawberry <strawberry@puppygock.gay>
Date: Wed, 1 May 2024 21:45:30 -0400
Subject: [PATCH] return more user-friendly message for debug memory-stats

Signed-off-by: strawberry <strawberry@puppygock.gay>
---
 src/service/admin/debug/debug_commands.rs | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/service/admin/debug/debug_commands.rs b/src/service/admin/debug/debug_commands.rs
index ef2fb3bd7..c27dd38c3 100644
--- a/src/service/admin/debug/debug_commands.rs
+++ b/src/service/admin/debug/debug_commands.rs
@@ -455,5 +455,14 @@ pub(crate) async fn resolve_true_destination(
 }
 
 pub(crate) fn memory_stats() -> RoomMessageEventContent {
-	RoomMessageEventContent::text_html("HTML only".to_owned(), crate::alloc::memory_stats())
+	let html_body = crate::alloc::memory_stats();
+
+	if html_body.is_empty() {
+		return RoomMessageEventContent::text_plain("malloc stats are not supported on your compiled malloc.");
+	}
+
+	RoomMessageEventContent::text_html(
+		"This command's output can only be viewed by clients that render HTML.".to_owned(),
+		html_body,
+	)
 }
-- 
GitLab