Add support for virtualUsers (Matrix)
Add support for virtualUsers
(Matrix)
Fix https://gitlab.com/gitlab-org/gitter/webapp/-/issues/1076

Dev notes
"virtualUser": {
"type": "matrix",
"externalId": "madlittlemods:matrix.org",
"displayName": "madlittlemods (Eric Eastwood)",
"avatarUrl": "https://matrix-client.matrix.org/_matrix/media/r0/thumbnail/matrix.org/bDayqThxTIcGNcskzIADknRv?width=30&height=30&method=crop"
},
Matrix avatars
https://matrix.org/docs/api/client-server/#!/User32data/getAvatarUrl
https://matrix-client.matrix.org/_matrix/client/r0/profile/%40madlittlemods%3Amatrix.org/avatar_url
{
// Where `matrix.org` and `bDayqThxTIcGNcskzIADknRv` are used in the next media request
"avatar_url": "mxc://matrix.org/bDayqThxTIcGNcskzIADknRv"
}
https://matrix-client.matrix.org/_matrix/media/r0/thumbnail/matrix.org/bDayqThxTIcGNcskzIADknRv?width=30&height=30&method=crop
Todo
-
Add flair/badges -
Threaded conversation -
Add tests -
Create matrix-bridge-prod
,matrix-bridge-beta
OAuth clients
Future iterations (will create follow-up issues for these):
-
Room bans -> https://gitlab.com/gitlab-org/gitter/webapp/-/issues/2615 -
Spam detection -> https://gitlab.com/gitlab-org/gitter/webapp/-/issues/2616 -
Chat message reports -> https://gitlab.com/gitlab-org/gitter/webapp/-/issues/2624 -
Typeahead -> https://gitlab.com/gitlab-org/gitter/webapp/-/issues/2617 -
Mentions -> https://gitlab.com/gitlab-org/gitter/webapp/-/issues/2618 -
Search -> https://gitlab.com/gitlab-org/gitter/webapp/-/issues/2619 -
User popover -> https://gitlab.com/gitlab-org/gitter/webapp/-/issues/2620 -
Unread notification emails -> https://gitlab.com/gitlab-org/gitter/webapp/-/issues/2621 -
Avatar sizes -> https://gitlab.com/gitlab-org/gitter/webapp/-/issues/2614
Testing strategy
- Create the OAuth client
db.oauthclients.insert({ clientKey: 'matrix-bridge-dev', clientSecret: Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15), name: 'Matrix bridge OAuth app', tag: 'matrix-bridge-dev' })
- Create a OAuth access token to use in our bridge
db.oauthaccesstokens.insert({ token: Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15), clientId: db.oauthclients.findOne({clientKey: 'matrix-bridge-dev' })._id, userId: db.users.findOne({ username: 'gitter-badger' })._id })
- You can find the token you just inserted with
db.oauthaccesstokens.find({ clientId: db.oauthclients.findOne({clientKey: 'matrix-bridge-dev' })._id }, { token: 1 })
- Test sending a message
POST http://localhost:5000/api/v1/rooms/5f7e2bc53279998d575e3546/chatMessages
(Authorization: Bearer xxx
,Content-Type: application/json
) with body:{ "virtualUser": { "type": "matrix", "externalId": "madlittlemods:matrix.org", "displayName": "madlittlemods (Eric Eastwood)", "avatarUrl": "https://matrix-client.matrix.org/_matrix/media/r0/thumbnail/matrix.org/bDayqThxTIcGNcskzIADknRv?width=30&height=30&method=crop" }, "text": "some message" }
- To test with threaded conversations: Find a message to thread on and add
parentId: <that parent message ID>
to the request above
- virtual users
Edited by Eric Eastwood