Add offline messages: inbox, compose and reply, unread notice

Tools > Offline Messages (Ctrl+O) lists the server inbox, shows a message and
marks it read; compose and reply follow the official windows. The unread count
comes from client_unread_messages: new mail is logged with a link to the inbox
and shown as an envelope in the status bar. Recipients can be given by unique
id, which needs no search permission.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 20:58:44 +00:00
co-authored by Claude Opus 5.5
parent e54623bc47
commit 023b449fba
20 changed files with 1496 additions and 5 deletions
@@ -30,6 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
class ConnectionEventHandlerTest {
private int modelChanges;
private int unreadReports;
private final Settings settings = new Settings();
private final TeamspeakConnection conn = new TeamspeakConnection(settings, null, new ConnectionListener() {
@Override
@@ -76,6 +77,11 @@ class ConnectionEventHandlerTest {
@Override
public void onServerLog(String message) {
}
@Override
public void onUnreadMessagesChanged(int unread) {
unreadReports++;
}
}, new SoundNotifier(settings), ContactStore.load());
private final ConnectionEventHandler events = new ConnectionEventHandler(conn);
private final ServerModel model = conn.getModel();
@@ -136,6 +142,17 @@ class ConnectionEventHandlerTest {
assertEquals("abc", alice.avatarFlag);
}
@Test
void tracksAClientsUnreadOfflineMessages() {
model.putChannel(1, "Lobby", 0, 0);
join(5, "alice", 1);
assertEquals(0, model.getClient(5).unreadMessages);
events.onClientChanged(new ClientUpdatedEvent(fields("notifyclientupdated clid=5 client_unread_messages=3")));
assertEquals(3, model.getClient(5).unreadMessages);
assertEquals(0, unreadReports, "only our own count is reported");
}
@Test
void clearedFieldsAreCleared() {
model.putChannel(1, "Lobby", 0, 0);
@@ -22,6 +22,14 @@ class BBCodeLinksTest {
assertTrue(html.contains(">Lobby</a>"), html);
}
@Test
void rendersTheOfflineMessagesLink() {
String html = BBCode.linksToHtml("You have " + TsLink.offlineMessagesBBCode("2 unread offline messages"));
assertTrue(html.contains("href=\"offline://\""), html);
assertTrue(html.contains(">2 unread offline messages</a>"), html);
assertTrue(TsLink.isOfflineMessages("offline://"));
}
@Test
void leavesOtherMarkupLiteral() {
assertEquals("[b]not bold[/b] &amp; &lt;i&gt;", BBCode.linksToHtml("[b]not bold[/b] & <i>"));