@openinc/parse-server-opendash
Version:
Parse Server Cloud Code for open.INC Stack.
31 lines (30 loc) • 1.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTicketLink = getTicketLink;
const config_1 = require("../../config");
/**
* Returns the link to a ticket.
* @param ticket
* @returns
*/
async function getTicketLink(ticket, user) {
//Get hostname from tenant or environment variable or default to localhost
let hostname = "localhost";
const tenant = (await user.fetchWithInclude("tenant", { useMasterKey: true })).get("tenant");
try {
const baseurl = tenant?.get("baseUrl");
const publicurl = config_1.ConfigInstance.getInstance()
.get("PARSE_PUBLIC_SERVER_URL")
.replace("/parse", "");
if (baseurl !== undefined && baseurl !== "") {
hostname = baseurl;
}
else if (publicurl) {
hostname = publicurl;
}
}
catch (error) {
console.warn("[@openinc/parse-server-opendash] Could not get a hostname, defaulting to localhost");
}
return `${hostname}/openservice/ticket/${ticket.id}`;
}