From ed25dffea36ab8f78d37962b858fbf9d10ead777 Mon Sep 17 00:00:00 2001 From: Mystikfluu Date: Tue, 12 Jul 2022 14:49:28 +0200 Subject: [PATCH] add getChannels api endpoint --- createSchema.sql | 1 + server.js | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/createSchema.sql b/createSchema.sql index 4652d8e..d68d0ad 100644 --- a/createSchema.sql +++ b/createSchema.sql @@ -26,6 +26,7 @@ CREATE TABLE `posts` ( `post_time` bigint NOT NULL, `post_special_text` varchar(100) DEFAULT NULL, `post_receiver_name` varchar(100) DEFAULT NULL, + `post_is_private` tinyint DEFAULT '0', `post_from_bot` tinyint DEFAULT '0', `post_reply_id` bigint unsigned DEFAULT NULL, PRIMARY KEY (`post_id`) diff --git a/server.js b/server.js index 75a4134..e1e9493 100644 --- a/server.js +++ b/server.js @@ -738,6 +738,15 @@ router.get("/api/getPersonalPosts", async function(req,res) { }); }) +router.get("/api/getChannels", async function(req,res) { + res.set("Access-Control-Allow-Origin","*") + let sql = `select post_receiver_name from ipost.posts where post_is_private = false group by post_receiver_name order by post_id desc;` + con.query(sql, [], function (err, result) { + if (err) throw err; + res.json(result) + }); +}) + router.post("/api/setBio", async function(req,res) { res.set("Access-Control-Allow-Origin","") let bio = req.body.Bio