support initiating 1-1 chats from matrix

This commit is contained in:
Robin Appelman 2020-05-09 14:00:33 +02:00
commit 3aa54d0cd2
2 changed files with 40 additions and 1 deletions

View file

@ -92,6 +92,8 @@ async function run() {
puppet.setCreateUserHook(steam.createUser.bind(steam)); puppet.setCreateUserHook(steam.createUser.bind(steam));
// puppet.setGetUserIdsInRoomHook(steam.getUserIdsInRoom.bind(steam)); // puppet.setGetUserIdsInRoomHook(steam.getUserIdsInRoom.bind(steam));
puppet.setListUsersHook(steam.listUsers.bind(steam)); puppet.setListUsersHook(steam.listUsers.bind(steam));
puppet.setGetDmRoomIdHook(steam.getDmRoomId.bind(steam));
puppet.setCreateRoomHook(steam.createRoom.bind(steam));
puppet.setGetDescHook(async (puppetId: number, data: any): Promise<string> => { puppet.setGetDescHook(async (puppetId: number, data: any): Promise<string> => {
let s = "Steam"; let s = "Steam";
if (data.screenName) { if (data.screenName) {

View file

@ -298,6 +298,43 @@ export class Steam {
})); }));
} }
public async getDmRoomId(user: IRemoteUser): Promise<string | null> {
log.info(`Got request for dm room id for ${user.userId}`);
if (!this.puppets[user.puppetId]) {
return null;
}
return user.userId;
}
public async createRoom(room: IRemoteRoom): Promise<IRemoteRoom | null> {
const p = this.puppets[room.puppetId];
if (!p) {
return null;
}
try {
let steamId = new SteamID(room.roomId);
if (!steamId.isValid()) {
throw new Error();
}
let persona = await this.getPersona(p, steamId);
log.info(`Got request to room user ${room.roomId}`);
return {
puppetId: room.puppetId,
roomId: room.roomId,
isDirect: true,
topic: persona.player_name
};
} catch (e) {
await this.bridge.sendStatusMessage(room.puppetId, `Creating group room chats is currently not supported`);
return null;
}
}
// public async getUserIdsInRoom(room: IRemoteRoom): Promise<Set<string> | null> { // public async getUserIdsInRoom(room: IRemoteRoom): Promise<Set<string> | null> {
// const p = this.puppets[room.puppetId]; // const p = this.puppets[room.puppetId];
// const client: TalkClient = p.client; // const client: TalkClient = p.client;