From 686fff945e0b4697aa74da404ce90534bb7b121d Mon Sep 17 00:00:00 2001 From: Jonas Kohl Date: Thu, 26 Dec 2024 20:12:34 +0100 Subject: Add async email and topic subscribing --- src/application/actions/subscribetopic/post.php | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/application/actions/subscribetopic/post.php (limited to 'src/application/actions/subscribetopic') diff --git a/src/application/actions/subscribetopic/post.php b/src/application/actions/subscribetopic/post.php new file mode 100644 index 0000000..78dad04 --- /dev/null +++ b/src/application/actions/subscribetopic/post.php @@ -0,0 +1,39 @@ +id = $topicId; + +if (!$db->fetch($topic)) { + http_response_code(404); + msg_error(__("No topic exists with this id")); + exit; +} + +$subscription = new Subscription; +$subscription->userId = $currentUser->id; +$subscription->topicId = $topic->id; + +if ($db->fetchWhere($subscription, ["user_id", "topic_id"])) { + $db->delete($subscription); +} else { + $subscription->id = $db->generateId(); + $db->insert($subscription); +} + +header("Location: ?_action=viewtopic&topic=" . urlencode($topic->id)); -- cgit v1.2.3