Giter Site home page Giter Site logo

mkizka / unsocial Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 0.0 4.05 MB

Simple ActivityPub server for personal use, built with Next.js (App Router), Prisma, and Tailwind CSS.

Home Page: https://beta.unsocial.dev

License: MIT License

Shell 1.12% TypeScript 96.97% JavaScript 1.29% CSS 0.41% Dockerfile 0.21%
activitypub fediverse microblog nextjs nodejs

unsocial's Introduction

Unsocial

 

Deployment Steps

Deploy on Railway

  1. Click on Deploy on Railway
  2. Click "Deploy Now"
  3. Configure and save config
  4. Click "Deploy"
  5. Wait for the deployment to finish
  6. Access https://${automatically_generated_subdomain}.up.railway.app

Features

  • Simple Deployment
  • Login with a single account on the server
  • Display Fediverse accounts
  • Federate posts (replies), likes, reposts, and follows
  • Registering relay servers
  • Fewer features, lightweight, and low cost

Supported ActivityPub Servers

  • Misskey
  • Mastodon

Contributing

unsocial's People

Contributors

mkizka avatar github-actions[bot] avatar renovate[bot] avatar

Stargazers

Alexandre Gressier avatar tinaxd avatar narirou avatar j00 avatar Osman Zeki avatar Daiki Maekawa avatar Lloyd Jose Fernandez avatar  avatar Сергей Ворон avatar Yukai Huang avatar 虹村晴好 avatar

Watchers

 avatar

unsocial's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: None
Error type: An existing branch is blocking Renovate
Message: Renovate needs to create the branch "renovate/pin-dependencies" but is blocked from doing so because of an existing branch called "renovate". Please remove it so that Renovate can proceed.

new URL使うのなるべくやめる

URLを扱う時は基本new URLするようにしてたけど、

  1. 毎回new URLがエラーになることを考慮しないといけない(new URLに渡す文字列がURLじゃないのは相当な例外)
  2. actorUrlなどurlで終わるフィールドでもDBから取ると文字列、変数ではURLインスタンスだったりしてどっちかわからない
  3. テストのアサーションで文字列比較の方がはっきり比較できる

hostを取る時などパースしたいときだけ使う

import * as とか export * as をやめる

  • index.tsから複数を再exportするとjest.mockするときに他のも巻き込まれる
  • importするときに関数を直接importするか".."みたいな分かりにくいパスからimportしないといけない
  • 対処法
    • 個別に判断、ディレクトリを切ってimportしやすくする(例えば型も一緒にexportしたい場合)か、ただのオブジェクトとしてexportする

actorへのfetchが連続で行われるのを防止する

  1. findOrFetchUserが失敗する(fetchが失敗するなど)
  2. user.lastFetchedAtが更新されない
  3. ページをリロードするたびにshouldRefetchが真になりfetchが呼ばれる

ということが起きる

対策1 ... fetch(GET)を一定時間内で連続で呼んだ場合はキャッシュから返すようにする
対策2 ... findOrFetchUserの最初にlastFetchedAtを更新する(失敗しても更新されるようにする)

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

asdf
.tool-versions
  • node 20.12.2
docker-compose
compose.yaml
  • nginx 1-alpine
  • yukimochi/activity-relay v2.0.5
  • yukimochi/activity-relay v2.0.5
  • nginx 1-alpine
  • nginx 1-alpine
  • tootsuite/mastodon v4.2.8
  • tootsuite/mastodon v4.2.8
  • tootsuite/mastodon v4.2.8
  • nginx 1-alpine
  • misskey/misskey 2024.3.1
  • postgres 16-alpine
  • redis 7-alpine
  • mailhog/mailhog v1.0.1
jest/compose.yaml
  • postgres 16-alpine
dockerfile
Dockerfile
github-actions
.github/workflows/_e2e-federation.yml
  • catchpoint/workflow-telemetry-action v2
  • actions/checkout v4
  • actions/cache v4
  • actions/setup-node v4
  • gh640/command-result-action v1
  • thollander/actions-comment-pull-request v2
.github/workflows/_mutation-test.yml
  • actions/checkout v4
  • actions/setup-node v4
  • gh640/command-result-action v1
  • thollander/actions-comment-pull-request v2
.github/workflows/_unit-test.yml
  • actions/checkout v4
  • actions/setup-node v4
.github/workflows/commit.yml
  • actions/create-github-app-token v1
  • actions/checkout v4
  • actions/setup-node v4
  • actions/create-github-app-token v1
  • actions/checkout v4
.github/workflows/pr.yml
  • actions/checkout v4
  • jdx/mise-action v2
.github/workflows/tag.yml
  • actions/checkout v4
  • docker/login-action v3
  • docker/setup-buildx-action v3
  • docker/metadata-action v5
  • docker/build-push-action v5
  • actions/checkout v4
  • actions/setup-node v4
  • actions/cache v4
