mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-25 11:14:02 +02:00
Fixed a few bugs, started invoice endpoint
This commit is contained in:
@@ -170,8 +170,8 @@ new Vue({
|
|||||||
self.requestAuthorization()
|
self.requestAuthorization()
|
||||||
self.$q.notify({
|
self.$q.notify({
|
||||||
spinner: true,
|
spinner: true,
|
||||||
message: 'Fetching token',
|
message: 'Processing',
|
||||||
timeout: 4000
|
timeout: 10000
|
||||||
})
|
})
|
||||||
self.getSpotifyTokens()
|
self.getSpotifyTokens()
|
||||||
},
|
},
|
||||||
@@ -194,8 +194,33 @@ new Vue({
|
|||||||
if (self.jukeboxDialog.data.sp_access_token) {
|
if (self.jukeboxDialog.data.sp_access_token) {
|
||||||
self.refreshPlaylists()
|
self.refreshPlaylists()
|
||||||
self.refreshDevices()
|
self.refreshDevices()
|
||||||
self.step = 4
|
if (self.devices.length < 1 && self.playlists.length < 1) {
|
||||||
clearInterval(timerId)
|
self.$q.notify({
|
||||||
|
spinner: true,
|
||||||
|
color: 'red',
|
||||||
|
message:
|
||||||
|
'Error! Make sure Spotify is open on the device you wish to use, and it has playlists',
|
||||||
|
timeout: 10000
|
||||||
|
})
|
||||||
|
LNbits.api
|
||||||
|
.request(
|
||||||
|
'DELETE',
|
||||||
|
'/jukebox/api/v1/jukebox/' + response.data.id,
|
||||||
|
self.g.user.wallets[0].adminkey
|
||||||
|
)
|
||||||
|
.then(function (response) {
|
||||||
|
self.getJukeboxes()
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
LNbits.utils.notifyApiError(err)
|
||||||
|
})
|
||||||
|
clearInterval(timerId)
|
||||||
|
self.closeFormDialog()
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
self.step = 4
|
||||||
|
clearInterval(timerId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -229,7 +254,7 @@ new Vue({
|
|||||||
self.jukeboxDialog.show = false
|
self.jukeboxDialog.show = false
|
||||||
self.getJukeboxes()
|
self.getJukeboxes()
|
||||||
},
|
},
|
||||||
updateDB(){
|
updateDB() {
|
||||||
self = this
|
self = this
|
||||||
console.log(self.jukeboxDialog.data)
|
console.log(self.jukeboxDialog.data)
|
||||||
LNbits.api
|
LNbits.api
|
||||||
@@ -241,10 +266,10 @@ new Vue({
|
|||||||
)
|
)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
console.log(response.data)
|
console.log(response.data)
|
||||||
if(this.jukeboxDialog.data.devices){
|
if (self.jukeboxDialog.data.sp_playlists && self.jukeboxDialog.data.sp_devices) {
|
||||||
self.getJukeboxes()
|
self.getJukeboxes()
|
||||||
|
// self.JukeboxLinks.push(mapJukebox(response.data))
|
||||||
}
|
}
|
||||||
self.JukeboxLinks.push(mapJukebox(response.data))
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
playlistApi(method, url, body) {
|
playlistApi(method, url, body) {
|
||||||
@@ -258,9 +283,13 @@ new Vue({
|
|||||||
)
|
)
|
||||||
xhr.send(body)
|
xhr.send(body)
|
||||||
xhr.onload = function () {
|
xhr.onload = function () {
|
||||||
if(xhr.status == 401){
|
if (xhr.status == 401) {
|
||||||
self.refreshAccessToken()
|
self.refreshAccessToken()
|
||||||
self.playlistApi('GET', 'https://api.spotify.com/v1/me/playlists', null)
|
self.playlistApi(
|
||||||
|
'GET',
|
||||||
|
'https://api.spotify.com/v1/me/playlists',
|
||||||
|
null
|
||||||
|
)
|
||||||
}
|
}
|
||||||
let responseObj = JSON.parse(xhr.response)
|
let responseObj = JSON.parse(xhr.response)
|
||||||
self.jukeboxDialog.data.playlists = null
|
self.jukeboxDialog.data.playlists = null
|
||||||
@@ -289,9 +318,13 @@ new Vue({
|
|||||||
)
|
)
|
||||||
xhr.send(body)
|
xhr.send(body)
|
||||||
xhr.onload = function () {
|
xhr.onload = function () {
|
||||||
if(xhr.status == 401){
|
if (xhr.status == 401) {
|
||||||
self.refreshAccessToken()
|
self.refreshAccessToken()
|
||||||
self.deviceApi('GET', 'https://api.spotify.com/v1/me/player/devices', null)
|
self.deviceApi(
|
||||||
|
'GET',
|
||||||
|
'https://api.spotify.com/v1/me/player/devices',
|
||||||
|
null
|
||||||
|
)
|
||||||
}
|
}
|
||||||
let responseObj = JSON.parse(xhr.response)
|
let responseObj = JSON.parse(xhr.response)
|
||||||
self.jukeboxDialog.data.devices = []
|
self.jukeboxDialog.data.devices = []
|
||||||
@@ -332,11 +365,13 @@ new Vue({
|
|||||||
},
|
},
|
||||||
callAuthorizationApi(body) {
|
callAuthorizationApi(body) {
|
||||||
self = this
|
self = this
|
||||||
console.log(btoa(
|
console.log(
|
||||||
this.jukeboxDialog.data.sp_user +
|
btoa(
|
||||||
':' +
|
this.jukeboxDialog.data.sp_user +
|
||||||
this.jukeboxDialog.data.sp_secret
|
':' +
|
||||||
))
|
this.jukeboxDialog.data.sp_secret
|
||||||
|
)
|
||||||
|
)
|
||||||
let xhr = new XMLHttpRequest()
|
let xhr = new XMLHttpRequest()
|
||||||
xhr.open('POST', 'https://accounts.spotify.com/api/token', true)
|
xhr.open('POST', 'https://accounts.spotify.com/api/token', true)
|
||||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
|
||||||
|
@@ -16,7 +16,7 @@ from .crud import (
|
|||||||
delete_jukebox,
|
delete_jukebox,
|
||||||
)
|
)
|
||||||
from .models import Jukebox
|
from .models import Jukebox
|
||||||
|
from lnbits.core.services import create_invoice
|
||||||
|
|
||||||
@jukebox_ext.route("/api/v1/jukebox", methods=["GET"])
|
@jukebox_ext.route("/api/v1/jukebox", methods=["GET"])
|
||||||
@api_check_wallet_key("invoice")
|
@api_check_wallet_key("invoice")
|
||||||
@@ -180,3 +180,14 @@ async def api_get_token(sp_id):
|
|||||||
except AssertionError:
|
except AssertionError:
|
||||||
something = None
|
something = None
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
######GET INVOICE
|
||||||
|
|
||||||
|
|
||||||
|
@jukebox_ext.route("/api/v1/jukebox/jb/<sp_id>/<sp_song>/", methods=["GET"])
|
||||||
|
async def api_get_jukebox_invoice(sp_id, sp_song):
|
||||||
|
jukebox = await get_jukebox(sp_id)
|
||||||
|
invoice = await create_invoice(wallet_id=jukebox.wallet,amount=jukebox.amount,memo="Jukebox " + jukebox.name)
|
||||||
|
|
||||||
|
return invoice, HTTPStatus.OK
|
||||||
|
Reference in New Issue
Block a user