Cleanup
This commit is contained in:
parent
727eb66aef
commit
db47653ca6
10 changed files with 14 additions and 81 deletions
53
.github/workflows/main.yml
vendored
53
.github/workflows/main.yml
vendored
|
|
@ -1,53 +0,0 @@
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- "v[0-9]+.[0-9]+.[0-9]+"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
|
|
||||||
release:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Create github release
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
tag: ${{ github.ref_name }}
|
|
||||||
run: |
|
|
||||||
gh release create "$tag" --generate-notes
|
|
||||||
pullrequest:
|
|
||||||
needs: [release]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.EXT_GITHUB }}
|
|
||||||
repository: lnbits/lnbits-extensions
|
|
||||||
path: './lnbits-extensions'
|
|
||||||
|
|
||||||
- name: setup git user
|
|
||||||
run: |
|
|
||||||
git config --global user.name "alan"
|
|
||||||
git config --global user.email "alan@lnbits.com"
|
|
||||||
- name: Create pull request in extensions repo
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.EXT_GITHUB }}
|
|
||||||
repo_name: "${{ github.event.repository.name }}"
|
|
||||||
tag: "${{ github.ref_name }}"
|
|
||||||
branch: "update-${{ github.event.repository.name }}-${{ github.ref_name }}"
|
|
||||||
title: "[UPDATE] ${{ github.event.repository.name }} to ${{ github.ref_name }}"
|
|
||||||
body: "https://github.com/lnbits/${{ github.event.repository.name }}/releases/${{ github.ref_name }}"
|
|
||||||
archive: "https://github.com/lnbits/${{ github.event.repository.name }}/archive/refs/tags/${{ github.ref_name }}.zip"
|
|
||||||
run: |
|
|
||||||
cd lnbits-extensions
|
|
||||||
git checkout -b $branch
|
|
||||||
# if there is another open PR
|
|
||||||
git pull origin $branch || echo "branch does not exist"
|
|
||||||
sh util.sh update_extension $repo_name $tag
|
|
||||||
git add -A
|
|
||||||
git commit -am "$title"
|
|
||||||
git push origin $branch
|
|
||||||
# check if pr exists before creating it
|
|
||||||
gh config set pager cat
|
|
||||||
check=$(gh pr list -H $branch | wc -l)
|
|
||||||
test $check -ne 0 || gh pr create --title "$title" --body "$body" --repo lnbits/lnbits-extensions
|
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1 +1 @@
|
||||||
__pycache__
|
__pycache__
|
||||||
12
__init__.py
12
__init__.py
|
|
@ -7,13 +7,13 @@ from lnbits.helpers import template_renderer
|
||||||
from lnbits.tasks import create_permanent_unique_task
|
from lnbits.tasks import create_permanent_unique_task
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
logger.debug("This logged message is from myextension/__init__.py, you can debug in your extension using 'import logger from loguru' and 'logger.debug(<thing-to-log>)'.")
|
logger.debug(
|
||||||
|
"This logged message is from myextension/__init__.py, you can debug in your extension using 'import logger from loguru' and 'logger.debug(<thing-to-log>)'."
|
||||||
|
)
|
||||||
|
|
||||||
db = Database("ext_myextension")
|
db = Database("ext_myextension")
|
||||||
|
|
||||||
myextension_ext: APIRouter = APIRouter(
|
myextension_ext: APIRouter = APIRouter(prefix="/myextension", tags=["MyExtension"])
|
||||||
prefix="/myextension", tags=["MyExtension"]
|
|
||||||
)
|
|
||||||
|
|
||||||
myextension_static_files = [
|
myextension_static_files = [
|
||||||
{
|
{
|
||||||
|
|
@ -34,6 +34,7 @@ from .views_api import *
|
||||||
|
|
||||||
scheduled_tasks: list[asyncio.Task] = []
|
scheduled_tasks: list[asyncio.Task] = []
|
||||||
|
|
||||||
|
|
||||||
def myextension_stop():
|
def myextension_stop():
|
||||||
for task in scheduled_tasks:
|
for task in scheduled_tasks:
|
||||||
try:
|
try:
|
||||||
|
|
@ -41,6 +42,7 @@ def myextension_stop():
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logger.warning(ex)
|
logger.warning(ex)
|
||||||
|
|
||||||
|
|
||||||
def myextension_start():
|
def myextension_start():
|
||||||
task = create_permanent_unique_task("ext_myextension", wait_for_paid_invoices)
|
task = create_permanent_unique_task("ext_myextension", wait_for_paid_invoices)
|
||||||
scheduled_tasks.append(task)
|
scheduled_tasks.append(task)
|
||||||
|
|
|
||||||
1
crud.py
1
crud.py
|
|
@ -4,7 +4,6 @@ from lnbits.helpers import urlsafe_short_hash
|
||||||
from lnbits.lnurl import encode as lnurl_encode
|
from lnbits.lnurl import encode as lnurl_encode
|
||||||
from . import db
|
from . import db
|
||||||
from .models import CreateMyExtensionData, MyExtension
|
from .models import CreateMyExtensionData, MyExtension
|
||||||
from loguru import logger
|
|
||||||
from fastapi import Request
|
from fastapi import Request
|
||||||
from lnurl import encode as lnurl_encode
|
from lnurl import encode as lnurl_encode
|
||||||
import shortuuid
|
import shortuuid
|
||||||
|
|
|
||||||
1
lnurl.py
1
lnurl.py
|
|
@ -124,7 +124,6 @@ async def api_lnurl_withdraw(
|
||||||
name="myextension.api_lnurl_withdraw_callback",
|
name="myextension.api_lnurl_withdraw_callback",
|
||||||
)
|
)
|
||||||
async def api_lnurl_withdraw_cb(
|
async def api_lnurl_withdraw_cb(
|
||||||
request: Request,
|
|
||||||
myextension_id: str,
|
myextension_id: str,
|
||||||
pr: Optional[str] = None,
|
pr: Optional[str] = None,
|
||||||
k1: Optional[str] = None,
|
k1: Optional[str] = None,
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,8 @@
|
||||||
# Data models for your extension
|
# Data models for your extension
|
||||||
|
|
||||||
from sqlite3 import Row
|
from sqlite3 import Row
|
||||||
from typing import Optional, List
|
from typing import Optional
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from fastapi import Request
|
|
||||||
|
|
||||||
from lnbits.lnurl import encode as lnurl_encode
|
|
||||||
from urllib.parse import urlparse
|
|
||||||
|
|
||||||
|
|
||||||
class CreateMyExtensionData(BaseModel):
|
class CreateMyExtensionData(BaseModel):
|
||||||
|
|
|
||||||
4
tasks.py
4
tasks.py
|
|
@ -1,9 +1,7 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from loguru import logger
|
|
||||||
|
|
||||||
from lnbits.core.models import Payment
|
from lnbits.core.models import Payment
|
||||||
from lnbits.core.services import create_invoice, websocket_updater
|
from lnbits.core.services import websocket_updater
|
||||||
from lnbits.helpers import get_current_extension_name
|
from lnbits.helpers import get_current_extension_name
|
||||||
from lnbits.tasks import register_invoice_listener
|
from lnbits.tasks import register_invoice_listener
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@
|
||||||
</div>
|
</div>
|
||||||
</q-card>
|
</q-card>
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock %} {% block scripts %} {{ window_vars(user) }}
|
{% endblock %} {% block scripts %} {{ window_vars(user) }}
|
||||||
<script src="https://cdn.jsdelivr.net/npm/canvas-confetti@1.4.0/dist/confetti.browser.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/canvas-confetti@1.4.0/dist/confetti.browser.min.js"></script>
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@
|
||||||
(this page will still be accessible even if you have restricted
|
(this page will still be accessible even if you have restricted
|
||||||
access to your LNbits install).
|
access to your LNbits install).
|
||||||
<br /><br />
|
<br /><br />
|
||||||
In this example when a user pays the LNURLpay it triggers an event via a websocket waiting for the payment, which you can subscribe to somewhere using wss://{your-lnbits}/api/v1/ws/{the-id-of-this-record}
|
In this example when a user pays the LNURLpay it triggers an event via a websocket waiting for the payment,
|
||||||
|
which you can subscribe to somewhere using wss://{your-lnbits}/api/v1/ws/{the-id-of-this-record}
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<q-card-section class="q-pa-none">
|
<q-card-section class="q-pa-none">
|
||||||
<q-separator></q-separator>
|
<q-separator></q-separator>
|
||||||
|
|
|
||||||
11
views_api.py
11
views_api.py
|
|
@ -1,22 +1,13 @@
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
import json
|
|
||||||
|
|
||||||
import httpx
|
|
||||||
from fastapi import Depends, Query, Request
|
from fastapi import Depends, Query, Request
|
||||||
from lnurl import decode as decode_lnurl
|
|
||||||
from loguru import logger
|
|
||||||
from starlette.exceptions import HTTPException
|
from starlette.exceptions import HTTPException
|
||||||
|
|
||||||
from lnbits.core.crud import get_user
|
from lnbits.core.crud import get_user
|
||||||
from lnbits.core.models import Payment
|
|
||||||
from lnbits.core.services import create_invoice
|
from lnbits.core.services import create_invoice
|
||||||
from lnbits.core.views.api import api_payment
|
|
||||||
from lnbits.decorators import (
|
from lnbits.decorators import (
|
||||||
WalletTypeInfo,
|
WalletTypeInfo,
|
||||||
check_admin,
|
|
||||||
get_key_type,
|
get_key_type,
|
||||||
require_admin_key,
|
require_admin_key,
|
||||||
require_invoice_key,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from . import myextension_ext
|
from . import myextension_ext
|
||||||
|
|
@ -140,7 +131,7 @@ async def api_myextension_delete(
|
||||||
@myextension_ext.post(
|
@myextension_ext.post(
|
||||||
"/api/v1/myex/payment/{myextension_id}", status_code=HTTPStatus.CREATED
|
"/api/v1/myex/payment/{myextension_id}", status_code=HTTPStatus.CREATED
|
||||||
)
|
)
|
||||||
async def api_tpos_create_invoice(
|
async def api_myextension_create_invoice(
|
||||||
myextension_id: str, amount: int = Query(..., ge=1), memo: str = ""
|
myextension_id: str, amount: int = Query(..., ge=1), memo: str = ""
|
||||||
) -> dict:
|
) -> dict:
|
||||||
myextension = await get_myextension(myextension_id)
|
myextension = await get_myextension(myextension_id)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue