CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/client/support.ts
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { replace_all } from "@cocalc/util/misc";
7
import * as message from "@cocalc/util/message";
8
import { AsyncCall } from "./client";
9
10
export class SupportTickets {
11
private async_call: AsyncCall;
12
13
constructor(async_call: AsyncCall) {
14
this.async_call = async_call;
15
}
16
17
private async call(message: object): Promise<any> {
18
return await this.async_call({ message, timeout: 30 });
19
}
20
21
public async create(opts): Promise<string> {
22
if (opts.body != null) {
23
// Make it so the session is ignored in any URL appearing in the body.
24
// Obviously, this is not 100% bullet proof, but should help enormously.
25
opts.body = replace_all(opts.body, "?session=", "?session=#");
26
}
27
return (await this.call(message.create_support_ticket(opts))).url;
28
}
29
30
public async get(): Promise<any> {
31
return (await this.call(message.get_support_tickets())).tickets;
32
}
33
}
34
35