diff --git a/.bash_history b/.bash_history new file mode 100644 index 0000000..17e76d8 --- /dev/null +++ b/.bash_history @@ -0,0 +1,20 @@ +cat .config/systemd/user/caddy.service +screen +htop +free -m -h +quota +quota -h +ls +du -h +neofetch +ls -a +htop +free -m -h +ls +nest resources +ls +mutt +ls Mail/ +mutt +ls -a +exit diff --git a/.config/caddy/autosave.json b/.config/caddy/autosave.json index 37939fc..ba0a9ef 100644 --- a/.config/caddy/autosave.json +++ b/.config/caddy/autosave.json @@ -1,60 +1 @@ -{ - "admin": { "listen": "unix//home/neon/caddy-admin.sock" }, - "apps": { - "http": { - "servers": { - "srv0": { - "automatic_https": { "skip": ["spotify.hackclub.app"] }, - "listen": ["unix/.spotify.neon.hackclub.app.webserver.sock|777"], - "routes": [ - { - "handle": [ - { - "handler": "subroute", - "routes": [ - { - "handle": [ - { - "handler": "reverse_proxy", - "upstreams": [{ "dial": "localhost:38275" }] - } - ] - } - ] - } - ], - "match": [{ "host": ["spotify.hackclub.app"] }], - "terminal": true - } - ] - }, - "srv1": { - "automatic_https": { "skip": ["neon.hackclub.app"] }, - "listen": ["unix/.webserver.sock|777"], - "routes": [ - { - "handle": [ - { - "handler": "subroute", - "routes": [ - { - "handle": [ - { "handler": "vars", "root": "/home/neon/pub" }, - { - "handler": "file_server", - "hide": [".git", ".env", "/home/neon/Caddyfile"] - } - ] - } - ] - } - ], - "match": [{ "host": ["neon.hackclub.app"] }], - "terminal": true - } - ] - } - } - } - } -} +{"admin":{"listen":"unix//home/neon/caddy-admin.sock"},"apps":{"http":{"servers":{"srv0":{"automatic_https":{"skip":["neon.hackclub.app"]},"listen":["unix/.webserver.sock|777"],"routes":[{"handle":[{"handler":"subroute","routes":[{"handle":[{"handler":"vars","root":"/home/neon/pub"},{"handler":"file_server","hide":[".git",".env","/home/neon/Caddyfile"]}]}]}],"match":[{"host":["neon.hackclub.app"]}],"terminal":true}]}}}}} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 999c91b..14bac7d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,8 @@ *.sock -.npm .config/git .config/pulse # tokens -.config/caddy -Mail -sent -Mail/* # mail sent to neon@hackclub.app is here -sent/* # all sent mail is there +Mail # mail sent to neon@hackclub.app is here +sent # all sent mail is there .bun .local .nix-profile diff --git a/.lesshst b/.lesshst deleted file mode 100644 index 4d1c30b..0000000 --- a/.lesshst +++ /dev/null @@ -1 +0,0 @@ -.less-history-file: diff --git a/Caddyfile b/Caddyfile index ee5c743..12182d2 100644 --- a/Caddyfile +++ b/Caddyfile @@ -9,7 +9,3 @@ http://neon.hackclub.app { } } -http://spotify.hackclub.app { - bind unix/.spotify.sock|777 - reverse_proxy localhost:378625 -} diff --git a/Mail/.gitignore b/Mail/.gitignore deleted file mode 100644 index 72e8ffc..0000000 --- a/Mail/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/hackclub-spotify-bot/TODO.md b/hackclub-spotify-bot/TODO.md index d3c0890..7bf6c50 100644 --- a/hackclub-spotify-bot/TODO.md +++ b/hackclub-spotify-bot/TODO.md @@ -4,12 +4,12 @@ - - [x] oauth [docs](https://tools.slack.dev/node-slack-sdk/oauth) - - [ ] fix the [channel](https://app.slack.com/client/T0266FRGM/C07RE4N7S4B) - - - [x] Add ping for new-song event & send message ovs -- [x] Spotify +- [ ] Spotify - - [x] web api [docs](https://developer.spotify.com/documentation/web-api/) - - [x] oauth [docs](https://developer.spotify.com/documentation/general/guides/authorization-guide/) - - [x] refresh token [docs](https://developer.spotify.com/documentation/general/guides/authorization-guide/#refresh-an-access-token) - - [x] playlist tools (creation,modifcation,deletion) - [x] keydb (quick db or smthing) - [x] express -- [x] transparency of added songs -- - [x] export db -> into csv with properties (slack_id, url, added_at) +- [ ] transparency of added songs +- - [ ] export db -> into csv with properties (slack_id, url, added_at) diff --git a/hackclub-spotify-bot/src/index.js b/hackclub-spotify-bot/src/index.js index 1b2b721..98dca8d 100644 --- a/hackclub-spotify-bot/src/index.js +++ b/hackclub-spotify-bot/src/index.js @@ -17,20 +17,6 @@ const { QuickDB } = require("quick.db"); const db = new QuickDB({ filePath: "./data/songs.sqlite", }); - -function arrayToCsv(data) { - return data - .map( - (row) => - row - .map(String) // convert every value to String - .map((v) => v.replaceAll('"', '""')) // escape double quotes - .map((v) => `"${v}"`) // quote it - .join(","), // comma-separated - ) - .join("\r\n"); // rows starting on new lines -} - let cacheDb = {}; const app = express(); const userScopes = ["identity.avatar", "identity.basic", "identity.team"]; @@ -83,7 +69,7 @@ app.use( path: path.join(__dirname, "../data/sessions"), }), saveUninitialized: true, - cookie: { secure: "auto", maxAge: 1000 * 60 * 60 * 24 * 7 }, + cookie: { secure: "auto", maxAge: 1000 * 60 * 60 * 24 * 365 }, }), ); @@ -171,19 +157,6 @@ app.get("/home", async (req, res) => { s: req.query.s, }); }); -app.get("/download/db", async (req, res) => { - if (!req.session.info) return res.redirect("/login"); - const allSongs = await db.all(); - const csvData = arrayToCsv([ - ["slack_id", "url", "song_id", "added_at"], - ...allSongs.map((d) => { - return [d.value.added_by, d.value.song_url, d.id, d.value.added_at]; - }), - ]); - res.setHeader("Content-Type", "text/csv"); - res.setHeader("Content-Disposition", 'attachment; filename="songs.csv"'); - res.send(csvData); -}); app.post("/spotify/submitsong", async (req, res) => { if (!req.session.token) return res.redirect("/login"); if (!cacheDb[req.query.token]) return res.redirect(`/home?error=0`); @@ -257,10 +230,3 @@ app.listen(process.env.PORT || 3000, async () => { // if(!await db.has()) if (getCredentials() !== null) refreshToken(getCredentials().refresh_token); }); - -process.on("uncaughtException", function (err) { - console.log(err); -}); -process.on("unhandledRejection", function (err) { - console.log(err); -}); diff --git a/hackclub-spotify-bot/src/public/hackclub.css b/hackclub-spotify-bot/src/public/hackclub.css index 2c85c22..feb83cb 100644 --- a/hackclub-spotify-bot/src/public/hackclub.css +++ b/hackclub-spotify-bot/src/public/hackclub.css @@ -633,12 +633,3 @@ td { max-width: var(--size-narrow-plus); } } -/* custom additions */ -.error { - color: var(--red); - font-weight: bold; -} -.success { - color: var(--green); - font-weight: bold; -} diff --git a/hackclub-spotify-bot/src/views/home.ejs b/hackclub-spotify-bot/src/views/home.ejs index 75336fa..e3d4601 100644 --- a/hackclub-spotify-bot/src/views/home.ejs +++ b/hackclub-spotify-bot/src/views/home.ejs @@ -23,21 +23,18 @@