mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2024-11-20 10:39:59 +01:00
broke
This commit is contained in:
parent
430cbb8275
commit
ed60b7f6ee
@ -21,8 +21,8 @@ async def create_jukebox(
|
||||
juke_id = urlsafe_short_hash()
|
||||
result = await db.execute(
|
||||
"""
|
||||
INSERT INTO jukebox (id, user, title, wallet, sp_user, sp_secret, sp_access_token, sp_refresh_token, sp_device, sp_playlists, price, profit)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
INSERT INTO jukebox (id, user, title, wallet, sp_user, sp_secret, sp_access_token, sp_refresh_token, sp_device, sp_playlists, price, profit, queue)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
juke_id,
|
||||
@ -37,6 +37,7 @@ async def create_jukebox(
|
||||
sp_playlists,
|
||||
int(price),
|
||||
0,
|
||||
"[]",
|
||||
),
|
||||
)
|
||||
jukebox = await get_jukebox(juke_id)
|
||||
@ -84,14 +85,17 @@ async def delete_jukebox(juke_id: str):
|
||||
#####################################PAYMENTS
|
||||
|
||||
|
||||
async def create_jukebox_payment(song_id: str, payment_hash: str) -> JukeboxPayment:
|
||||
async def create_jukebox_payment(
|
||||
song_id: str, payment_hash: str, juke_id: str
|
||||
) -> JukeboxPayment:
|
||||
result = await db.execute(
|
||||
"""
|
||||
INSERT INTO jukebox_payment (payment_hash, song_id, paid)
|
||||
VALUES (?, ?, ?)
|
||||
INSERT INTO jukebox_payment (payment_hash, juke_id, song_id, paid)
|
||||
VALUES (?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
payment_hash,
|
||||
juke_id,
|
||||
song_id,
|
||||
False,
|
||||
),
|
||||
|
@ -19,7 +19,7 @@ async def m001_initial(db):
|
||||
price INTEGER,
|
||||
profit INTEGER,
|
||||
queue TEXT,
|
||||
last_checked
|
||||
last_checked TIMESTAMP NOT NULL DEFAULT (strftime('%s', 'now'))
|
||||
);
|
||||
"""
|
||||
)
|
||||
|
@ -184,7 +184,7 @@
|
||||
LNbits.api
|
||||
.request(
|
||||
'GET',
|
||||
'/api/v1/jukebox/jb/invoicepaid/' + self.receive.paymentHash + '/{{ juke_id }}')
|
||||
'/jukebox/api/v1/jukebox/jb/invoicep/{{ juke_id }}/' + self.receive.paymentHash)
|
||||
.then(function (response) {
|
||||
self.$q.notify({
|
||||
color: 'green',
|
||||
|
@ -5,6 +5,7 @@ from http import HTTPStatus
|
||||
import trio
|
||||
from lnbits.decorators import check_user_exists, validate_uuids
|
||||
from lnbits.core.models import Payment
|
||||
from functools import wraps
|
||||
|
||||
import json
|
||||
from . import jukebox_ext
|
||||
|
@ -203,32 +203,37 @@ async def api_get_jukebox_invoice(juke_id, song_id):
|
||||
extra={"tag": "jukebox"},
|
||||
)
|
||||
|
||||
jukebox_payment = await create_jukebox_payment(song_id, invoice[0])
|
||||
jukebox_payment = await create_jukebox_payment(song_id, invoice[0], juke_id)
|
||||
|
||||
return jsonify(invoice, jukebox_payment)
|
||||
|
||||
|
||||
@jukebox_ext.route(
|
||||
"/api/v1/jukebox/jb/invoicep/<juke_id>/<payment_hash>", methods=["GET"]
|
||||
)
|
||||
async def api_get_jukebox_invoice_paid(payment_hash, juke_id):
|
||||
@jukebox_ext.route("/api/v1/jukebox/jb/invoicep/<juke_id>/<pay_hash>", methods=["GET"])
|
||||
async def api_get_jukebox_invoice_paid(juke_id, pay_hash):
|
||||
jukebox = await get_jukebox(juke_id)
|
||||
print(jukebox)
|
||||
paid = await check_invoice_status(jukebox.wallet, payment_hash)
|
||||
if paid:
|
||||
jukebox_payment = await update_jukebox_payment(payment_hash, paid=True)
|
||||
paid = await check_invoice_status(jukebox.wallet, pay_hash)
|
||||
if paid.paid:
|
||||
jukebox_payment = await update_jukebox_payment(pay_hash, paid=True)
|
||||
else:
|
||||
return jsonify({"error": "Invoice not paid"})
|
||||
queue = await add_to_song_queue(jukebox_payment.song_id, jukebox_payment.juke_id)
|
||||
return queue
|
||||
|
||||
|
||||
@jukebox_ext.route("/api/v1/jukebox/jb/invoicep/<cunt>", methods=["GET"])
|
||||
async def api_get_jukebox_invoice_cunt(cunt):
|
||||
|
||||
return cunt
|
||||
|
||||
|
||||
############################QUEUE SONG
|
||||
|
||||
|
||||
async def add_to_song_queue(song_id, juke_id):
|
||||
jukebox = await get_jukebox(juke_id)
|
||||
queue = jukebox.queue
|
||||
print(queue[0])
|
||||
queue.append(song_id)
|
||||
# Add song to back of queue
|
||||
jukebox = await update_jukebox(juke_id=juke_id, queue=queue)
|
||||
|
Loading…
Reference in New Issue
Block a user