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";
|
2022-03-06 15:18:46 -05:00
|
|
|
import { next } from "@ember/runloop";
|
2017-07-24 11:13:53 -04:00
|
|
|
|
2020-05-12 14:24:33 -04:00
|
|
|
export default DiscourseRoute.extend({
|
2019-07-27 10:04:42 -04:00
|
|
|
model(params) {
|
2017-10-03 05:42:07 -04:00
|
|
|
if (this.currentUser) {
|
2019-07-27 10:04:42 -04:00
|
|
|
const secret = params.secret;
|
2017-07-24 11:13:53 -04:00
|
|
|
|
2020-09-04 07:23:28 -04:00
|
|
|
this.replaceWith("discovery.latest").then((e) => {
|
2018-09-12 11:16:18 -04:00
|
|
|
if (this.controllerFor("navigation/default").get("canCreateTopic")) {
|
2022-03-06 15:18:46 -05:00
|
|
|
next(() => {
|
2020-09-04 07:23:28 -04:00
|
|
|
ajax(`chat-transcript/${secret}`).then((result) => {
|
2018-09-12 11:16:18 -04:00
|
|
|
e.send(
|
|
|
|
"createNewTopicViaParams",
|
|
|
|
null,
|
|
|
|
result["content"],
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null
|
|
|
|
);
|
2017-07-24 11:13:53 -04:00
|
|
|
}, popupAjaxError);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.session.set("shouldRedirectToUrl", window.location.href);
|
2018-09-12 11:16:18 -04:00
|
|
|
this.replaceWith("login");
|
2017-07-24 11:13:53 -04:00
|
|
|
}
|
2020-09-04 07:23:28 -04:00
|
|
|
},
|
2017-10-03 05:42:07 -04:00
|
|
|
});
|