-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Github App 安装的加回来
- Loading branch information
Showing
6 changed files
with
146 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use client'; | ||
|
||
import React from 'react'; | ||
|
||
export default function GithubAppInstalled() { | ||
return ( | ||
<div className="flex h-screen w-full flex-col items-center bg-white pb-16 pt-20 sm:pb-20 md:pt-36 lg:py-32"> | ||
<p className='font-display text-4xl font-bold tracking-tight text-slate-900'> | ||
Installation Approved | ||
</p> | ||
<p> | ||
Thank you for installing PeterCat's GitHub App! | ||
</p> | ||
<p> | ||
Your Team will now be able to use robots for your GitHub organization! | ||
</p> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from abc import abstractmethod | ||
|
||
class BaseDAO: | ||
@abstractmethod | ||
def get_client(): | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
import json | ||
from dao.BaseDAO import BaseDAO | ||
from models.authorization import Authorization | ||
from supabase.client import Client, create_client | ||
|
||
from petercat_utils.db.client.supabase import get_client | ||
|
||
class AuthorizationDAO(BaseDAO): | ||
client: Client | ||
|
||
def __init__(self): | ||
super().__init__() | ||
self.client = get_client() | ||
|
||
def exists(self, installation_id: str) -> bool: | ||
try: | ||
authorization = self.client.table("github_app_authorization")\ | ||
.select('*', count="exact")\ | ||
.eq('installation_id', installation_id) \ | ||
.execute() | ||
|
||
return bool(authorization.count) | ||
|
||
except Exception as e: | ||
print("Error: ", e) | ||
return {"message": "User creation failed"} | ||
|
||
def create(self, data: Authorization): | ||
print('supabase github_app_authorization creation', data.model_dump()) | ||
try: | ||
authorization = self.client.from_("github_app_authorization")\ | ||
.insert(data.model_dump())\ | ||
.execute() | ||
if authorization: | ||
return True, {"message": "User created successfully"} | ||
else: | ||
return False, {"message": "User creation failed"} | ||
except Exception as e: | ||
print("Error: ", e) | ||
return {"message": "User creation failed"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from datetime import datetime | ||
import json | ||
from pydantic import BaseModel, field_serializer | ||
from typing import Any, Dict | ||
|
||
class Authorization(BaseModel): | ||
token: str | ||
installation_id: str | ||
code: str | ||
created_at: datetime | ||
expires_at: datetime | ||
|
||
permissions: Dict | ||
|
||
@field_serializer('created_at') | ||
def serialize_created_at(self, created_at: datetime): | ||
return created_at.isoformat() | ||
|
||
@field_serializer('expires_at') | ||
def serialize_expires_at(self, expires_at: datetime): | ||
return expires_at.isoformat() | ||
|
||
@field_serializer('permissions') | ||
def serialize_permissions(self, permissions: Dict): | ||
return json.dumps(permissions) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters