1
0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2024-11-14 04:17:29 +00:00

Fix instance parameter when subscribing

This commit is contained in:
Cadence Ember 2020-09-01 01:51:24 +12:00
parent 0b178fc7a0
commit 850c9cca4a
No known key found for this signature in database
GPG Key ID: 128B99B1B74A6412

View File

@ -1,7 +1,7 @@
const {redirect} = require("pinski/plugins")
const db = require("./utils/db")
const constants = require("./utils/constants")
const {getToken} = require("./utils/getuser")
const {getUser} = require("./utils/getuser")
const validate = require("./utils/validate")
const V = validate.V
const {fetchChannel} = require("./utils/youtube")
@ -18,10 +18,12 @@ module.exports = [
.last(async state => {
const {params} = state
const responseHeaders = {}
const token = getToken(req, responseHeaders)
const user = getUser(req, responseHeaders)
const settings = user.getSettingsOrDefaults()
const token = user.token
if (add) {
await fetchChannel(ucid)
await fetchChannel(ucid, settings.instance)
db.prepare("INSERT OR IGNORE INTO Subscriptions (token, ucid) VALUES (?, ?)").run(token, ucid)
} else {
db.prepare("DELETE FROM Subscriptions WHERE token = ? AND ucid = ?").run(token, ucid)