Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.

Commit 2df9ea5

Browse files
authored
Merge pull request #95 from Sigmapitech/feat/issue-79/(re)actions
fix(front): add node deletion
2 parents 59eac1e + 4e6fbd8 commit 2df9ea5

File tree

19 files changed

+347
-48
lines changed

19 files changed

+347
-48
lines changed

back/app/db/models/oauth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class OAuthToken(Base):
1212
access_token = Column(String(128), nullable=False)
1313
refresh_token = Column(String(128), nullable=True)
1414

15-
service_id = Column(Integer, ForeignKey("service.id"), nullable=False)
15+
service = Column(String, nullable=False)
1616

1717
scope = Column(String(512), nullable=True)
1818
expires_at = Column(DateTime, nullable=True)

back/app/db/models/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ class User(Base):
3030
back_populates="user",
3131
cascade="all, delete-orphan",
3232
passive_deletes=True,
33-
lazy="selectin"
33+
lazy="selectin",
3434
)

back/app/routes/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
routers = []
66
providers = (
7+
"about",
78
"auth",
89
"hello",
910
"workflow",
@@ -19,10 +20,12 @@
1920
try:
2021
mod = importlib.import_module(f".{mod_name}", __package__)
2122

22-
assert hasattr(mod, "router"), \
23-
f"Module {mod.__name__} is missing 'router' attribute"
24-
assert isinstance(mod.router, APIRouter), \
25-
f"'router' in module {mod.__name__} is not an APIRouter instance"
23+
assert hasattr(
24+
mod, "router"
25+
), f"Module {mod.__name__} is missing 'router' attribute"
26+
assert isinstance(
27+
mod.router, APIRouter
28+
), f"'router' in module {mod.__name__} is not an APIRouter instance"
2629
print(
2730
"Registering router from module:"
2831
f" {mod.__name__} with prefix: {mod.router.prefix}"

back/app/routes/about.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import time
2+
3+
from fastapi import APIRouter, Request
4+
from fastapi.responses import JSONResponse
5+
6+
from .oauth_base import OAuthProvider
7+
8+
router = APIRouter(prefix="")
9+
10+
11+
@router.get("/about.json")
12+
async def about_json(request: Request):
13+
client = request.client
14+
client_ip = client.host if client else "unknown"
15+
services = OAuthProvider.services.keys()
16+
return JSONResponse(
17+
{
18+
"client": {
19+
"host": client_ip,
20+
},
21+
"server": {
22+
"current_time": int(time.time()),
23+
"services": [
24+
{
25+
"name": service_name,
26+
"actions": [],
27+
"reactions": [],
28+
}
29+
for service_name in services
30+
],
31+
},
32+
}
33+
)

back/app/routes/auth.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ async def login_user(
6464
},
6565
)
6666
async def get_me(
67-
current_user = Depends(get_current_user),
67+
current_user=Depends(get_current_user),
6868
) -> UserSchema:
6969
connected_services = {token.service: True for token in current_user.tokens}
7070

@@ -73,6 +73,7 @@ async def get_me(
7373
services=connected_services,
7474
)
7575

76+
7677
@router.patch(
7778
"/credentials",
7879
response_model=UserBase,

back/app/routes/caldav/google.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Config(BaseModel):
4747
provider = OAuthProvider(
4848
package=__package__,
4949
config_model=Config,
50-
icon=(pathlib.Path(__file__).parent / "icon.svg").read_text()
50+
icon=(pathlib.Path(__file__).parent / "icon.svg").read_text(),
5151
)
5252

5353

back/app/routes/discord/discord.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Config(BaseModel):
3333
provider = OAuthProvider(
3434
package=__package__,
3535
config_model=Config,
36-
icon=(pathlib.Path(__file__).parent / "icon.svg").read_text()
36+
icon=(pathlib.Path(__file__).parent / "icon.svg").read_text(),
3737
)
3838

3939

back/app/routes/gmail/gmail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Config(BaseModel):
4949
provider = OAuthProvider(
5050
package=__package__,
5151
config_model=Config,
52-
icon=(pathlib.Path(__file__).parent / "icon.svg").read_text()
52+
icon=(pathlib.Path(__file__).parent / "icon.svg").read_text(),
5353
)
5454

5555

back/app/routes/oauth_base.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@ class OAuthProvider:
4444

4545
services = {}
4646

47-
def __init__(
48-
self,
49-
icon: str,
50-
package: str | None,
51-
config_model: Any
52-
):
47+
def __init__(self, icon: str, package: str | None, config_model: Any):
5348
assert package is not None, "Package name must be provided"
5449

5550
*_, service_name = package.split(".")
@@ -172,7 +167,7 @@ async def auth(self, code: str, state: str, db: AsyncSession):
172167
tokens = resp.json()
173168

174169
token = OAuthToken(
175-
user_id=user.id,
170+
owner_id=user.id,
176171
service=self.cfg.service,
177172
access_token=tokens.get("access_token"),
178173
refresh_token=tokens.get("refresh_token"),
@@ -294,6 +289,7 @@ async def me(self, user: User, db: AsyncSession):
294289

295290
router = APIRouter(prefix="/services", tags=["services"])
296291

292+
297293
@router.get("", response_model=dict[str, str])
298294
async def get_service_list():
299295
return OAuthProvider.services

back/app/routes/spotify/spotify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Config(BaseModel):
2929
provider = OAuthProvider(
3030
package=__package__,
3131
config_model=Config,
32-
icon=(pathlib.Path(__file__).parent / "icon.svg").read_text()
32+
icon=(pathlib.Path(__file__).parent / "icon.svg").read_text(),
3333
)
3434

3535

0 commit comments

Comments
 (0)