Merge pull request #541 from talvasconcelos/fix/streamlabsInv

fix streamalerts
This commit is contained in:
Arc 2022-03-07 04:17:15 +00:00 committed by GitHub
commit 7988e2c303
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View file

@ -60,7 +60,7 @@ class Service(BaseModel):
onchain: Optional[str] onchain: Optional[str]
servicename: str # Currently, this will just always be "Streamlabs" servicename: str # Currently, this will just always be "Streamlabs"
authenticated: bool # Whether a token (see below) has been acquired yet authenticated: bool # Whether a token (see below) has been acquired yet
token: Optional[int] # The token with which to authenticate requests token: Optional[str] # The token with which to authenticate requests
@classmethod @classmethod
def from_row(cls, row: Row) -> "Service": def from_row(cls, row: Row) -> "Service":

View file

@ -62,7 +62,7 @@
donationDialog: { donationDialog: {
show: false, show: false,
data: { data: {
name: '', name: null,
sats: '', sats: '',
message: '' message: ''
} }

View file

@ -7,6 +7,7 @@ from starlette.responses import RedirectResponse
from lnbits.core.crud import get_user from lnbits.core.crud import get_user
from lnbits.decorators import WalletTypeInfo, get_key_type from lnbits.decorators import WalletTypeInfo, get_key_type
from lnbits.extensions.satspay.models import CreateCharge
from lnbits.extensions.streamalerts.models import ( from lnbits.extensions.streamalerts.models import (
CreateDonation, CreateDonation,
CreateService, CreateService,
@ -113,17 +114,18 @@ async def api_create_donation(data: CreateDonation, request: Request):
service_id = data.service service_id = data.service
service = await get_service(service_id) service = await get_service(service_id)
charge_details = await get_charge_details(service.id) charge_details = await get_charge_details(service.id)
name = data.name name = data.name if data.name else "Anonymous"
description = f"{sats} sats donation from {name} to {service.twitchuser}" description = f"{sats} sats donation from {name} to {service.twitchuser}"
charge = await create_charge( create_charge_data = CreateCharge(
amount=sats, amount=sats,
completelink=f"https://twitch.tv/{service.twitchuser}", completelink=f"https://twitch.tv/{service.twitchuser}",
completelinktext="Back to Stream!", completelinktext="Back to Stream!",
webhook=webhook_base + "/streamalerts/api/v1/postdonation", webhook=webhook_base + "/streamalerts/api/v1/postdonation",
description=description, description=description,
**charge_details, **charge_details
) )
charge = await create_charge(user=charge_details["user"], data=create_charge_data)
await create_donation( await create_donation(
id=charge.id, id=charge.id,
wallet=service.wallet, wallet=service.wallet,