2023-11-29 17:01:31 -05:00
|
|
|
import { inject as service } from "@ember/service";
|
2018-09-12 11:16:18 -04:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
|
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
2020-05-12 14:24:33 -04:00
|
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
2017-07-24 11:13:53 -04:00
|
|
|
|
2023-12-11 14:00:34 -05:00
|
|
|
export default class Transcript extends DiscourseRoute {
|
2023-11-27 07:04:54 -05:00
|
|
|
@service currentUser;
|
|
|
|
@service composer;
|
|
|
|
@service router;
|
2017-07-24 11:13:53 -04:00
|
|
|
|
2023-11-27 07:04:54 -05:00
|
|
|
async model(params) {
|
|
|
|
if (!this.currentUser) {
|
2017-07-24 11:13:53 -04:00
|
|
|
this.session.set("shouldRedirectToUrl", window.location.href);
|
2023-11-27 07:04:54 -05:00
|
|
|
this.router.replaceWith("login");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
await this.router.replaceWith("discovery.latest").followRedirects();
|
|
|
|
|
|
|
|
try {
|
2023-12-11 14:00:34 -05:00
|
|
|
const result = await ajax(`/chat-transcript/${params.secret}`);
|
2023-11-27 07:04:54 -05:00
|
|
|
this.composer.openNewTopic({
|
|
|
|
body: result.content,
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
popupAjaxError(e);
|
2017-07-24 11:13:53 -04:00
|
|
|
}
|
2023-01-23 13:30:48 -05:00
|
|
|
}
|
|
|
|
}
|