Skip to content

Commit

Permalink
Merge pull request #4 from pgrosslicht/master
Browse files Browse the repository at this point in the history
Fix error when trying to export DMs
  • Loading branch information
patrickfav authored Mar 4, 2021
2 parents 1525262 + 06837c3 commit 4274448
Showing 3 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -206,7 +206,10 @@ public List<RocketChatDm.DirectMessage> listDirectMessageChannels() throws IOExc
if (channel != null) {
return channel.getIms()
.stream()
.peek(dm -> dm.setGeneratedName(dm.getUsernames().stream().filter(u -> !u.equals(userName)).findFirst().get()))
.peek(dm -> dm.setGeneratedName(dm.getUsernames().stream()
.filter(u -> !u.equals(userName))
.findFirst()
.orElse(userName))) // Fallback to the user's name if we have filtered out all names (conversations with themselves)
.collect(Collectors.toList());
} else {
return Collections.emptyList();
Original file line number Diff line number Diff line change
@@ -108,7 +108,7 @@ public void listDms() throws Exception {
login();
List<RocketChatDm.DirectMessage> dm = exporter.listDirectMessageChannels();
assertNotNull(dm);
assertEquals(2, dm.size());
assertEquals(3, dm.size());
}


21 changes: 19 additions & 2 deletions src/test/resources/__files/mock/example_dms.json
Original file line number Diff line number Diff line change
@@ -53,10 +53,27 @@
"channels": [],
"_updatedAt": "2019-09-24T10:29:13.803Z"
}
},
{
"_id": "gtJdgvcKxTtWN4Q9wgwJdmvcKxTtWN4Q9w",
"usernames": [
"a.ason",
"a.ason"
],
"_updatedAt": "2019-07-04T13:11:57.603Z",
"t": "d",
"msgs": 2,
"ts": "2019-07-04T13:11:54.739Z",
"lm": "2019-07-04T13:11:57.545Z",
"usersCount": 1,
"uids": [
"gtJdgvcKxTtWN4Q9w",
"gtJdgvcKxTtWN4Q9w"
]
}
],
"offset": 0,
"count": 2,
"total": 2,
"count": 3,
"total": 3,
"success": true
}

0 comments on commit 4274448

Please sign in to comment.