Extending work at #51 for not adding users on UM3 message

This commit is contained in:
Marc Froehlich
2026-07-12 22:43:19 +02:00
parent 750d0a3be1
commit 674c5a62e3
2 changed files with 57 additions and 25 deletions
@@ -1357,20 +1357,26 @@ public class ChatController implements ThreadStatusCallback, PstRotatorEventList
}
/**
* Applies a UM3-style user-info update to an already known member. If ON4KST
* sends the update before the matching enter message, the member is added so
* later CH messages can resolve sender/receiver immediately.
* Applies a UM3-style user-info update only to an already active chat member.
*
* ON4KST may send UM3 messages for stations that are not logged into the
* current channel, for example when a user changes locator/profile data on the
* website. Such stations must not be added to the visible chat member list,
* because they cannot be addressed in the channel. Their full information will
* be delivered again with UA0/UA5/UA2 when they actually join.
*
* @return true if an active member was found and updated, false if the UM3
* information was intentionally ignored.
*/
public void updateOrAddActiveChatMemberInfo(ChatMember updatedMember) {
public boolean updateActiveChatMemberInfoIfPresent(ChatMember updatedMember) {
String key = buildActiveChatMemberKey(updatedMember);
if (key == null) {
return;
return false;
}
ChatMember activeMember = activeChatMembersByCallAndCategory.get(key);
if (activeMember == null) {
addOrUpdateActiveChatMember(updatedMember);
return;
return false;
}
activeMember.setName(updatedMember.getName());
@@ -1381,6 +1387,15 @@ public class ChatController implements ThreadStatusCallback, PstRotatorEventList
activeMember.setQrb(updatedMember.getQrb());
activeMember.setQTFdirection(updatedMember.getQTFdirection());
fireUserListUpdate("User info updated");
return true;
}
/**
* Backward-compatible wrapper for older call sites. Despite the historic name,
* this method no longer adds unknown UM3 users to the active member model.
*/
public boolean updateOrAddActiveChatMemberInfo(ChatMember updatedMember) {
return updateActiveChatMemberInfoIfPresent(updatedMember);
}
/**
@@ -1241,26 +1241,43 @@ public class MessageBusManagementThread extends Thread {
*/
if (splittedMessageLine[0].contains(USERINFOUPDATEORUSERISBACK)) {
ChatMember stateChangeMember = new ChatMember();
if (splittedMessageLine.length < 6) {
System.out.println("[MSGBUSMGT, warning:] Malformed UM3 message ignored: "
+ messageToProcess.getMessageText());
} else {
ChatMember stateChangeMember = new ChatMember();
stateChangeMember.setChatCategory(util_getChatCategoryByCategoryNrString(splittedMessageLine[1]));
stateChangeMember.setChatCategory(util_getChatCategoryByCategoryNrString(splittedMessageLine[1]));
stateChangeMember.setCallSign(splittedMessageLine[2]);
stateChangeMember.setName(splittedMessageLine[3]);
stateChangeMember.setQra(splittedMessageLine[4]);
stateChangeMember.setState(Integer.parseInt(splittedMessageLine[5]));
stateChangeMember.setLastActivity(new Utils4KST().time_generateActualTimeInDateFormat());
stateChangeMember.setQrb(new Location().getDistanceKmByTwoLocatorStrings(
client.getChatPreferences().getStn_loginLocatorMainCat(),
stateChangeMember.getQra()));
stateChangeMember.setQTFdirection(new Location(client.getChatPreferences().getStn_loginLocatorMainCat())
.getBearing(new Location(stateChangeMember.getQra())));
stateChangeMember.setCallSign(splittedMessageLine[2]);
stateChangeMember.setName(splittedMessageLine[3]);
stateChangeMember.setQra(splittedMessageLine[4]);
stateChangeMember.setState(Integer.parseInt(splittedMessageLine[5]));
stateChangeMember.setLastActivity(new Utils4KST().time_generateActualTimeInDateFormat());
stateChangeMember.setQrb(new Location().getDistanceKmByTwoLocatorStrings(client.getChatPreferences().getStn_loginLocatorMainCat(), stateChangeMember.getQra()));
stateChangeMember.setQTFdirection(new Location(client.getChatPreferences().getStn_loginLocatorMainCat()).getBearing(new Location(stateChangeMember.getQra())));
this.client.getDbHandler().storeChatMember(stateChangeMember); // TODO: not clean, it should be an
// upodate
// System.out.println("[MSGBUSMGT:] DXCluster Message detected ");
// -1 could be the case if mycall is processed; own call is not displayed in the active-member list.
if (!client.getChatPreferences().getStn_loginCallSign().equalsIgnoreCase(stateChangeMember.getCallSign())) {
this.client.updateOrAddActiveChatMemberInfo(stateChangeMember);
/*
* UM3 is only an info/profile update. ON4KST also sends it for stations
* that are not logged into this channel. Such stations must not become
* visible chat members, otherwise the user could try to address an
* offline callsign and receive server-side errors.
*
* Therefore UM3 updates existing active members only. Unknown UM3 calls
* are intentionally ignored; if the station joins later, UA0/UA5/UA2
* will deliver the complete current user information again.
*/
if (!client.getChatPreferences().getStn_loginCallSign().equalsIgnoreCase(stateChangeMember.getCallSign())) {
boolean updatedActiveMember = this.client.updateActiveChatMemberInfoIfPresent(stateChangeMember);
if (updatedActiveMember) {
this.client.getDbHandler().storeChatMember(stateChangeMember); // TODO: not clean, it should be an update
} else {
System.out.println("[MSGBUSMGT, Info:] UM3 ignored for inactive user: "
+ stateChangeMember.getCallSign() + " / " + stateChangeMember.getChatCategory());
}
}
}
} else