summaryrefslogtreecommitdiff
path: root/pages/api/pluralkit-integration.php
diff options
context:
space:
mode:
Diffstat (limited to 'pages/api/pluralkit-integration.php')
-rw-r--r--pages/api/pluralkit-integration.php120
1 files changed, 45 insertions, 75 deletions
diff --git a/pages/api/pluralkit-integration.php b/pages/api/pluralkit-integration.php
index 0793873..f5bb4dd 100644
--- a/pages/api/pluralkit-integration.php
+++ b/pages/api/pluralkit-integration.php
@@ -1,6 +1,6 @@
<?php
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/agewarning.inc";
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/agewarning.inc";
$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
$user = $_GET['user'] ?? null;
@@ -86,86 +86,56 @@ if ($input["type"] === "CREATE_SWITCH" || $input["type"] === "UPDATE_SWITCH" ||
}
}
- if ($system !== $app["other"]["id"] || !isset($app["other"])) {
- if (count($fronters["members"]) > 1) {
- $context = stream_context_create([
- 'http' => [
- 'method' => 'POST',
- 'header' =>
- "Content-Type: text/plain\r\n" .
- "Title: 🐴 Switch occurred in the $name\r\n" .
- "Priority: default\r\n" .
- "Tags: switch\r\n" .
- "Actions: view, Open " . $fronters["members"][0]["display_name"] . " on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true;view, Open " . $fronters["members"][1]["display_name"] . " on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][1]["name"] . "/, clear=true\r\n" .
- "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
- 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " and " . ($fronters["members"][1]["display_name"] ?? $fronters["members"][1]["name"]) . " switched in just now"
- ]
- ]);
- } else if (count($fronters["members"]) > 0) {
- $context = stream_context_create([
- 'http' => [
- 'method' => 'POST',
- 'header' =>
- "Content-Type: text/plain\r\n" .
- "Title: 🐴 Switch occurred in the $name\r\n" .
- "Priority: default\r\n" .
- "Tags: switch\r\n" .
- "Actions: view, Open on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true\r\n" .
- "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
- 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " switched in just now"
- ]
- ]);
- } else {
- $context = stream_context_create([
- 'http' => [
- 'method' => 'POST',
- 'header' =>
- "Content-Type: text/plain\r\n" .
- "Title: 🐴 Switch occurred in the $name\r\n" .
- "Priority: default\r\n" .
- "Tags: switch\r\n" .
- "Actions: view, Open on Cold Haze, https://ponies.equestria.horse/, clear=true\r\n" .
- "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
- 'content' => "The fallback pony switched in just now"
- ]
- ]);
- }
+ if (count($fronters["members"]) > 1) {
+ $context = stream_context_create([
+ 'http' => [
+ 'method' => 'POST',
+ 'header' =>
+ "Content-Type: text/plain\r\n" .
+ "Title: 🐴 Switch occurred in $name\r\n" .
+ "Priority: default\r\n" .
+ "Tags: switch\r\n" .
+ "Actions: view, Open " . $fronters["members"][0]["display_name"] . " on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true;view, Open " . $fronters["members"][1]["display_name"] . " on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][1]["name"] . "/, clear=true\r\n" .
+ "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
+ 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " and " . ($fronters["members"][1]["display_name"] ?? $fronters["members"][1]["name"]) . " switched in just now"
+ ]
+ ]);
+ } else if (count($fronters["members"]) > 0) {
+ $context = stream_context_create([
+ 'http' => [
+ 'method' => 'POST',
+ 'header' =>
+ "Content-Type: text/plain\r\n" .
+ "Title: 🐴 Switch occurred in $name\r\n" .
+ "Priority: default\r\n" .
+ "Tags: switch\r\n" .
+ "Actions: view, Open on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true\r\n" .
+ "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
+ 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " switched in just now"
+ ]
+ ]);
+ } else {
+ $context = stream_context_create([
+ 'http' => [
+ 'method' => 'POST',
+ 'header' =>
+ "Content-Type: text/plain\r\n" .
+ "Title: 🐴 Switch occurred in $name\r\n" .
+ "Priority: default\r\n" .
+ "Tags: switch\r\n" .
+ "Actions: view, Open on Cold Haze, https://ponies.equestria.horse/, clear=true\r\n" .
+ "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
+ 'content' => "The fallback pony switched in just now"
+ ]
+ ]);
+ }
+ if ($system !== $app["other"]["id"] || !isset($app["other"])) {
file_get_contents('https://' . $ntfy["server"] . '/public-switches', false, $context);
}
if ($system === "gdapd") {
$topic = "public-switches-raindrops";
-
- if (count($fronters["members"]) > 0) {
- file_get_contents('https://' . $ntfy["server"] . '/public-switches-fr', false, stream_context_create([
- 'http' => [
- 'method' => 'POST',
- 'header' =>
- "Content-Type: text/plain\r\n" .
- "Title: 🐴 $name vient de switch\r\n" .
- "Priority: default\r\n" .
- "Tags: switch\r\n" .
- "Actions: view, Voir sur Cold Haze, https://fr.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true\r\n" .
- "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
- 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " est désormais au front"
- ]
- ]));
- } else {
- file_get_contents('https://' . $ntfy["server"] . '/public-switches-fr', false, stream_context_create([
- 'http' => [
- 'method' => 'POST',
- 'header' =>
- "Content-Type: text/plain\r\n" .
- "Title: 🐴 $name vient de switch\r\n" .
- "Priority: default\r\n" .
- "Tags: switch\r\n" .
- "Actions: view, Voir sur Cold Haze, https://fr.equestria.horse/, clear=true\r\n" .
- "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
- 'content' => "Le poney de trait est désormais au front"
- ]
- ]));
- }
} else if ($system === "ynmuc") {
$topic = "public-switches-cloudburst";
} else {