Stream Alerts: Fix donations table and default donor name "Anonymous" (#283)

This commit is contained in:
Fitti 2021-08-03 20:54:55 +02:00 committed by GitHub
parent 4a84204523
commit baf3b76c33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 23 deletions

View file

@ -101,37 +101,22 @@
dense dense
flat flat
:data="donations" :data="donations"
row-key="id"
:columns="donationsTable.columns" :columns="donationsTable.columns"
:pagination.sync="donationsTable.pagination" :pagination.sync="donationsTable.pagination"
> >
{% raw %} {% raw %}
<template v-slot:header="props"> <template v-slot:header="props">
<q-tr :props="props"> <q-tr :props="props">
<q-th auto-width></q-th>
<q-th v-for="col in props.cols" :key="col.name" :props="props"> <q-th v-for="col in props.cols" :key="col.name" :props="props">
{{ col.label }} {{ col.label }}
</q-th> </q-th>
</q-tr> </q-tr>
</template> </template>
<template v-slot:body="props"> <template v-slot:body="props">
<q-tr :props="props" v-if="props.row.paid"> <q-tr :props="props">
<q-td auto-width>
<q-btn
unelevated
dense
size="xs"
icon="email"
:color="($q.dark.isActive) ? 'grey-7' : 'grey-5'"
type="a"
:href="'mailto:' + props.row.email"
></q-btn>
</q-td>
<q-td v-for="col in props.cols" :key="col.name" :props="props"> <q-td v-for="col in props.cols" :key="col.name" :props="props">
{{ col.value }} {{ col.value }}
</q-td> </q-td>
<q-td auto-width> <q-td auto-width>
<q-btn <q-btn
flat flat
@ -341,9 +326,11 @@
label: 'Service', label: 'Service',
field: 'service' field: 'service'
}, },
{name: 'donor', align: 'left', label: 'Donor', field: 'donor'}, {name: 'id', align: 'left', label: 'Charge ID', field: 'id'},
{name: 'ltext', align: 'left', label: 'Message', field: 'ltext'}, {name: 'name', align: 'left', label: 'Donor', field: 'name'},
{name: 'sats', align: 'left', label: 'Sats', field: 'sats'} {name: 'message', align: 'left', label: 'Message', field: 'message'},
{name: 'sats', align: 'left', label: 'Sats', field: 'sats'},
{name: 'posted', align: 'left', label: 'Posted to API', field: 'posted'}
], ],
pagination: { pagination: {
rowsPerPage: 10 rowsPerPage: 10

View file

@ -2,7 +2,7 @@ from quart import g, redirect, request, jsonify
from http import HTTPStatus from http import HTTPStatus
from lnbits.decorators import api_validate_post_request, api_check_wallet_key from lnbits.decorators import api_validate_post_request, api_check_wallet_key
from lnbits.core.crud import get_wallet, get_user from lnbits.core.crud import get_user
from lnbits.utils.exchange_rates import btc_price from lnbits.utils.exchange_rates import btc_price
from . import streamalerts_ext from . import streamalerts_ext
@ -47,7 +47,6 @@ async def api_create_service():
return jsonify(service._asdict()), HTTPStatus.CREATED return jsonify(service._asdict()), HTTPStatus.CREATED
@streamalerts_ext.route("/api/v1/getaccess/<service_id>", methods=["GET"]) @streamalerts_ext.route("/api/v1/getaccess/<service_id>", methods=["GET"])
async def api_get_access(service_id): async def api_get_access(service_id):
"""Redirect to Streamlabs' Approve/Decline page for API access for Service """Redirect to Streamlabs' Approve/Decline page for API access for Service
@ -117,7 +116,9 @@ async def api_create_donation():
service_id = g.data["service"] service_id = g.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 = g.data.get("name", "Anonymous") name = g.data.get("name", "")
if not name:
name = "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( charge = await create_charge(
amount=sats, amount=sats,