feat: add member gpg keys

This commit is contained in:
Alexandre Teles 2024-01-16 15:31:07 -03:00
parent 60301fc30b
commit 80cdb3be6a
No known key found for this signature in database
GPG Key ID: DB1C7FA46B1007F0
6 changed files with 38 additions and 13 deletions

View File

@ -5,7 +5,7 @@ import pkgutil
from api.utils.versioning import get_version
# Dynamically import all modules in the 'api' package, excluding subdirectories
versioned_blueprints = {}
versioned_blueprints: dict[str, list] = {}
for finder, module_name, ispkg in pkgutil.iter_modules(["api"]):
if not ispkg:
# Import the module

View File

@ -102,13 +102,14 @@ class Contributor(dict):
html_url: str,
contributions: Optional[int] = None,
bio: Optional[str] = None,
keys: Optional[str] = None,
):
match contributions, bio:
case None, None:
match contributions, bio, keys:
case None, None, None:
dict.__init__(
self, login=login, avatar_url=avatar_url, html_url=html_url, bio=bio
self, login=login, avatar_url=avatar_url, html_url=html_url, bio=bio, keys=keys
)
case int(_), None:
case int(_), None, None:
dict.__init__(
self,
login=login,
@ -116,7 +117,7 @@ class Contributor(dict):
html_url=html_url,
contributions=contributions,
)
case None, str(_):
case None, str(_), None:
dict.__init__(
self,
login=login,
@ -124,7 +125,7 @@ class Contributor(dict):
html_url=html_url,
bio=bio,
)
case int(_), str(_):
case int(_), str(_), str(_):
dict.__init__(
self,
login=login,
@ -132,6 +133,16 @@ class Contributor(dict):
html_url=html_url,
contributions=contributions,
bio=bio,
keys=keys,
)
case None, str(_), str(_):
dict.__init__(
self,
login=login,
avatar_url=avatar_url,
html_url=html_url,
bio=bio,
keys=keys,
)
case _:
raise ValueError("Invalid arguments")

View File

@ -1,7 +1,7 @@
import asyncio
import os
from operator import eq
from typing import Optional
from typing import Any, Optional
import ujson
from aiohttp import ClientResponse
@ -107,6 +107,11 @@ class Github(Backend):
contributor,
)
if team_view:
filter_contributor[
"keys"
] = f"{base_url.replace('api.', '')}/{filter_contributor['login']}.gpg"
return Contributor(**filter_contributor)
@staticmethod
@ -372,7 +377,7 @@ class Github(Backend):
list[dict[str, str]]: A JSON object containing the contributors.
"""
def transform(data: dict, repository: GithubRepository) -> list:
def transform(data: dict, repository: GithubRepository) -> dict[str, Any]:
"""Transforms a dictionary from the input list into a list of dictionaries with the desired structure.
Args:

View File

@ -2,17 +2,17 @@
This module provides endpoints for pinging the API.
Routes:
- HEAD /ping: Ping the API.
- GET /ping: Ping the API.
"""
import os
from sanic import Blueprint, HTTPResponse, Request, response
from sanic_ext import openapi
ping: Blueprint = Blueprint(os.path.basename(__file__).strip(".py"))
ping: Blueprint = Blueprint(os.path.basename(__file__).rstrip(".py"))
@ping.head("/ping")
@ping.get("/ping")
@openapi.summary("Ping the API")
async def root(request: Request) -> HTTPResponse:
"""

View File

@ -1,5 +1,8 @@
# API Configuration
from typing import Any
backend: str = "github"
redis: dict[str, str | int] = {"host": "localhost", "port": 6379}
hostnames: list[str] = [
@ -137,7 +140,7 @@ links: list[dict[str, str | bool]] = [
},
]
default_info: dict[str, str | list[str | bool] | bool] = {
default_info: dict[str, Any] = {
"name": "ReVanced",
"about": "ReVanced was born out of Vanced's discontinuation and it is our goal to continue the legacy of what Vanced left behind. Thanks to ReVanced Patcher, it's possible to create long-lasting patches for nearly any Android app. ReVanced's patching system is designed to allow patches to work on new versions of the apps automatically with bare minimum maintenance.",
"branding": {

View File

@ -22,3 +22,9 @@ ignore_missing_imports = True
[mypy-sanic_testing.*]
ignore_missing_imports = True
[mypy-fire.*]
ignore_missing_imports = True
[mypy-cytoolz.*]
ignore_missing_imports = True