Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MCS #132

Merged
merged 26 commits into from
Aug 29, 2022
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d7032d6
Add MCS api
weeman1337 Aug 12, 2022
25f2279
Add MCS UI
weeman1337 Aug 16, 2022
1042876
Use components from matrix-react-sdk.
weeman1337 Aug 22, 2022
f98400c
Move translations to tchap_translations
weeman1337 Aug 22, 2022
05e39a8
Make infected content less scary
weeman1337 Aug 22, 2022
68c3b4a
Drop NoopContentScanner; use server URL; rename var
weeman1337 Aug 22, 2022
075d3b1
Merge branch 'weeman1337/mcs-api' into weeman1337/mcs-ui
weeman1337 Aug 22, 2022
54b0067
Implement content scan API error handling
weeman1337 Aug 22, 2022
b5902ac
Extract scan() to async function
weeman1337 Aug 23, 2022
e4d40c8
Refactor ContentScanningDownloadActionButton
weeman1337 Aug 24, 2022
280b276
Rename pendingScans to cachedScans
weeman1337 Aug 24, 2022
531a35e
Extract fetchKey function
weeman1337 Aug 24, 2022
c796a3b
Remove local content scanner URL override
weeman1337 Aug 24, 2022
9f22df7
Use fetchKey
weeman1337 Aug 24, 2022
0599b51
Remove unused state
weeman1337 Aug 24, 2022
4588e70
Add content_scanner.url config option
weeman1337 Aug 25, 2022
535661a
Refactor ContentScanningDownloadActionButton
weeman1337 Aug 25, 2022
00e10d2
Let ContentScannerConfig extends IConfigOptions
weeman1337 Aug 25, 2022
2fdd144
Refactor contentScannerUrl
weeman1337 Aug 25, 2022
d7e350b
Fix ContentScanningDownloadActionButton
weeman1337 Aug 25, 2022
9886d2a
Merge branch 'develop_tchap' into weeman1337/mcs-api
weeman1337 Aug 25, 2022
c7638ad
Merge branch 'weeman1337/mcs-api' into weeman1337/mcs-ui
weeman1337 Aug 25, 2022
2eedf79
Update customisations
weeman1337 Aug 25, 2022
ce1a2cc
Fix wait for keys
weeman1337 Aug 25, 2022
eb02004
Migrate ContentScanningDownloadActionButton
weeman1337 Aug 25, 2022
04e808f
Remove postcss-strip-inline-comments
weeman1337 Aug 25, 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
9 changes: 5 additions & 4 deletions src/content-scanner/ContentScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class ContentScanner {

private mcsKey: PkEncryption = new global.Olm.PkEncryption();
private hasKey = false;
private pendingScans = new Map<string, Promise<boolean>>();
private cachedScans = new Map<string, Promise<boolean>>();

constructor(private scannerUrl: string) {
}
Expand Down Expand Up @@ -82,12 +82,12 @@ export class ContentScanner {
public async scan(mxc: string, file?: IEncryptedFile): Promise<boolean> {
// XXX: we're assuming that encryption won't be a differentiating factor and that the MXC URIs
// will be different.
if (this.pendingScans.has(mxc)) {
return this.pendingScans.get(mxc);
if (this.cachedScans.has(mxc)) {
return this.cachedScans.get(mxc);
}

const prom = this.doScan(mxc, file);
this.pendingScans.set(mxc, prom);
this.cachedScans.set(mxc, prom);
return prom;
}

Expand Down Expand Up @@ -123,6 +123,7 @@ export class ContentScanner {
public static get instance(): ContentScanner {
if (!ContentScanner.internalInstance) {
ContentScanner.internalInstance = new ContentScanner(MatrixClientPeg.get().getHomeserverUrl());
ContentScanner.internalInstance = new ContentScanner("http://localhost:9000");
weeman1337 marked this conversation as resolved.
Show resolved Hide resolved
}

return ContentScanner.internalInstance;
Expand Down