npm
package.json
  • @aws-sdk/client-s3 3.556.0
  • @heroicons/react 2.1.3
  • @prisma/client 5.13.0
  • @sentry/nextjs 7.112.1
  • async-mutex 0.5.0
  • bcryptjs 2.4.3
  • class-variance-authority 0.7.0
  • clsx 2.1.1
  • jotai 2.8.0
  • jsonld 8.3.2
  • next 14.3.0-canary.21
  • next-auth 4.24.7
  • next-nprogress-bar 2.3.11
  • react 19.0.0-canary-e3ebcd54b-20240405
  • react-dom 19.0.0-canary-e3ebcd54b-20240405
  • react-simple-image-viewer 1.2.2
  • sanitize-html 2.13.0
  • server-only 0.0.1
  • sharp 0.33.3
  • swiper 11.1.1
  • tailwind-merge 2.3.0
  • zod 3.23.4
  • zod-validation-error 3.2.0
  • @changesets/cli 2.27.1
  • @eslint/eslintrc 3.0.2
  • @mkizka/eslint-config 4.1.1
  • @playwright/test 1.43.1
  • @quramy/jest-prisma-core 1.8.0
  • @quramy/jest-prisma-node 1.8.0
  • @quramy/prisma-fabbrica 2.1.2
  • @storybook/addon-essentials 8.0.9
  • @storybook/addon-interactions 8.0.9
  • @storybook/jest 0.2.3
  • @storybook/nextjs 8.0.9
  • @storybook/react 8.0.9
  • @storybook/test-runner 0.17.0
  • @storybook/testing-library 0.2.2
  • @stryker-mutator/api 8.2.6
  • @stryker-mutator/core 8.2.6
  • @stryker-mutator/jest-runner 8.2.6
  • @total-typescript/ts-reset 0.5.1
  • @types/bcryptjs 2.4.6
  • @types/eslint__eslintrc 2.1.1
  • @types/jest 29.5.12
  • @types/jsonld 1.5.13
  • @types/node 20.12.7
  • @types/react 18.2.79
  • @types/react-dom 18.2.25
  • @types/sanitize-html 2.11.0
  • @typescript-eslint/eslint-plugin 7.7.1
  • @typescript-eslint/parser 7.7.1
  • autoprefixer 10.4.19
  • cli-markdown 3.2.3
  • dotenv-cli 7.4.1
  • eslint 8.57.0
  • eslint-config-next 14.2.2
  • eslint-plugin-storybook 0.8.0
  • eslint-plugin-tailwindcss 3.15.1
  • husky 9.0.11
  • jest 29.7.0
  • jest-diff 29.7.0
  • jest-mock-extended 3.0.6
  • knip 5.10.0
  • lint-staged 15.2.2
  • msw 2.2.14
  • npm-run-all2 6.1.2
  • postcss 8.4.38
  • prettier 3.2.5
  • prettier-plugin-pkg 0.18.1
  • prettier-plugin-sh 0.14.0
  • prisma 5.13.0
  • storybook 8.0.9
  • tailwindcss 3.4.3
  • tailwindcss-animate 1.0.7
  • ts-node 10.9.2
  • tsx 4.7.2
  • typescript 5.4.5
  • wait-on 7.2.0
  • node 20.x
  • pnpm 9.0.5
regex
Dockerfile
  • node 20.12.2

  • Check this box to trigger a request for Renovate to run again on this repository

投稿時の画像添付をサポート

  • dockerにminio追加
  • 投稿時に画像を添付するUI追加(投稿はエラーにする)
  • 投稿時に画像添付されてたらS3にアップロードし、URLをDBに保存

next/imageやめる?

next/imageはリサイズした画像をキャッシュする?ためかメモリ使用率がすごく増えた
image

next/imageのリサイズだけ使ってキャッシュはさせないというのは出来なさそう
(CDN用にs-maxageを指定するとnext/imageがそれを使ってキャッシュしてしまう)
https://nextjs.org/docs/pages/api-reference/components/image#caching-behavior

リサイズは自分で実装して、キャッシュはCloudflareにさせるべき?

リポスト機能

用語の整理

概念 名前 変数名 変数の例
誰かの投稿を再投稿すること リポスト repost リポストボタンのハンドラ
再投稿そのもの コメントなし引用ノート noteWithQuote prismaの返り値
再投稿の元の投稿 引用されたノート note.quote または quotedNote prismaの返り値

Storybookに合わせてコンポーネントのファイル構造を見直す

例えばNoteなら

  • ServerNoteCard ... RSC(server-onlyあり)。サーバーサイド処理やserver actionsをimportする
    • NoteCard ... RSCかつRCC(use clientなし)。ServerNoteCardの値をバケツリレーする
      • LikeButton ... RCC(use clientあり)。server actionsを登録、値を受け取って表示

NoteCard, LikeButtonをStorybookでテストする

ServerNoteCardは単体テストがあるserviceロジックをimportして実行するだけにする

inboxのリファクタリング

  • 各処理をinboxServiceに移動
  • schemaを別ファイルに分ける
  • repositoryが失敗しても200か202を返すようにする

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.