Follow a begin curate/update curation workflow

This commit is contained in:
Daoud Clarke 2022-12-10 22:49:06 +00:00
parent 8aa51e548b
commit eadb7f3e28

View file

@ -21,11 +21,19 @@ class Login(BaseModel):
password: str
class BeginCurate(BaseModel):
auth: str
query: str
original_urls: list[str]
def create_router() -> APIRouter:
router = APIRouter(prefix="/user", tags=["user"])
community_id = get_community_id()
@router.post("/register")
def register_user(register: Register) -> Response:
def user_register(register: Register) -> Response:
lemmy_register = {
"username": register.username,
"email": register.email,
@ -41,8 +49,29 @@ def create_router() -> APIRouter:
return Response(content=request.content, status_code=request.status_code, media_type="text/json")
@router.post("/login")
def register_user(login: Login) -> Response:
def user_login(login: Login) -> Response:
request = requests.post(urljoin(LEMMY_URL, "api/v3/user/login"), json=login.dict())
return Response(content=request.content, status_code=request.status_code, media_type="text/json")
@router.post("/query/create")
def user_begin_curate(begin_curate: BeginCurate):
create_post = {
"auth": begin_curate.auth,
"body": None,
"community_id": community_id,
"honeypot": None,
"language_id": None,
"name": None,
"nsfw": None,
"url": None,
}
return router
def get_community_id() -> str:
request = requests.get(urljoin(LEMMY_URL, "api/v3/community?name=main"))
community = request.json()
return community["community_view"]["community"]["id"]