-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inbox: Add API to list conversations (#11110)
* Add API to list inbox conversations * fix test + add api doc * use `.lean()` * orderBy after the the grouped conversations are loaded * fix ordering
- Loading branch information
Showing
5 changed files
with
122 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { | ||
generateUser, | ||
} from '../../../helpers/api-integration/v4'; | ||
|
||
describe('GET /inbox/conversations', () => { | ||
let user; | ||
let otherUser; | ||
let thirdUser; | ||
|
||
before(async () => { | ||
[user, otherUser, thirdUser] = await Promise.all([generateUser(), generateUser(), generateUser()]); | ||
|
||
await otherUser.post('/members/send-private-message', { | ||
toUserId: user.id, | ||
message: 'first', | ||
}); | ||
await user.post('/members/send-private-message', { | ||
toUserId: otherUser.id, | ||
message: 'second', | ||
}); | ||
await user.post('/members/send-private-message', { | ||
toUserId: thirdUser.id, | ||
message: 'third', | ||
}); | ||
await otherUser.post('/members/send-private-message', { | ||
toUserId: user.id, | ||
message: 'fourth', | ||
}); | ||
|
||
// message to yourself | ||
await user.post('/members/send-private-message', { | ||
toUserId: user.id, | ||
message: 'fifth', | ||
}); | ||
}); | ||
|
||
it('returns the conversations', async () => { | ||
const result = await user.get('/inbox/conversations'); | ||
|
||
expect(result.length).to.be.equal(3); | ||
expect(result[0].user).to.be.equal(user.profile.name); | ||
expect(result[0].username).to.be.equal(user.auth.local.username); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters