chatService.roomNeedsInvitation()
This commit is contained in:
17854
package-lock.json
generated
17854
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -23,7 +23,7 @@
|
||||
"@angular/platform-browser": "~11.2.6",
|
||||
"@angular/platform-browser-dynamic": "~11.2.6",
|
||||
"@angular/router": "~11.2.6",
|
||||
"angular-auth-oidc-client": "^11.6.4",
|
||||
"angular-auth-oidc-client": "^11.6.6",
|
||||
"matrix-js-sdk": "^9.9.0",
|
||||
"moment": "^2.29.1",
|
||||
"olm": "https://packages.matrix.org/npm/olm/olm-3.2.1.tgz",
|
||||
|
||||
@@ -16,7 +16,7 @@ export class User {
|
||||
return new User(
|
||||
claims["sub"].toString(),
|
||||
claims["preferred_username"].toString(),
|
||||
'@' + claims["preferred_username"] + ':synapse',
|
||||
'@' + claims["preferred_username"] + ':okupamicoche-synapse',
|
||||
claims["name"].toString(),
|
||||
claims["admin"] === true
|
||||
);
|
||||
|
||||
@@ -27,7 +27,7 @@ export class NewTravelComponent implements OnInit {
|
||||
.subscribe(res => {
|
||||
if (res.success) {
|
||||
console.log('Travel created');
|
||||
this.router.navigateByUrl('/');
|
||||
this.router.navigateByUrl('/travel/' + travel.id);
|
||||
}
|
||||
else {
|
||||
console.error('Error creating travel: ' + res.error.code + ' ' + res.error.msg);
|
||||
|
||||
@@ -4,12 +4,15 @@ import * as matrix from 'matrix-js-sdk';
|
||||
import { MatrixClient } from 'matrix-js-sdk/src/client';
|
||||
import { MatrixEvent } from 'matrix-js-sdk/src/models/event';
|
||||
import { Room, RoomMember } from 'matrix-js-sdk/src/models/room';
|
||||
import { SyncApi } from 'matrix-js-sdk/src/sync';
|
||||
import * as olm from 'olm';
|
||||
import { Observable } from 'rxjs';
|
||||
import { MatrixLoginDto } from '../entities/matrix-login-dto';
|
||||
import { ChatMessageHandler } from './chat-message-handler';
|
||||
global.Olm = olm;
|
||||
|
||||
const FORWARDS = 'f';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@@ -84,6 +87,18 @@ export class ChatService {
|
||||
return this.matrixClient.leave(roomId);
|
||||
}
|
||||
|
||||
roomNeedsInvitation = async (roomId: string): Promise<boolean> => {
|
||||
let room: Room = this.matrixClient.getRoom(roomId) as Room;
|
||||
if (room === null) {
|
||||
try {
|
||||
room = await this.matrixClient.peekInRoom(roomId);
|
||||
}
|
||||
catch (error) { return true; }
|
||||
}
|
||||
const joinRule = room.getLiveTimeline().getState(FORWARDS).getJoinRule();
|
||||
return joinRule === 'invite';
|
||||
}
|
||||
|
||||
private async loginWithToken(loginToken: string): Promise<MatrixClient> {
|
||||
const matrixLogin = await this.http.post<MatrixLoginDto>(
|
||||
'http://okupamicoche-synapse:8008/_matrix/client/r0/login',
|
||||
|
||||
@@ -33,6 +33,9 @@ export class ChatComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
console.log('Is in room: ' + this.chatService.isInRoom(this.roomId));
|
||||
console.log('Is invited to room: ' + this.chatService.isInvitedToRoom(this.roomId));
|
||||
this.chatService.roomNeedsInvitation(this.roomId).then(needsInvitation => {
|
||||
console.log('Room needs invitation: ' + needsInvitation);
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
|
||||
Reference in New Issue
Block a user