Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
24abc44
Replace OTR.Room to class
albuquerquefabio Feb 11, 2022
fb2cadf
Improve promise
albuquerquefabio Feb 16, 2022
6965fad
Merge branch 'develop' into improve/otr-refactoring
albuquerquefabio Mar 8, 2022
0cea4a3
OTR ROOM to TS
albuquerquefabio Mar 8, 2022
fcb87c1
Fix EJSON issues
albuquerquefabio Mar 8, 2022
8097207
remove useless code
albuquerquefabio Mar 8, 2022
3e471ea
Fix stdout types
albuquerquefabio Mar 9, 2022
aeaa6ed
Moving OTR meteor startup to the right place
albuquerquefabio Mar 9, 2022
f38fd86
Remove imports defined but never used
albuquerquefabio Mar 9, 2022
1729844
Moving IOTR to the right place
albuquerquefabio Mar 9, 2022
5426c46
Fix: types and interface of OTR Room
albuquerquefabio Mar 10, 2022
82b87a3
Fix: types and interface of OTR Startup
albuquerquefabio Mar 10, 2022
3b5aad7
OTR Refactoring
albuquerquefabio Mar 10, 2022
199cfba
OTR startup logic update
albuquerquefabio Mar 10, 2022
8b898c1
Fix imports
albuquerquefabio Mar 10, 2022
a74a73b
remove: negative that is always true
albuquerquefabio Mar 11, 2022
76e7bfe
Types update
albuquerquefabio Mar 11, 2022
5299f06
OTR Functions
albuquerquefabio Mar 11, 2022
22d8815
Merge branch 'develop' into improve/otr-refactoring
albuquerquefabio Mar 11, 2022
be34b3c
Remove Braces from arrow functions
albuquerquefabio Mar 11, 2022
9f3fe16
Remove redundant vars
albuquerquefabio Mar 11, 2022
e78fcbe
Native crypto library
albuquerquefabio Mar 14, 2022
cf558fa
Fix: Type 'ArrayBuffer' is missing
albuquerquefabio Mar 14, 2022
47ecd67
Merge branch 'develop' into improve/otr-refactoring
albuquerquefabio Mar 15, 2022
71f14c9
Merge branch 'develop' into improve/otr-refactoring
albuquerquefabio Mar 23, 2022
2354e2e
Statistics telemetry on OTR
albuquerquefabio Mar 23, 2022
1644f22
Fix: imports and file paths
albuquerquefabio Apr 21, 2022
fd9d831
Merge branch 'develop' into improve/otr-refactoring
albuquerquefabio Apr 25, 2022
a594983
Merge branch 'develop' into improve/otr-refactoring
albuquerquefabio Apr 25, 2022
7a4aca6
Merge branch 'develop' into improve/otr-refactoring
albuquerquefabio Apr 26, 2022
53959a4
Fix IMessage quotes
albuquerquefabio Apr 26, 2022
5a2f9dc
Merge branch 'develop' into improve/otr-refactoring
albuquerquefabio May 3, 2022
e7f4f35
Fix: Property 'temp' on Message.tsx
albuquerquefabio May 3, 2022
3a23fe8
Merge branch 'develop' into improve/otr-refactoring
albuquerquefabio May 11, 2022
82f4ee7
Convert server methods to ts
debdutdeb May 15, 2022
5a6ac29
Move around files
debdutdeb May 15, 2022
3c581f3
Fix some types issues
albuquerquefabio May 17, 2022
3c95998
Merge branch 'develop' into improve/otr-refactoring
albuquerquefabio Jun 9, 2022
5a1398c
Chore: Statistics and telemetry
albuquerquefabio Jun 10, 2022
03e6d2f
Chore: interfaces
albuquerquefabio Jun 10, 2022
c46f0fc
Chore: changes requested
albuquerquefabio Jun 10, 2022
5468ad9
Remove underscore import
albuquerquefabio Jun 10, 2022
20cd772
Merge branch 'develop' into improve/otr-refactoring
albuquerquefabio Jun 10, 2022
82e69ce
Update statistics.ts
albuquerquefabio Jun 10, 2022
02b03da
Merge branch 'develop' into improve/otr-refactoring
albuquerquefabio Jun 13, 2022
7467c62
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into impr…
tassoevan Jul 26, 2022
4f509de
Encapsulate internal stte a little more
tassoevan Jul 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions apps/meteor/app/otr/client/OTR.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';

import { IOTR } from '../lib/IOTR';
import { Subscriptions } from '../../models/client';
import { OTRRoom } from './OTRRoom';

class OTR implements IOTR {
private enabled: ReactiveVar<boolean>;

private instancesByRoomId: { [rid: string]: OTRRoom };

constructor() {
this.enabled = new ReactiveVar(false);
this.instancesByRoomId = {};
}

isEnabled(): boolean {
return this.enabled.get();
}

setEnabled(enabled: boolean): void {
this.enabled.set(enabled);
}

getInstanceByRoomId(roomId: string): OTRRoom | undefined {
const userId = Meteor.userId();
if (!userId) {
return;
}
if (!this.enabled.get()) {
return;
}

if (this.instancesByRoomId[roomId]) {
return this.instancesByRoomId[roomId];
}

const subscription = Subscriptions.findOne({
rid: roomId,
});

if (!subscription || subscription.t !== 'd') {
return;
}

this.instancesByRoomId[roomId] = new OTRRoom(userId, roomId);
return this.instancesByRoomId[roomId];
}
}

export default new OTR();
Loading