Skip to content

Commit

Permalink
Update unban link to use prime URL as well
Browse files Browse the repository at this point in the history
  • Loading branch information
sylveon committed Aug 30, 2021
1 parent fc4cc5e commit 6693089
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ function replaceInFile(file, original, replacement) {
}

async function main() {
const url = process.env.CONTEXT === "production" ? process.env.URL : process.env.DEPLOY_PRIME_URL;
replaceInFile(path.resolve(__dirname, "func", "oauth.js"), "DEPLOY_PRIME_URL", `"${url}"`);
replaceInFile(path.resolve(__dirname, "func", "oauth-callback.js"), "DEPLOY_PRIME_URL", `"${url}"`);
replaceInFile(path.resolve(__dirname, "func", "submission-created.js"), "DEPLOY_PRIME_URL", `"${url}"`);

if (!process.env.USE_NETLIFY_FORMS) {
fs.rename(path.resolve(__dirname, "func", "submission-created.js"), path.resolve(__dirname, "func", "submit-appeal.js"), assertSuccess);
replaceInFile(path.resolve(__dirname, "public", "form.html"), "action=\"/success\" netlify", "action=\"/.netlify/functions/submit-appeal\"");
Expand All @@ -28,10 +33,6 @@ async function main() {
fs.unlink(path.resolve(__dirname, "func", "unban.js"), assertSuccess);
}

const url = process.env.CONTEXT === "production" ? process.env.URL : process.env.DEPLOY_PRIME_URL;
replaceInFile(path.resolve(__dirname, "func", "oauth.js"), "DEPLOY_PRIME_URL", `"${url}"`);
replaceInFile(path.resolve(__dirname, "func", "oauth-callback.js"), "DEPLOY_PRIME_URL", `"${url}"`);

// Make sure the bot connected to the gateway at least once.
const client = new Discord.Client();
try {
Expand Down
2 changes: 1 addition & 1 deletion func/submission-created.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ exports.handler = async function (event, context) {
}

if (!process.env.DISABLE_UNBAN_LINK) {
const unbanUrl = new URL("/.netlify/functions/unban", process.env.URL);
const unbanUrl = new URL("/.netlify/functions/unban", DEPLOY_PRIME_URL);
const unbanInfo = {
userId: userInfo.id
};
Expand Down

0 comments on commit 6693089

Please sign in to comment.