cheogram-android
created pr with
cheogram-android/offline-nick.1
commented
lgtm
cmds
checkout latest patchset:
ssh pr.pico.sh pull cheogram-android:offline-nick | git am -3checkout specific patchset revision:
ssh pr.pico.sh pull cheogram-android:offline-nick [rev] | git am -3add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh cheogram-android:offline-nickadd comment to patch request:
ssh pr.pico.sh comment cheogram-android:offline-nick "lgtm!"
Patchset
cheogram-android/offline-nick.1
Make a stub if we don't know nick
Stephen Paul Weber
2026-11-07T18:05:53ZSemantic diff summary
0 added,
0 modified,
0 signature changed,
0 removed
across 0 analyzed files
(3 files skipped: unsupported file type)
+4
-2
src/main/java/eu/siacs/conversations/entities/MucOptions.java
#
| ... | ... | @@ -543,12 +543,14 @@ public class MucOptions { | |
| 543 | 543 | ||
| 544 | 544 | public User getUserOrStub(final IdentifiableUser identifiableUser) { | |
| 545 | 545 | final var existing = getUser(identifiableUser); | |
| 546 | - | if (existing != null) { | |
| 546 | + | final var address = identifiableUser.mucUserAddress(); | |
| 547 | + | if (existing != null | |
| 548 | + | && (existing.getNick() != null || address == null || !address.isFullJid())) { | |
| 547 | 549 | return existing; | |
| 548 | 550 | } | |
| 549 | 551 | return new Stub( | |
| 550 | 552 | this, | |
| 551 | - | identifiableUser.mucUserAddress(), | |
| 553 | + | address, | |
| 552 | 554 | identifiableUser.mucUserRealAddress(), | |
| 553 | 555 | identifiableUser.mucUserOccupantId()); | |
| 554 | 556 | } |
+1
-6
src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
#
| ... | ... | @@ -5158,7 +5158,7 @@ public class ConversationFragment extends XmppFragment | |
| 5158 | 5158 | final var mucOptions = c.getMucOptions(); | |
| 5159 | 5159 | if (mucOptions.participating()) { | |
| 5160 | 5160 | final var user = mucOptions.getUserOrStub(message); | |
| 5161 | - | if (user.resource() != null) { | |
| 5161 | + | if (user.getNick() != null) { | |
| 5162 | 5162 | if (user instanceof MucOptions.Stub) { | |
| 5163 | 5163 | Toast.makeText( | |
| 5164 | 5164 | requireActivity(), |
| ... | ... | @@ -5170,11 +5170,6 @@ public class ConversationFragment extends XmppFragment | |
| 5170 | 5170 | .show(); | |
| 5171 | 5171 | } | |
| 5172 | 5172 | highlightInConference(user.getNick()); | |
| 5173 | - | } else { | |
| 5174 | - | final var counterpart = message.getCounterpart(); | |
| 5175 | - | if (counterpart != null && counterpart.isFullJid()) { | |
| 5176 | - | highlightInConference(counterpart.getResource()); | |
| 5177 | - | } | |
| 5178 | 5173 | } | |
| 5179 | 5174 | } else { | |
| 5180 | 5175 | Toast.makeText( |
+27
-0
src/test/java/eu/siacs/conversations/entities/MucOptionsTest.java
#
| ... | ... | @@ -135,6 +135,33 @@ public class MucOptionsTest { | |
| 135 | 135 | ||
| 136 | 136 | Assert.assertEquals("Contact Name", offlineUser.getDisplayName()); | |
| 137 | 137 | } | |
| 138 | + | ||
| 139 | + | @Test | |
| 140 | + | public void testGetUserOrStubUsesNickFromMessageAddress() throws Exception { | |
| 141 | + | final var realJid = Jid.ofLocalAndDomain("anonUser", "example.org"); | |
| 142 | + | final var offlineUser = new MucOptions.User( | |
| 143 | + | mucOptions, | |
| 144 | + | null, | |
| 145 | + | realJid, | |
| 146 | + | null, | |
| 147 | + | null, | |
| 148 | + | im.conversations.android.xmpp.model.muc.Role.NONE, | |
| 149 | + | im.conversations.android.xmpp.model.muc.Affiliation.NONE, | |
| 150 | + | new HashSet<>() | |
| 151 | + | ); | |
| 152 | + | mucOptions.updateUser(offlineUser, null); | |
| 153 | + | ||
| 154 | + | final var identifiableUser = mock(MucOptions.IdentifiableUser.class); | |
| 155 | + | when(identifiableUser.mucUserAddress()) | |
| 156 | + | .thenReturn(Jid.of("testMuc@example.org/testNick")); | |
| 157 | + | when(identifiableUser.mucUserRealAddress()).thenReturn(realJid); | |
| 158 | + | ||
| 159 | + | final var user = mucOptions.getUserOrStub(identifiableUser); | |
| 160 | + | ||
| 161 | + | Assert.assertTrue(user instanceof MucOptions.Stub); | |
| 162 | + | Assert.assertEquals("testNick", user.getNick()); | |
| 163 | + | } | |
| 164 | + | ||
| 138 | 165 | @Test | |
| 139 | 166 | public void testSetAvatarCachesAvatar() throws Exception { | |
| 140 | 167 | when(conversation.setCachedOccupantAvatar(CACHE_KEY, "newAvatar")).thenReturn(true); |