Show an avatar, description or away message being cleared
Client and channel updates were only applied when the field had a value, since ts3j reads a missing field back as an empty string. A removed avatar, an emptied description or a cleared away message arrives as the field without a value, so they stayed as they were. Such fields are now applied whenever the update carries them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
package com.ts3client.net;
|
||||
|
||||
import com.github.manevolent.ts3j.command.MultiCommand;
|
||||
import com.github.manevolent.ts3j.event.ClientUpdatedEvent;
|
||||
import com.github.manevolent.ts3j.protocol.ProtocolRole;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Pins the ts3j behaviour {@code ConnectionEventHandler.has(...)} exists for: a field
|
||||
@@ -22,4 +26,15 @@ class EventFieldsTest {
|
||||
assertEquals("", e.get("client_is_recording"));
|
||||
assertEquals("", e.get("client_nickname"));
|
||||
}
|
||||
|
||||
/** What {@code reported(...)} relies on: a cleared field still arrives, just without a value. */
|
||||
@Test
|
||||
void clearedFieldsAreStillInTheMap() {
|
||||
Map<String, String> fields = MultiCommand.parse(ProtocolRole.SERVER,
|
||||
"notifyclientupdated clid=7 client_flag_avatar client_description=").simplifyOne().toMap();
|
||||
ClientUpdatedEvent e = new ClientUpdatedEvent(fields);
|
||||
assertTrue(e.getMap().containsKey("client_flag_avatar"));
|
||||
assertTrue(e.getMap().containsKey("client_description"));
|
||||
assertFalse(e.getMap().containsKey("client_away_message"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user