Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Migration to Robyn" #16

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .config/config_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,4 @@ job:
debug:
enable: true
profiling: false
nossl: false

extends:
workers: 4
process: 4
nossl: false
Empty file removed .logs/.gitkeep
Empty file.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Holo
Holo backend server.
# HoloBE
Holo (Hol0) backend server.

Powered by [Robyn](https://fastapi.tiangolo.com) with [Prisma](https://prisma.io) ([prisma-client-py](https://github.com/RobertCraigie/prisma-client-py))
Powered by [FastAPI](https://fastapi.tiangolo.com) with [Prisma](https://prisma.io) ([prisma-client-py](https://github.com/RobertCraigie/prisma-client-py))

## Getting Started
> [!WARNING]
> Holo is under development. Therefore, its use in a production environment is deprecated.
> HoloBE is under development. Therefore, its use in a production environment is deprecated.
By following this guide, you can build an instance of Hol0.

```shell
Expand All @@ -26,7 +26,7 @@ Hol0 is inspired by the following software:
- [ ] ActivityPub (1/8 done)
- [x] webfinger
- [ ] Person
<!-- - [ ] Instance Actor-->
- [ ] Instance Actor
- [ ] Inbox
- [ ] Outbox
- [ ] Post Activity To Remote
Expand All @@ -45,11 +45,11 @@ Hol0 is inspired by the following software:
- [ ] Misskey's summaly proxy support
- [ ] Allow registration to be approved/or invite code-based (from Misskey (and Sharkey))
- [ ] Frontend
- [ ] login
- [ ] signup
- [ ] CloudFlare Turnstile
- [x] login
- [x] signup
- [x] CloudFlare Turnstile
- [ ] password reset
- [ ] CloudFlare Turnstile
- [x] CloudFlare Turnstile
- [ ] Profile
- [ ] Note
- [ ] Render MFM
Expand Down
File renamed without changes.
54 changes: 54 additions & 0 deletions app/models/prisma/backend.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
model BEConfig { // 略してベーコn(((
id String @id @default("hol0")
host String @unique

name String @default("Hol0")
description String @default("An Interconnected Extensible Microblogging Platform🪐")

repositoryUrl String @default("https://github.com/hol0-dev/backend")
feedbackUrl String @default("https://github.com/hol0-dev/backend/issues")

admin String?
adminEmail String? // 実はメールアドレス以外も入る。

maintainerName String?
maintainerEmail String?

impressumUrl String?
tosUrl String?
privacyPolicyUrl String?

PushNotification Boolean @default(false)
SWPublicKey String?
SWPrivateKey String?

enableMail Boolean @default(false)
mailAddress String?
smtpHost String?
smtpPort String?
smtpUser String?
smtpPass String?
smtpSSL Boolean @default(false)

useObjectStorage Boolean @default(false)
s3BaseUrl String?
s3Bucket String?
s3Prefix String?
s3Endpoint String?
s3Region String @default("us-east-1")
s3AccessKey String?
s3SecretKey String?
s3useSSL Boolean @default(false)
s3ForcePathStyle Boolean @default(false)
s3setPublicRead Boolean @default(false)

enableTurnstile Boolean @default(false)
turnstileSiteKey String?
turnstileSecretKey String?

faviconUrl String?
appleTouchIconUrl String?
androidTouchIconUrl String?

themeColor String @default("#B0F7DD")
}
26 changes: 26 additions & 0 deletions app/models/prisma/channel.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
model ChannelFollow {
followeeId String @id
channelId String

createdAt DateTime @default(now())

channel Channel @relation(fields: [channelId], references: [id], onDelete: Cascade)
followee User @relation("channelFollowee", fields: [followeeId], references: [id], onDelete: Cascade)
}

model Channel {
id String @id

name String
description String

remote String?

createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")

host Instance? @relation(fields: [remote], references: [host])

followers ChannelFollow[]
notes Note[]
}
50 changes: 50 additions & 0 deletions app/models/prisma/instance.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
model Instance {
id String @id
host String @unique

usersCount Int @default(0)
notesCount Int @default(0)

name String?
description String?

iconUrl String
faviconUrl String
themeColor String @default("#ffffff")

firstRetrievedAt DateTime? @default(now())

isNotResponding Boolean? @default(false)
isSuspended Boolean? @default(false)
isBlocked Boolean? @default(false)
isSilenced Boolean? @default(false)

softwareName String?
softwareVersion String?
softwareHomepage String?

openRegistrations Boolean

adminName String?
adminEmail String?

maintainerName String?
maintainerEmail String?

infoUpdatedAt DateTime @default(now())
latestRequestReceivedAt DateTime @default(now())

moderationNote String?

langs String[]

tosUrl String?
privacyPolicyUrl String?
inquiryUrl String?
impressumUrl String?
repositoryUrl String?
feedbackUrl String?

channels Channel[]
user User[]
}
53 changes: 53 additions & 0 deletions app/models/prisma/note.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
model Reactions {
id String @id @default(cuid())

noteId String
userId String

note Note @relation(fields: [noteId], references: [id])
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model File {
id String @id
hash String @unique

url String

isSensitive Boolean

fileSize Int?
fileType String

caption String?

createdAt DateTime @default(now()) @map("created_at")
attachedNotes Note[] @relation("AttachmentsToNote")
}

model Note {
id String @id

content String?
content_html String?

username String

createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")

visibility String
visibleUserIds String[]

replyId String?
renoteId String?

channelId String?
channel Channel? @relation(fields: [channelId], references: [id], onDelete: Cascade)

authorId String
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)

reactions Reactions[]
attachments File[] @relation("AttachmentsToNote")
}
8 changes: 8 additions & 0 deletions app/models/prisma/schema.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
generator client {
provider = "prisma-client-py"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
78 changes: 78 additions & 0 deletions app/models/prisma/user.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
model Field {
id String @id
authorId String

name String
value String

user User @relation(fields: [authorId], references: [id])
}

model User {
id String @id
host String
username String

email String? @unique
password String? // BackendやWheet経由ではパスワードなしのユーザーは作成できない。ただシステムのユーザー用にNoneなパスワードも設定できるようになってる

displayName String?
description String?

avatarUrl String?
bannerUrl String?

bday DateTime?
address String?

manuallyApprovesFollowers Boolean @default(false)
discoverable Boolean @default(true)

publicKeyPem String
publicKeyOwner String

privateKeyPem String?

accessTokens AccessToken[]
channelFollowees ChannelFollow[] @relation("channelFollowee")
notes Note[]
reactions Reactions[]
fields Field[]
followees Follow[] @relation("followee")
followers Follow[] @relation("follower")
instance Instance? @relation(fields: [host], references: [host])
}

model Follow {
followerId String
followeeId String

createdAt DateTime @default(now())

followee User @relation("followee", fields: [followeeId], references: [id], onDelete: Cascade)
follower User @relation("follower", fields: [followerId], references: [id], onDelete: Cascade)

@@id([followerId, followeeId])
}


model AccessToken {
id String @id

createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt
expiresAt DateTime?

name String

scope String[] // if WebClient: web:read, web:write

token String @unique

userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)

fromWeb Boolean @default(false)

@@index([token])
}
4 changes: 2 additions & 2 deletions src/app/routes/__init__.py → app/routes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from robyn import SubRouter
from fastapi import APIRouter

from . import activitypub, avatar

router = SubRouter("Holo")
router = APIRouter()
router.include_router(activitypub.router)
router.include_router(avatar.router)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from robyn import SubRouter
from fastapi import APIRouter

from . import well_known, nodeinfo, box, actors

router = SubRouter("Holo")
router = APIRouter()
router.include_router(well_known.router)
router.include_router(nodeinfo.router)
router.include_router(box.router)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import logging

from prisma.models import User
from robyn import SubRouter, Response, jsonify, Request

from fastapi import APIRouter
from fastapi.requests import Request
from fastapi.responses import ORJSONResponse, Response
from prisma.models import BEConfig

router = SubRouter("Holo")
router = APIRouter(include_in_schema=False)
logger: logging.Logger = None


Expand Down Expand Up @@ -82,7 +83,7 @@ async def users(request: Request, userid: str):
"sensitive": False,
"name": None,
}
return Response(jsonify(actor), headers={"Content-Type": "application/activity+json"})
return ORJSONResponse(actor, media_type="application/activity+json")


"""
Expand Down
Loading
Loading