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