Merge pull request #463 from matrix-org/dbkr/flag_incoming_dms
Flag incoming DMs as such
This commit is contained in:
commit
f82629aed0
3 changed files with 33 additions and 0 deletions
|
@ -36,6 +36,7 @@ var dis = require("../../dispatcher");
|
||||||
var Tinter = require("../../Tinter");
|
var Tinter = require("../../Tinter");
|
||||||
var rate_limited_func = require('../../ratelimitedfunc');
|
var rate_limited_func = require('../../ratelimitedfunc');
|
||||||
var ObjectUtils = require('../../ObjectUtils');
|
var ObjectUtils = require('../../ObjectUtils');
|
||||||
|
var Rooms = require('../../Rooms');
|
||||||
|
|
||||||
import UserProvider from '../../autocomplete/UserProvider';
|
import UserProvider from '../../autocomplete/UserProvider';
|
||||||
|
|
||||||
|
@ -674,6 +675,20 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
|
|
||||||
display_name_promise.then(() => {
|
display_name_promise.then(() => {
|
||||||
|
// if this is an invite and has the 'direct' hint set, mark it as a DM room now.
|
||||||
|
if (this.state.room) {
|
||||||
|
const me = this.state.room.getMember(MatrixClientPeg.get().credentials.userId);
|
||||||
|
if (me.membership == 'invite') {
|
||||||
|
// The 'direct' hihnt is there, so declare that this is a DM room for
|
||||||
|
// whoever invited us.
|
||||||
|
if (me.events.member.getContent().is_direct) {
|
||||||
|
return Rooms.setDMRoom(this.state.room.roomId, me.events.member.getSender());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return q();
|
||||||
|
}).then(() => {
|
||||||
var sign_url = this.props.thirdPartyInvite ? this.props.thirdPartyInvite.inviteSignUrl : undefined;
|
var sign_url = this.props.thirdPartyInvite ? this.props.thirdPartyInvite.inviteSignUrl : undefined;
|
||||||
return MatrixClientPeg.get().joinRoom(this.props.roomAddress,
|
return MatrixClientPeg.get().joinRoom(this.props.roomAddress,
|
||||||
{ inviteSignUrl: sign_url } )
|
{ inviteSignUrl: sign_url } )
|
||||||
|
|
|
@ -57,6 +57,9 @@ function createRoom(opts) {
|
||||||
if (opts.dmUserId && createOpts.invite === undefined) {
|
if (opts.dmUserId && createOpts.invite === undefined) {
|
||||||
createOpts.invite = [opts.dmUserId];
|
createOpts.invite = [opts.dmUserId];
|
||||||
}
|
}
|
||||||
|
if (opts.dmUserId && createOpts.is_direct === undefined) {
|
||||||
|
createOpts.is_direct = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Allow guests by default since the room is private and they'd
|
// Allow guests by default since the room is private and they'd
|
||||||
// need an invite. This means clicking on a 3pid invite email can
|
// need an invite. This means clicking on a 3pid invite email can
|
||||||
|
|
|
@ -21,6 +21,7 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
export default class DMRoomMap {
|
export default class DMRoomMap {
|
||||||
constructor(matrixClient) {
|
constructor(matrixClient) {
|
||||||
|
this.matrixClient = matrixClient;
|
||||||
this.roomToUser = null;
|
this.roomToUser = null;
|
||||||
|
|
||||||
const mDirectEvent = matrixClient.getAccountData('m.direct');
|
const mDirectEvent = matrixClient.getAccountData('m.direct');
|
||||||
|
@ -49,6 +50,20 @@ export default class DMRoomMap {
|
||||||
}
|
}
|
||||||
// Here, we return undefined if the room is not in the map:
|
// Here, we return undefined if the room is not in the map:
|
||||||
// the room ID you gave is not a DM room for any user.
|
// the room ID you gave is not a DM room for any user.
|
||||||
|
if (this.roomToUser[roomId] === undefined) {
|
||||||
|
// no entry? if the room is an invite, look for the is_direct hint.
|
||||||
|
const room = this.matrixClient.getRoom(roomId);
|
||||||
|
if (room) {
|
||||||
|
const me = room.getMember(this.matrixClient.credentials.userId);
|
||||||
|
if (me.membership == 'invite') {
|
||||||
|
// The 'direct' hihnt is there, so declare that this is a DM room for
|
||||||
|
// whoever invited us.
|
||||||
|
if (me.events.member.getContent().is_direct) {
|
||||||
|
return me.events.member.getSender();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return this.roomToUser[roomId];
|
return this.roomToUser[roomId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue