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
Use contact for name only when in contact list
Stephen Paul Weber
2026-11-07T18:04:00ZDon't display chunk off jid otherwise
Semantic diff summary
0 added,
0 modified,
0 signature changed,
0 removed
across 0 analyzed files
(2 files skipped: unsupported file type)
+2
-7
src/main/java/eu/siacs/conversations/entities/MucOptions.java
#
| ... | ... | @@ -1019,15 +1019,10 @@ public class MucOptions { | |
| 1019 | 1019 | } | |
| 1020 | 1020 | ||
| 1021 | 1021 | public Contact getContact() { | |
| 1022 | - | if (fullJid != null) { | |
| 1023 | - | return realJid == null | |
| 1024 | - | ? null | |
| 1025 | - | : getAccount().getRoster().getContactFromContactList(realJid); | |
| 1026 | - | } else if (realJid != null) { | |
| 1027 | - | return getAccount().getRoster().getContact(realJid); | |
| 1028 | - | } else { | |
| 1022 | + | if (realJid == null) { | |
| 1029 | 1023 | return null; | |
| 1030 | 1024 | } | |
| 1025 | + | return getAccount().getRoster().getContactFromContactList(realJid); | |
| 1031 | 1026 | } | |
| 1032 | 1027 | ||
| 1033 | 1028 | public boolean setAvatar(final String avatar) { |
+22
-0
src/test/java/eu/siacs/conversations/entities/MucOptionsTest.java
#
| ... | ... | @@ -88,6 +88,28 @@ public class MucOptionsTest { | |
| 88 | 88 | Assert.assertEquals("cachedAvatar", cachedUser.getAvatar()); | |
| 89 | 89 | } | |
| 90 | 90 | ||
| 91 | + | @Test | |
| 92 | + | public void testOfflineUserUsesContactNameWhenInContactList() throws Exception { | |
| 93 | + | final var realJid = Jid.ofLocalAndDomain("realUser", "example.org"); | |
| 94 | + | final var contact = mock(Contact.class); | |
| 95 | + | when(contact.getDisplayName()).thenReturn("Contact Name"); | |
| 96 | + | when(conversation.getAccount().getRoster().getContactFromContactList(realJid)) | |
| 97 | + | .thenReturn(contact); | |
| 98 | + | final var user = new MucOptions.User( | |
| 99 | + | mucOptions, | |
| 100 | + | Jid.of("testMuc@example.org/testNick"), | |
| 101 | + | realJid, | |
| 102 | + | null, | |
| 103 | + | null, | |
| 104 | + | im.conversations.android.xmpp.model.muc.Role.NONE, | |
| 105 | + | im.conversations.android.xmpp.model.muc.Affiliation.NONE, | |
| 106 | + | new HashSet<>() | |
| 107 | + | ); | |
| 108 | + | ||
| 109 | + | final var offlineUser = user.asOfflineUser(); | |
| 110 | + | ||
| 111 | + | Assert.assertEquals("Contact Name", offlineUser.getDisplayName()); | |
| 112 | + | } | |
| 91 | 113 | @Test | |
| 92 | 114 | public void testSetAvatarCachesAvatar() throws Exception { | |
| 93 | 115 | when(conversation.setCachedOccupantAvatar(CACHE_KEY, "newAvatar")).thenReturn(true); |