From 7dfc52b68173305b4d669075984b61c736b57a98 Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 27 Nov 2023 18:17:53 +0900 Subject: [PATCH] chore: unsafe linting --- packages/backend/src/boot/index.ts | 2 +- packages/backend/src/boot/master.ts | 12 +- packages/backend/src/boot/worker.ts | 4 +- packages/backend/src/config/load.ts | 4 +- packages/backend/src/daemons/queue-stats.ts | 2 +- packages/backend/src/daemons/server-stats.ts | 6 +- packages/backend/src/db/elasticsearch.ts | 2 +- packages/backend/src/db/meilisearch.ts | 6 +- packages/backend/src/db/postgre.ts | 122 +++++++-------- packages/backend/src/db/redis.ts | 2 +- packages/backend/src/mfm/to-html.ts | 6 +- packages/backend/src/misc/antenna-cache.ts | 4 +- packages/backend/src/misc/before-shutdown.ts | 2 - packages/backend/src/misc/cache.ts | 2 +- packages/backend/src/misc/captcha.ts | 4 +- .../backend/src/misc/check-hit-antenna.ts | 12 +- packages/backend/src/misc/check-word-mute.ts | 2 +- packages/backend/src/misc/convert-host.ts | 2 +- packages/backend/src/misc/detect-language.ts | 2 +- packages/backend/src/misc/download-url.ts | 6 +- packages/backend/src/misc/emoji-meta.ts | 2 +- .../misc/extract-custom-emojis-from-mfm.ts | 2 +- packages/backend/src/misc/extract-hashtags.ts | 2 +- .../backend/src/misc/fetch-proxy-account.ts | 2 +- packages/backend/src/misc/fetch.ts | 6 +- packages/backend/src/misc/gen-id.ts | 2 +- packages/backend/src/misc/get-file-info.ts | 8 +- packages/backend/src/misc/id/aid.ts | 2 +- packages/backend/src/misc/keypair-store.ts | 4 +- packages/backend/src/misc/password.ts | 2 +- packages/backend/src/misc/populate-emojis.ts | 14 +- packages/backend/src/misc/post.ts | 2 +- .../backend/src/misc/process-masto-notes.ts | 14 +- packages/backend/src/misc/reaction-lib.ts | 6 +- packages/backend/src/misc/schema.ts | 56 +++---- .../backend/src/misc/show-machine-info.ts | 2 +- .../backend/src/misc/skipped-instances.ts | 8 +- packages/backend/src/misc/webhook-cache.ts | 4 +- .../src/models/entities/abuse-user-report.ts | 6 +- .../src/models/entities/access-token.ts | 12 +- packages/backend/src/models/entities/ad.ts | 2 +- .../src/models/entities/announcement-read.ts | 8 +- .../src/models/entities/announcement.ts | 2 +- .../backend/src/models/entities/antenna.ts | 8 +- packages/backend/src/models/entities/app.ts | 4 +- .../models/entities/attestation-challenge.ts | 10 +- .../src/models/entities/auth-session.ts | 12 +- .../backend/src/models/entities/blocking.ts | 6 +- .../src/models/entities/channel-following.ts | 6 +- .../models/entities/channel-note-pining.ts | 8 +- .../backend/src/models/entities/channel.ts | 6 +- .../backend/src/models/entities/clip-note.ts | 6 +- packages/backend/src/models/entities/clip.ts | 6 +- .../backend/src/models/entities/drive-file.ts | 8 +- .../src/models/entities/drive-folder.ts | 8 +- packages/backend/src/models/entities/emoji.ts | 2 +- .../src/models/entities/follow-request.ts | 6 +- .../backend/src/models/entities/following.ts | 6 +- .../src/models/entities/gallery-like.ts | 6 +- .../src/models/entities/gallery-post.ts | 6 +- .../backend/src/models/entities/hashtag.ts | 4 +- .../backend/src/models/entities/instance.ts | 2 +- .../src/models/entities/messaging-message.ts | 8 +- packages/backend/src/models/entities/meta.ts | 4 +- .../src/models/entities/moderation-log.ts | 6 +- .../backend/src/models/entities/muted-note.ts | 6 +- .../backend/src/models/entities/muting.ts | 6 +- .../backend/src/models/entities/note-edit.ts | 8 +- .../src/models/entities/note-favorite.ts | 6 +- .../src/models/entities/note-reaction.ts | 8 +- .../src/models/entities/note-thread-muting.ts | 6 +- .../src/models/entities/note-unread.ts | 8 +- .../src/models/entities/note-watching.ts | 8 +- packages/backend/src/models/entities/note.ts | 10 +- .../src/models/entities/notification.ts | 12 +- .../backend/src/models/entities/page-like.ts | 6 +- packages/backend/src/models/entities/page.ts | 6 +- .../models/entities/password-reset-request.ts | 6 +- .../backend/src/models/entities/poll-vote.ts | 8 +- packages/backend/src/models/entities/poll.ts | 6 +- .../backend/src/models/entities/promo-note.ts | 6 +- .../backend/src/models/entities/promo-read.ts | 6 +- .../models/entities/registration-tickets.ts | 2 +- .../src/models/entities/registry-item.ts | 6 +- packages/backend/src/models/entities/relay.ts | 2 +- .../src/models/entities/renote-muting.ts | 4 +- .../backend/src/models/entities/signin.ts | 6 +- .../src/models/entities/sw-subscription.ts | 6 +- .../src/models/entities/used-username.ts | 2 +- .../models/entities/user-group-invitation.ts | 8 +- .../src/models/entities/user-group-joining.ts | 8 +- .../backend/src/models/entities/user-group.ts | 6 +- .../backend/src/models/entities/user-ip.ts | 2 +- .../src/models/entities/user-keypair.ts | 4 +- .../src/models/entities/user-list-joining.ts | 8 +- .../backend/src/models/entities/user-list.ts | 6 +- .../src/models/entities/user-note-pining.ts | 6 +- .../src/models/entities/user-pending.ts | 2 +- .../src/models/entities/user-profile.ts | 8 +- .../src/models/entities/user-publickey.ts | 6 +- .../src/models/entities/user-security-key.ts | 10 +- packages/backend/src/models/entities/user.ts | 4 +- .../backend/src/models/entities/webhook.ts | 6 +- packages/backend/src/models/index.ts | 120 +++++++-------- .../models/repositories/abuse-user-report.ts | 2 +- .../backend/src/models/repositories/app.ts | 4 +- .../src/models/repositories/auth-session.ts | 4 +- .../src/models/repositories/blocking.ts | 6 +- .../src/models/repositories/channel.ts | 4 +- .../backend/src/models/repositories/clip.ts | 4 +- .../src/models/repositories/drive-file.ts | 12 +- .../src/models/repositories/drive-folder.ts | 4 +- .../backend/src/models/repositories/emoji.ts | 2 +- .../src/models/repositories/follow-request.ts | 2 +- .../src/models/repositories/following.ts | 6 +- .../src/models/repositories/gallery-post.ts | 6 +- .../src/models/repositories/hashtag.ts | 2 +- .../src/models/repositories/instance.ts | 2 +- .../models/repositories/messaging-message.ts | 4 +- .../models/repositories/moderation-logs.ts | 2 +- .../backend/src/models/repositories/muting.ts | 6 +- .../src/models/repositories/note-favorite.ts | 2 +- .../src/models/repositories/note-reaction.ts | 6 +- .../backend/src/models/repositories/note.ts | 38 ++--- .../src/models/repositories/notification.ts | 22 +-- .../backend/src/models/repositories/page.ts | 6 +- .../src/models/repositories/user-group.ts | 2 +- .../src/models/repositories/user-list.ts | 2 +- .../backend/src/models/repositories/user.ts | 86 +++++------ packages/backend/src/queue/index.ts | 22 +-- packages/backend/src/queue/initialize.ts | 4 +- .../processors/background/index-all-notes.ts | 10 +- .../src/queue/processors/db/delete-account.ts | 12 +- .../queue/processors/db/delete-drive-files.ts | 8 +- .../queue/processors/db/export-blocking.ts | 14 +- .../processors/db/export-custom-emojis.ts | 18 +-- .../queue/processors/db/export-following.ts | 16 +- .../src/queue/processors/db/export-mute.ts | 14 +- .../src/queue/processors/db/export-notes.ts | 16 +- .../queue/processors/db/export-user-lists.ts | 14 +- .../queue/processors/db/import-blocking.ts | 8 +- .../processors/db/import-custom-emojis.ts | 14 +- .../processors/db/import-firefish-post.ts | 32 ++-- .../queue/processors/db/import-following.ts | 10 +- .../queue/processors/db/import-masto-post.ts | 26 ++-- .../src/queue/processors/db/import-muting.ts | 12 +- .../src/queue/processors/db/import-posts.ts | 10 +- .../queue/processors/db/import-user-lists.ts | 16 +- .../backend/src/queue/processors/db/index.ts | 20 +-- .../backend/src/queue/processors/deliver.ts | 10 +- .../processors/ended-poll-notification.ts | 2 +- .../backend/src/queue/processors/inbox.ts | 28 ++-- .../object-storage/clean-remote-files.ts | 6 +- .../processors/object-storage/delete-file.ts | 2 +- .../queue/processors/object-storage/index.ts | 4 +- .../system/check-expired-mutings.ts | 4 +- .../queue/processors/system/clean-charts.ts | 2 +- .../src/queue/processors/system/clean.ts | 2 +- .../src/queue/processors/system/index.ts | 2 +- .../processors/system/local-emoji-size.ts | 4 +- .../queue/processors/system/verify-links.ts | 2 +- .../src/queue/processors/webhook-deliver.ts | 10 +- packages/backend/src/queue/queues.ts | 6 +- .../src/remote/activitypub/audience.ts | 12 +- .../src/remote/activitypub/check-fetch.ts | 12 +- .../src/remote/activitypub/db-resolver.ts | 16 +- .../src/remote/activitypub/deliver-manager.ts | 8 +- .../activitypub/kernel/accept/follow.ts | 4 +- .../remote/activitypub/kernel/accept/index.ts | 8 +- .../remote/activitypub/kernel/add/index.ts | 4 +- .../activitypub/kernel/announce/index.ts | 6 +- .../activitypub/kernel/announce/note.ts | 20 +-- .../remote/activitypub/kernel/block/index.ts | 6 +- .../remote/activitypub/kernel/create/index.ts | 10 +- .../remote/activitypub/kernel/create/note.ts | 10 +- .../remote/activitypub/kernel/delete/actor.ts | 4 +- .../remote/activitypub/kernel/delete/index.ts | 6 +- .../remote/activitypub/kernel/delete/note.ts | 8 +- .../remote/activitypub/kernel/flag/index.ts | 8 +- .../src/remote/activitypub/kernel/follow.ts | 2 +- .../src/remote/activitypub/kernel/index.ts | 80 +++++----- .../src/remote/activitypub/kernel/like.ts | 4 +- .../src/remote/activitypub/kernel/read.ts | 6 +- .../activitypub/kernel/reject/follow.ts | 8 +- .../remote/activitypub/kernel/reject/index.ts | 8 +- .../remote/activitypub/kernel/remove/index.ts | 4 +- .../remote/activitypub/kernel/undo/accept.ts | 4 +- .../activitypub/kernel/undo/announce.ts | 4 +- .../remote/activitypub/kernel/undo/block.ts | 6 +- .../remote/activitypub/kernel/undo/follow.ts | 6 +- .../remote/activitypub/kernel/undo/index.ts | 18 +-- .../remote/activitypub/kernel/undo/like.ts | 4 +- .../remote/activitypub/kernel/update/index.ts | 9 +- .../remote/activitypub/misc/get-note-html.ts | 4 +- .../remote/activitypub/misc/html-to-mfm.ts | 4 +- .../remote/activitypub/misc/ld-signature.ts | 14 +- .../src/remote/activitypub/models/image.ts | 14 +- .../src/remote/activitypub/models/mention.ts | 8 +- .../src/remote/activitypub/models/note.ts | 98 ++++++------ .../src/remote/activitypub/models/person.ts | 84 +++++------ .../src/remote/activitypub/models/question.ts | 10 +- .../src/remote/activitypub/models/tag.ts | 2 +- .../backend/src/remote/activitypub/perform.ts | 2 +- .../activitypub/renderer/follow-user.ts | 2 +- .../src/remote/activitypub/renderer/index.ts | 2 +- .../src/remote/activitypub/renderer/key.ts | 6 +- .../src/remote/activitypub/renderer/like.ts | 2 +- .../remote/activitypub/renderer/mention.ts | 2 +- .../src/remote/activitypub/renderer/note.ts | 22 +-- .../src/remote/activitypub/renderer/person.ts | 10 +- .../remote/activitypub/renderer/question.ts | 2 +- .../src/remote/activitypub/renderer/read.ts | 2 +- .../src/remote/activitypub/renderer/vote.ts | 2 +- .../backend/src/remote/activitypub/request.ts | 4 +- .../src/remote/activitypub/resolver.ts | 30 ++-- packages/backend/src/remote/resolve-user.ts | 10 +- packages/backend/src/server/activitypub.ts | 34 ++--- .../src/server/activitypub/featured.ts | 14 +- .../src/server/activitypub/followers.ts | 22 +-- .../src/server/activitypub/following.ts | 22 +-- .../backend/src/server/activitypub/outbox.ts | 24 +-- packages/backend/src/server/api/2fa.ts | 2 +- .../backend/src/server/api/api-handler.ts | 20 +-- .../backend/src/server/api/authenticate.ts | 8 +- packages/backend/src/server/api/call.ts | 22 +-- .../api/common/generate-muted-user-query.ts | 4 +- .../common/generated-muted-renote-query.ts | 2 +- .../backend/src/server/api/common/getters.ts | 2 +- .../src/server/api/common/inject-featured.ts | 6 +- .../src/server/api/common/inject-promo.ts | 4 +- .../api/common/read-messaging-message.ts | 24 +-- .../server/api/common/read-notification.ts | 8 +- .../backend/src/server/api/common/signin.ts | 2 +- .../backend/src/server/api/common/signup.ts | 20 +-- packages/backend/src/server/api/define.ts | 6 +- packages/backend/src/server/api/endpoints.ts | 62 ++++---- .../api/endpoints/admin/abuse-user-reports.ts | 2 +- .../api/endpoints/admin/accounts/create.ts | 2 +- .../api/endpoints/admin/accounts/delete.ts | 6 +- .../api/endpoints/admin/accounts/hosted.ts | 4 +- .../server/api/endpoints/admin/ad/create.ts | 4 +- .../server/api/endpoints/admin/ad/delete.ts | 2 +- .../src/server/api/endpoints/admin/ad/list.ts | 2 +- .../server/api/endpoints/admin/ad/update.ts | 2 +- .../endpoints/admin/announcements/create.ts | 4 +- .../endpoints/admin/announcements/delete.ts | 2 +- .../api/endpoints/admin/announcements/list.ts | 4 +- .../endpoints/admin/announcements/update.ts | 2 +- .../server/api/endpoints/admin/delete-2fa.ts | 4 +- .../api/endpoints/admin/delete-account.ts | 2 +- .../admin/delete-all-files-of-a-user.ts | 2 +- .../api/endpoints/admin/delete-passkeys.ts | 4 +- .../admin/drive-capacity-override.ts | 2 +- .../admin/drive/clean-remote-files.ts | 2 +- .../api/endpoints/admin/drive/cleanup.ts | 4 +- .../server/api/endpoints/admin/drive/files.ts | 2 +- .../endpoints/admin/emoji/add-aliases-bulk.ts | 8 +- .../server/api/endpoints/admin/emoji/add.ts | 16 +- .../server/api/endpoints/admin/emoji/copy.ts | 16 +- .../api/endpoints/admin/emoji/delete-bulk.ts | 10 +- .../api/endpoints/admin/emoji/delete.ts | 10 +- .../api/endpoints/admin/emoji/import-zip.ts | 2 +- .../api/endpoints/admin/emoji/list-remote.ts | 6 +- .../server/api/endpoints/admin/emoji/list.ts | 6 +- .../admin/emoji/remove-aliases-bulk.ts | 8 +- .../endpoints/admin/emoji/set-aliases-bulk.ts | 8 +- .../admin/emoji/set-category-bulk.ts | 8 +- .../endpoints/admin/emoji/set-license-bulk.ts | 8 +- .../api/endpoints/admin/emoji/update.ts | 8 +- .../admin/federation/delete-all-files.ts | 2 +- .../refresh-remote-instance-metadata.ts | 4 +- .../admin/federation/remove-all-following.ts | 2 +- .../admin/federation/update-instance.ts | 4 +- .../api/endpoints/admin/get-index-stats.ts | 2 +- .../src/server/api/endpoints/admin/invite.ts | 6 +- .../src/server/api/endpoints/admin/meta.ts | 2 +- .../api/endpoints/admin/moderators/add.ts | 2 +- .../api/endpoints/admin/moderators/remove.ts | 2 +- .../api/endpoints/admin/promo/create.ts | 4 +- .../server/api/endpoints/admin/queue/clear.ts | 2 +- .../endpoints/admin/queue/deliver-delayed.ts | 2 +- .../endpoints/admin/queue/inbox-delayed.ts | 2 +- .../server/api/endpoints/admin/queue/stats.ts | 4 +- .../server/api/endpoints/admin/relays/add.ts | 2 +- .../api/endpoints/admin/reset-password.ts | 4 +- .../admin/resolve-abuse-user-report.ts | 6 +- .../api/endpoints/admin/search/index-all.ts | 2 +- .../api/endpoints/admin/send-mod-mail.ts | 6 +- .../server/api/endpoints/admin/server-info.ts | 6 +- .../endpoints/admin/set-emoji-moderator.ts | 2 +- .../endpoints/admin/show-moderation-logs.ts | 2 +- .../server/api/endpoints/admin/show-users.ts | 2 +- .../api/endpoints/admin/silence-user.ts | 2 +- .../api/endpoints/admin/suspend-user.ts | 6 +- .../api/endpoints/admin/unsilence-user.ts | 2 +- .../api/endpoints/admin/unsuspend-user.ts | 2 +- .../server/api/endpoints/admin/update-meta.ts | 4 +- .../src/server/api/endpoints/admin/vacuum.ts | 2 +- .../src/server/api/endpoints/announcements.ts | 4 +- .../server/api/endpoints/antennas/create.ts | 4 +- .../server/api/endpoints/antennas/delete.ts | 2 +- .../src/server/api/endpoints/antennas/list.ts | 2 +- .../server/api/endpoints/antennas/markread.ts | 2 +- .../server/api/endpoints/antennas/notes.ts | 14 +- .../src/server/api/endpoints/antennas/show.ts | 2 +- .../server/api/endpoints/antennas/update.ts | 2 +- .../src/server/api/endpoints/ap/get.ts | 4 +- .../src/server/api/endpoints/ap/show.ts | 26 ++-- .../src/server/api/endpoints/app/create.ts | 6 +- .../src/server/api/endpoints/app/show.ts | 4 +- .../src/server/api/endpoints/auth/accept.ts | 6 +- .../api/endpoints/auth/session/generate.ts | 6 +- .../server/api/endpoints/auth/session/show.ts | 2 +- .../api/endpoints/auth/session/userkey.ts | 2 +- .../server/api/endpoints/blocking/create.ts | 8 +- .../server/api/endpoints/blocking/delete.ts | 8 +- .../src/server/api/endpoints/blocking/list.ts | 2 +- .../server/api/endpoints/channels/create.ts | 6 +- .../server/api/endpoints/channels/featured.ts | 2 +- .../server/api/endpoints/channels/follow.ts | 4 +- .../server/api/endpoints/channels/followed.ts | 2 +- .../server/api/endpoints/channels/owned.ts | 2 +- .../server/api/endpoints/channels/search.ts | 6 +- .../src/server/api/endpoints/channels/show.ts | 2 +- .../server/api/endpoints/channels/timeline.ts | 4 +- .../server/api/endpoints/channels/unfollow.ts | 2 +- .../server/api/endpoints/channels/update.ts | 2 +- .../api/endpoints/charts/active-users.ts | 2 +- .../server/api/endpoints/clips/add-note.ts | 6 +- .../src/server/api/endpoints/clips/create.ts | 2 +- .../src/server/api/endpoints/clips/delete.ts | 2 +- .../src/server/api/endpoints/clips/list.ts | 2 +- .../src/server/api/endpoints/clips/notes.ts | 10 +- .../server/api/endpoints/clips/remove-note.ts | 4 +- .../src/server/api/endpoints/clips/show.ts | 2 +- .../src/server/api/endpoints/clips/update.ts | 2 +- .../endpoints/compatibility/custom-emojis.ts | 6 +- .../src/server/api/endpoints/drive/files.ts | 2 +- .../endpoints/drive/files/attached-notes.ts | 2 +- .../endpoints/drive/files/check-existence.ts | 2 +- .../api/endpoints/drive/files/create.ts | 10 +- .../api/endpoints/drive/files/delete.ts | 6 +- .../server/api/endpoints/drive/files/find.ts | 2 +- .../api/endpoints/drive/files/update.ts | 4 +- .../endpoints/drive/files/upload-from-url.ts | 8 +- .../src/server/api/endpoints/drive/folders.ts | 2 +- .../api/endpoints/drive/folders/create.ts | 6 +- .../api/endpoints/drive/folders/delete.ts | 4 +- .../api/endpoints/drive/folders/find.ts | 2 +- .../api/endpoints/drive/folders/show.ts | 2 +- .../api/endpoints/drive/folders/update.ts | 10 +- .../src/server/api/endpoints/drive/stream.ts | 2 +- .../backend/src/server/api/endpoints/emoji.ts | 2 +- .../api/endpoints/export-custom-emojis.ts | 2 +- .../api/endpoints/federation/followers.ts | 2 +- .../api/endpoints/federation/following.ts | 2 +- .../api/endpoints/federation/instances.ts | 4 +- .../api/endpoints/federation/show-instance.ts | 4 +- .../server/api/endpoints/federation/stats.ts | 2 +- .../federation/update-remote-user.ts | 4 +- .../server/api/endpoints/federation/users.ts | 2 +- .../src/server/api/endpoints/fetch-rss.ts | 4 +- .../server/api/endpoints/following/create.ts | 10 +- .../server/api/endpoints/following/delete.ts | 8 +- .../api/endpoints/following/invalidate.ts | 8 +- .../endpoints/following/requests/accept.ts | 4 +- .../endpoints/following/requests/cancel.ts | 8 +- .../api/endpoints/following/requests/list.ts | 2 +- .../endpoints/following/requests/reject.ts | 4 +- .../server/api/endpoints/gallery/featured.ts | 2 +- .../server/api/endpoints/gallery/popular.ts | 2 +- .../src/server/api/endpoints/gallery/posts.ts | 4 +- .../api/endpoints/gallery/posts/create.ts | 8 +- .../api/endpoints/gallery/posts/delete.ts | 2 +- .../api/endpoints/gallery/posts/like.ts | 4 +- .../api/endpoints/gallery/posts/show.ts | 2 +- .../api/endpoints/gallery/posts/unlike.ts | 2 +- .../api/endpoints/gallery/posts/update.ts | 6 +- .../api/endpoints/get-online-users-count.ts | 2 +- .../src/server/api/endpoints/get-sounds.ts | 2 +- .../src/server/api/endpoints/hashtags/list.ts | 2 +- .../server/api/endpoints/hashtags/search.ts | 4 +- .../src/server/api/endpoints/hashtags/show.ts | 4 +- .../server/api/endpoints/hashtags/trend.ts | 10 +- .../server/api/endpoints/hashtags/users.ts | 4 +- .../src/server/api/endpoints/i/2fa/done.ts | 4 +- .../server/api/endpoints/i/2fa/key-done.ts | 14 +- .../api/endpoints/i/2fa/password-less.ts | 4 +- .../api/endpoints/i/2fa/register-key.ts | 8 +- .../server/api/endpoints/i/2fa/register.ts | 6 +- .../server/api/endpoints/i/2fa/remove-key.ts | 2 +- .../server/api/endpoints/i/2fa/unregister.ts | 6 +- .../server/api/endpoints/i/2fa/update-key.ts | 4 +- .../src/server/api/endpoints/i/apps.ts | 2 +- .../server/api/endpoints/i/authorized-apps.ts | 2 +- .../server/api/endpoints/i/change-password.ts | 4 +- .../server/api/endpoints/i/delete-account.ts | 6 +- .../server/api/endpoints/i/export-blocking.ts | 4 +- .../api/endpoints/i/export-following.ts | 4 +- .../src/server/api/endpoints/i/export-mute.ts | 4 +- .../server/api/endpoints/i/export-notes.ts | 4 +- .../api/endpoints/i/export-user-lists.ts | 4 +- .../src/server/api/endpoints/i/favorites.ts | 2 +- .../server/api/endpoints/i/gallery/likes.ts | 2 +- .../server/api/endpoints/i/gallery/posts.ts | 2 +- .../endpoints/i/get-word-muted-notes-count.ts | 2 +- .../server/api/endpoints/i/import-blocking.ts | 8 +- .../api/endpoints/i/import-following.ts | 8 +- .../server/api/endpoints/i/import-muting.ts | 8 +- .../server/api/endpoints/i/import-posts.ts | 8 +- .../api/endpoints/i/import-user-lists.ts | 8 +- .../src/server/api/endpoints/i/known-as.ts | 10 +- .../src/server/api/endpoints/i/move.ts | 16 +- .../server/api/endpoints/i/notifications.ts | 12 +- .../src/server/api/endpoints/i/page-likes.ts | 2 +- .../src/server/api/endpoints/i/pages.ts | 2 +- .../backend/src/server/api/endpoints/i/pin.ts | 4 +- .../i/read-all-messaging-messages.ts | 4 +- .../api/endpoints/i/read-all-unread-notes.ts | 4 +- .../api/endpoints/i/read-announcement.ts | 4 +- .../api/endpoints/i/regenerate-token.ts | 8 +- .../api/endpoints/i/registry/get-all.ts | 2 +- .../api/endpoints/i/registry/get-detail.ts | 2 +- .../api/endpoints/i/registry/get-unsecure.ts | 4 +- .../server/api/endpoints/i/registry/get.ts | 2 +- .../endpoints/i/registry/keys-with-type.ts | 2 +- .../server/api/endpoints/i/registry/keys.ts | 2 +- .../server/api/endpoints/i/registry/remove.ts | 2 +- .../server/api/endpoints/i/registry/scopes.ts | 2 +- .../server/api/endpoints/i/registry/set.ts | 6 +- .../server/api/endpoints/i/revoke-token.ts | 2 +- .../server/api/endpoints/i/signin-history.ts | 2 +- .../src/server/api/endpoints/i/unpin.ts | 4 +- .../server/api/endpoints/i/update-email.ts | 14 +- .../src/server/api/endpoints/i/update.ts | 26 ++-- .../api/endpoints/i/user-group-invites.ts | 2 +- .../server/api/endpoints/i/webhooks/create.ts | 6 +- .../server/api/endpoints/i/webhooks/delete.ts | 2 +- .../server/api/endpoints/i/webhooks/list.ts | 2 +- .../server/api/endpoints/i/webhooks/show.ts | 2 +- .../server/api/endpoints/i/webhooks/update.ts | 4 +- .../server/api/endpoints/messaging/history.ts | 2 +- .../api/endpoints/messaging/messages.ts | 14 +- .../endpoints/messaging/messages/create.ts | 18 +-- .../endpoints/messaging/messages/delete.ts | 4 +- .../api/endpoints/messaging/messages/read.ts | 6 +- .../backend/src/server/api/endpoints/meta.ts | 6 +- .../server/api/endpoints/miauth/gen-token.ts | 4 +- .../src/server/api/endpoints/mute/create.ts | 8 +- .../src/server/api/endpoints/mute/delete.ts | 4 +- .../src/server/api/endpoints/mute/list.ts | 4 +- .../src/server/api/endpoints/my/apps.ts | 2 +- .../backend/src/server/api/endpoints/notes.ts | 2 +- .../server/api/endpoints/notes/children.ts | 8 +- .../src/server/api/endpoints/notes/clips.ts | 4 +- .../api/endpoints/notes/conversation.ts | 2 +- .../src/server/api/endpoints/notes/create.ts | 32 ++-- .../src/server/api/endpoints/notes/delete.ts | 6 +- .../src/server/api/endpoints/notes/edit.ts | 58 +++---- .../api/endpoints/notes/favorites/create.ts | 4 +- .../api/endpoints/notes/favorites/delete.ts | 2 +- .../server/api/endpoints/notes/featured.ts | 4 +- .../api/endpoints/notes/global-timeline.ts | 12 +- .../api/endpoints/notes/hybrid-timeline.ts | 18 +-- .../api/endpoints/notes/local-timeline.ts | 22 +-- .../api/endpoints/notes/make-private.ts | 10 +- .../server/api/endpoints/notes/mentions.ts | 14 +- .../endpoints/notes/polls/recommendation.ts | 4 +- .../server/api/endpoints/notes/polls/vote.ts | 26 ++-- .../server/api/endpoints/notes/reactions.ts | 6 +- .../api/endpoints/notes/reactions/create.ts | 4 +- .../api/endpoints/notes/reactions/delete.ts | 6 +- .../endpoints/notes/recommended-timeline.ts | 22 +-- .../src/server/api/endpoints/notes/renotes.ts | 14 +- .../src/server/api/endpoints/notes/replies.ts | 8 +- .../api/endpoints/notes/search-by-tag.ts | 12 +- .../src/server/api/endpoints/notes/search.ts | 12 +- .../src/server/api/endpoints/notes/show.ts | 2 +- .../endpoints/notes/thread-muting/create.ts | 6 +- .../endpoints/notes/thread-muting/delete.ts | 2 +- .../server/api/endpoints/notes/timeline.ts | 18 +-- .../server/api/endpoints/notes/translate.ts | 8 +- .../server/api/endpoints/notes/unrenote.ts | 6 +- .../api/endpoints/notes/user-list-timeline.ts | 10 +- .../api/endpoints/notes/watching/create.ts | 4 +- .../api/endpoints/notes/watching/delete.ts | 4 +- .../api/endpoints/notifications/create.ts | 2 +- .../notifications/mark-all-as-read.ts | 4 +- .../api/endpoints/notifications/read.ts | 2 +- .../src/server/api/endpoints/page-push.ts | 4 +- .../src/server/api/endpoints/pages/create.ts | 4 +- .../src/server/api/endpoints/pages/like.ts | 2 +- .../src/server/api/endpoints/pages/show.ts | 4 +- .../src/server/api/endpoints/pages/unlike.ts | 2 +- .../src/server/api/endpoints/pages/update.ts | 8 +- .../src/server/api/endpoints/patrons.ts | 8 +- .../src/server/api/endpoints/pinned-users.ts | 6 +- .../src/server/api/endpoints/promo/read.ts | 4 +- .../api/endpoints/renote-mute/create.ts | 4 +- .../api/endpoints/renote-mute/delete.ts | 2 +- .../server/api/endpoints/renote-mute/list.ts | 2 +- .../api/endpoints/request-reset-password.ts | 12 +- .../server/api/endpoints/reset-password.ts | 4 +- .../src/server/api/endpoints/server-info.ts | 4 +- .../backend/src/server/api/endpoints/stats.ts | 2 +- .../api/endpoints/username/available.ts | 4 +- .../backend/src/server/api/endpoints/users.ts | 4 +- .../src/server/api/endpoints/users/clips.ts | 2 +- .../server/api/endpoints/users/followers.ts | 8 +- .../server/api/endpoints/users/following.ts | 8 +- .../api/endpoints/users/gallery/posts.ts | 2 +- .../users/get-frequently-replied-users.ts | 6 +- .../api/endpoints/users/groups/create.ts | 4 +- .../users/groups/invitations/accept.ts | 4 +- .../api/endpoints/users/groups/invite.ts | 14 +- .../api/endpoints/users/groups/joined.ts | 4 +- .../api/endpoints/users/groups/leave.ts | 2 +- .../server/api/endpoints/users/groups/pull.ts | 4 +- .../server/api/endpoints/users/groups/show.ts | 2 +- .../api/endpoints/users/groups/transfer.ts | 4 +- .../api/endpoints/users/lists/create.ts | 2 +- .../server/api/endpoints/users/lists/pull.ts | 6 +- .../server/api/endpoints/users/lists/push.ts | 6 +- .../src/server/api/endpoints/users/notes.ts | 14 +- .../src/server/api/endpoints/users/pages.ts | 2 +- .../server/api/endpoints/users/reactions.ts | 4 +- .../api/endpoints/users/recommendation.ts | 14 +- .../api/endpoints/users/report-abuse.ts | 18 +-- .../users/search-by-username-and-host.ts | 8 +- .../src/server/api/endpoints/users/search.ts | 8 +- .../src/server/api/endpoints/users/show.ts | 14 +- packages/backend/src/server/api/index.ts | 26 ++-- packages/backend/src/server/api/limiter.ts | 6 +- .../mastodon/ApiMastodonCompatibleService.ts | 22 +-- .../src/server/api/mastodon/converters.ts | 2 +- .../server/api/mastodon/endpoints/account.ts | 14 +- .../server/api/mastodon/endpoints/filter.ts | 2 +- .../src/server/api/mastodon/endpoints/meta.ts | 4 +- .../api/mastodon/endpoints/notifications.ts | 4 +- .../server/api/mastodon/endpoints/search.ts | 4 +- .../server/api/mastodon/endpoints/status.ts | 18 +-- .../server/api/mastodon/endpoints/timeline.ts | 8 +- .../src/server/api/openapi/gen-spec.ts | 11 +- .../backend/src/server/api/private/signin.ts | 36 ++--- .../src/server/api/private/signup-pending.ts | 6 +- .../backend/src/server/api/private/signup.ts | 28 ++-- .../src/server/api/private/verify-email.ts | 6 +- .../backend/src/server/api/stream/channel.ts | 6 +- .../src/server/api/stream/channels/admin.ts | 2 +- .../src/server/api/stream/channels/antenna.ts | 8 +- .../src/server/api/stream/channels/channel.ts | 8 +- .../src/server/api/stream/channels/drive.ts | 2 +- .../api/stream/channels/global-timeline.ts | 8 +- .../src/server/api/stream/channels/hashtag.ts | 4 +- .../api/stream/channels/home-timeline.ts | 10 +- .../api/stream/channels/hybrid-timeline.ts | 16 +- .../src/server/api/stream/channels/index.ts | 30 ++-- .../api/stream/channels/local-timeline.ts | 8 +- .../src/server/api/stream/channels/main.ts | 4 +- .../api/stream/channels/messaging-index.ts | 2 +- .../server/api/stream/channels/messaging.ts | 18 +-- .../stream/channels/recommended-timeline.ts | 14 +- .../server/api/stream/channels/user-list.ts | 8 +- .../backend/src/server/api/stream/index.ts | 46 +++--- .../backend/src/server/api/stream/types.ts | 20 +-- packages/backend/src/server/api/streaming.ts | 4 +- .../src/server/file/byte-range-readable.ts | 8 +- packages/backend/src/server/file/index.ts | 4 +- .../src/server/file/send-drive-file.ts | 24 +-- packages/backend/src/server/index.ts | 40 ++--- packages/backend/src/server/nodeinfo.ts | 10 +- packages/backend/src/server/proxy/index.ts | 2 +- .../backend/src/server/proxy/proxy-media.ts | 16 +- packages/backend/src/server/web/feed.ts | 10 +- packages/backend/src/server/web/index.ts | 46 +++--- packages/backend/src/server/web/manifest.ts | 4 +- .../backend/src/server/web/url-preview.ts | 10 +- packages/backend/src/server/well-known.ts | 6 +- .../src/services/add-note-to-antenna.ts | 6 +- .../backend/src/services/blocking/create.ts | 20 +-- .../backend/src/services/blocking/delete.ts | 10 +- .../src/services/chart/charts/active-users.ts | 2 +- packages/backend/src/services/chart/core.ts | 26 ++-- .../src/services/create-notification.ts | 16 +- .../src/services/create-system-user.ts | 18 +-- .../backend/src/services/detect-sensitive.ts | 2 +- .../backend/src/services/drive/add-file.ts | 42 +++--- .../backend/src/services/drive/delete-file.ts | 6 +- .../drive/generate-video-thumbnail.ts | 2 +- .../src/services/drive/internal-storage.ts | 2 +- packages/backend/src/services/drive/s3.ts | 4 +- .../src/services/drive/upload-from-url.ts | 6 +- .../src/services/fetch-instance-metadata.ts | 10 +- packages/backend/src/services/fetch-rel-me.ts | 2 +- .../backend/src/services/following/create.ts | 44 +++--- .../backend/src/services/following/delete.ts | 20 +-- .../backend/src/services/following/reject.ts | 16 +- .../services/following/requests/accept-all.ts | 2 +- .../src/services/following/requests/accept.ts | 12 +- .../src/services/following/requests/cancel.ts | 12 +- .../src/services/following/requests/create.ts | 12 +- packages/backend/src/services/i/pin.ts | 16 +- packages/backend/src/services/i/update.ts | 8 +- .../src/services/insert-moderation-log.ts | 2 +- .../backend/src/services/instance-actor.ts | 4 +- packages/backend/src/services/logger.ts | 4 +- .../backend/src/services/messages/create.ts | 32 ++-- .../backend/src/services/messages/delete.ts | 10 +- packages/backend/src/services/note/create.ts | 141 +++++++++--------- packages/backend/src/services/note/delete.ts | 24 +-- .../backend/src/services/note/polls/update.ts | 8 +- .../backend/src/services/note/polls/vote.ts | 10 +- .../src/services/note/reaction/create.ts | 28 ++-- .../src/services/note/reaction/delete.ts | 16 +- packages/backend/src/services/note/read.ts | 12 +- packages/backend/src/services/note/unread.ts | 4 +- packages/backend/src/services/note/unwatch.ts | 2 +- packages/backend/src/services/note/watch.ts | 6 +- .../backend/src/services/push-notification.ts | 6 +- .../register-or-fetch-instance-doc.ts | 6 +- packages/backend/src/services/relay.ts | 16 +- packages/backend/src/services/send-email.ts | 4 +- packages/backend/src/services/stream.ts | 12 +- packages/backend/src/services/suspend-user.ts | 10 +- .../backend/src/services/unsuspend-user.ts | 12 +- .../backend/src/services/update-hashtag.ts | 6 +- packages/backend/src/services/user-cache.ts | 4 +- .../backend/src/services/user-list/push.ts | 12 +- .../services/validate-email-for-account.ts | 4 +- packages/client/src/account.ts | 6 +- packages/client/src/components/index.ts | 22 +-- packages/client/src/components/mfm.ts | 20 +-- .../client/src/directives/follow-append.ts | 2 +- packages/client/src/directives/hotkey.ts | 2 +- packages/client/src/directives/index.ts | 20 +-- packages/client/src/directives/ripple.ts | 2 +- packages/client/src/directives/tooltip.ts | 6 +- .../client/src/directives/user-preview.ts | 2 +- packages/client/src/directives/vibrate.ts | 2 +- packages/client/src/filters/user.ts | 2 +- packages/client/src/i18n.ts | 2 +- packages/client/src/init.ts | 2 +- packages/client/src/navbar.ts | 2 +- packages/client/src/nirax.ts | 8 +- packages/client/src/os.ts | 26 ++-- packages/client/src/pizzax.ts | 2 +- packages/client/src/plugin.ts | 2 +- packages/client/src/reactiveAccount.ts | 2 +- packages/client/src/router.ts | 4 +- packages/client/src/scripts/aiscript/api.ts | 2 +- packages/client/src/scripts/autocomplete.ts | 10 +- packages/client/src/scripts/chiptune2.ts | 6 +- .../client/src/scripts/detect-language.ts | 2 +- packages/client/src/scripts/emojilist.ts | 6 +- .../src/scripts/extract-url-from-mfm.ts | 2 +- .../client/src/scripts/gen-search-query.ts | 5 +- packages/client/src/scripts/get-note-menu.ts | 16 +- packages/client/src/scripts/get-user-menu.ts | 16 +- packages/client/src/scripts/helpMenu.ts | 8 +- packages/client/src/scripts/hotkey.ts | 2 +- packages/client/src/scripts/hpml/evaluator.ts | 16 +- packages/client/src/scripts/hpml/index.ts | 2 +- packages/client/src/scripts/hpml/lib.ts | 4 +- .../client/src/scripts/hpml/type-checker.ts | 4 +- packages/client/src/scripts/init-chart.ts | 6 +- packages/client/src/scripts/katex-macro.ts | 22 +-- packages/client/src/scripts/lookup-user.ts | 2 +- packages/client/src/scripts/media-proxy.ts | 2 +- packages/client/src/scripts/please-login.ts | 4 +- packages/client/src/scripts/popout.ts | 2 +- packages/client/src/scripts/popup-position.ts | 12 +- packages/client/src/scripts/preprocess.ts | 4 +- .../client/src/scripts/reaction-picker.ts | 10 +- packages/client/src/scripts/search.ts | 4 +- packages/client/src/scripts/select-file.ts | 12 +- packages/client/src/scripts/shuffle.ts | 4 +- packages/client/src/scripts/theme.ts | 6 +- packages/client/src/scripts/upload.ts | 12 +- .../client/src/scripts/use-chart-tooltip.ts | 4 +- .../client/src/scripts/use-note-capture.ts | 8 +- packages/client/src/scripts/use-tooltip.ts | 14 +- packages/client/src/stream.ts | 4 +- packages/client/src/theme-store.ts | 2 +- packages/client/src/ui/_common_/sw-inject.ts | 4 +- packages/client/src/ui/deck/deck-store.ts | 8 +- packages/client/src/widgets/widget.ts | 6 +- packages/client/vite.config.ts | 2 +- packages/client/vite.json5.ts | 4 +- 688 files changed, 2873 insertions(+), 2869 deletions(-) diff --git a/packages/backend/src/boot/index.ts b/packages/backend/src/boot/index.ts index 489350a1..37c4ab09 100644 --- a/packages/backend/src/boot/index.ts +++ b/packages/backend/src/boot/index.ts @@ -5,11 +5,11 @@ import Xev from "xev"; import Logger from "@/services/logger.js"; import { envOption } from "../env.js"; +import os from "node:os"; // for typeorm import "reflect-metadata"; import { masterMain } from "./master.js"; import { workerMain } from "./worker.js"; -import os from "node:os"; const logger = new Logger("core", "cyan"); const clusterLogger = logger.createSubLogger("cluster", "orange", false); diff --git a/packages/backend/src/boot/master.ts b/packages/backend/src/boot/master.ts index 84767a92..f330d69f 100644 --- a/packages/backend/src/boot/master.ts +++ b/packages/backend/src/boot/master.ts @@ -1,18 +1,18 @@ -import * as fs from "node:fs"; -import { fileURLToPath } from "node:url"; -import { dirname } from "node:path"; -import * as os from "node:os"; import cluster from "node:cluster"; +import * as fs from "node:fs"; +import * as os from "node:os"; +import { dirname } from "node:path"; +import { fileURLToPath } from "node:url"; import chalk from "chalk"; import chalkTemplate from "chalk-template"; import semver from "semver"; -import Logger from "@/services/logger.js"; import loadConfig from "@/config/load.js"; import type { Config } from "@/config/types.js"; +import { db, initDb } from "@/db/postgre.js"; import { envOption } from "@/env.js"; import { showMachineInfo } from "@/misc/show-machine-info.js"; -import { db, initDb } from "@/db/postgre.js"; +import Logger from "@/services/logger.js"; const _filename = fileURLToPath(import.meta.url); const _dirname = dirname(_filename); diff --git a/packages/backend/src/boot/worker.ts b/packages/backend/src/boot/worker.ts index 0acdcd97..8491ce33 100644 --- a/packages/backend/src/boot/worker.ts +++ b/packages/backend/src/boot/worker.ts @@ -1,6 +1,6 @@ import cluster from "node:cluster"; -import { initDb } from "@/db/postgre.js"; import os from "node:os"; +import { initDb } from "@/db/postgre.js"; /** * Init worker process @@ -25,6 +25,6 @@ export async function workerMain() { if (cluster.isWorker) { // Send a 'ready' message to parent process - process.send!("ready"); + process.send?.("ready"); } } diff --git a/packages/backend/src/config/load.ts b/packages/backend/src/config/load.ts index 2ff33092..e5279d2b 100644 --- a/packages/backend/src/config/load.ts +++ b/packages/backend/src/config/load.ts @@ -3,10 +3,10 @@ */ import * as fs from "node:fs"; -import { fileURLToPath } from "node:url"; import { dirname } from "node:path"; +import { fileURLToPath } from "node:url"; import * as yaml from "js-yaml"; -import type { Source, Mixin } from "./types.js"; +import type { Mixin, Source } from "./types.js"; const _filename = fileURLToPath(import.meta.url); const _dirname = dirname(_filename); diff --git a/packages/backend/src/daemons/queue-stats.ts b/packages/backend/src/daemons/queue-stats.ts index c358518f..82e8226e 100644 --- a/packages/backend/src/daemons/queue-stats.ts +++ b/packages/backend/src/daemons/queue-stats.ts @@ -1,5 +1,5 @@ -import Xev from "xev"; import { deliverQueue, inboxQueue } from "@/queue/queues.js"; +import Xev from "xev"; const ev = new Xev(); diff --git a/packages/backend/src/daemons/server-stats.ts b/packages/backend/src/daemons/server-stats.ts index dc749338..aad5d6b3 100644 --- a/packages/backend/src/daemons/server-stats.ts +++ b/packages/backend/src/daemons/server-stats.ts @@ -1,8 +1,8 @@ +import meilisearch from "@/db/meilisearch.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; +import * as osUtils from "os-utils"; import si from "systeminformation"; import Xev from "xev"; -import * as osUtils from "os-utils"; -import { fetchMeta } from "@/misc/fetch-meta.js"; -import meilisearch from "@/db/meilisearch.js"; const ev = new Xev(); diff --git a/packages/backend/src/db/elasticsearch.ts b/packages/backend/src/db/elasticsearch.ts index 2640e7f9..f6ecc1b7 100644 --- a/packages/backend/src/db/elasticsearch.ts +++ b/packages/backend/src/db/elasticsearch.ts @@ -1,5 +1,5 @@ -import * as elasticsearch from "@elastic/elasticsearch"; import config from "@/config/index.js"; +import * as elasticsearch from "@elastic/elasticsearch"; const index = { settings: { diff --git a/packages/backend/src/db/meilisearch.ts b/packages/backend/src/db/meilisearch.ts index 40efaa58..c30da7d5 100644 --- a/packages/backend/src/db/meilisearch.ts +++ b/packages/backend/src/db/meilisearch.ts @@ -1,9 +1,9 @@ import { Health, Index, MeiliSearch, Stats } from "meilisearch"; import { dbLogger } from "./logger.js"; +import * as url from "url"; import config from "@/config/index.js"; import { Note } from "@/models/entities/note.js"; -import * as url from "url"; import { ILocalUser } from "@/models/entities/user.js"; import { Followings, Users } from "@/models/index.js"; @@ -154,7 +154,7 @@ function timestampToUnix(timestamp: string) { if (unix === 0) { // Try to parse the timestamp as JavaScript Date const date = Date.parse(timestamp); - if (isNaN(date)) return 0; + if (Number.isNaN(date)) return 0; unix = date / 1000; } @@ -408,7 +408,7 @@ export default hasConfig return { health: health.status, size: stats.databaseSize, - indexed_count: stats.indexes["posts"].numberOfDocuments, + indexed_count: stats.indexes.posts.numberOfDocuments, }; }, deleteNotes: async (note: Note | Note[] | string | string[]) => { diff --git a/packages/backend/src/db/postgre.ts b/packages/backend/src/db/postgre.ts index 4090cc50..17c43561 100644 --- a/packages/backend/src/db/postgre.ts +++ b/packages/backend/src/db/postgre.ts @@ -2,76 +2,76 @@ import pg from "pg"; pg.types.setTypeParser(20, Number); +import config from "@/config/index.js"; +import * as highlight from "cli-highlight"; import type { Logger } from "typeorm"; import { DataSource } from "typeorm"; -import * as highlight from "cli-highlight"; -import config from "@/config/index.js"; -import { User } from "@/models/entities/user.js"; -import { DriveFile } from "@/models/entities/drive-file.js"; -import { DriveFolder } from "@/models/entities/drive-folder.js"; -import { AccessToken } from "@/models/entities/access-token.js"; -import { App } from "@/models/entities/app.js"; -import { PollVote } from "@/models/entities/poll-vote.js"; -import { Note } from "@/models/entities/note.js"; -import { NoteReaction } from "@/models/entities/note-reaction.js"; -import { NoteWatching } from "@/models/entities/note-watching.js"; -import { NoteThreadMuting } from "@/models/entities/note-thread-muting.js"; -import { NoteUnread } from "@/models/entities/note-unread.js"; -import { Notification } from "@/models/entities/notification.js"; -import { Meta } from "@/models/entities/meta.js"; -import { Following } from "@/models/entities/following.js"; -import { Instance } from "@/models/entities/instance.js"; -import { Muting } from "@/models/entities/muting.js"; -import { RenoteMuting } from "@/models/entities/renote-muting.js"; -import { SwSubscription } from "@/models/entities/sw-subscription.js"; -import { Blocking } from "@/models/entities/blocking.js"; -import { UserList } from "@/models/entities/user-list.js"; -import { UserListJoining } from "@/models/entities/user-list-joining.js"; -import { UserGroup } from "@/models/entities/user-group.js"; -import { UserGroupJoining } from "@/models/entities/user-group-joining.js"; -import { UserGroupInvitation } from "@/models/entities/user-group-invitation.js"; -import { Hashtag } from "@/models/entities/hashtag.js"; -import { NoteFavorite } from "@/models/entities/note-favorite.js"; import { AbuseUserReport } from "@/models/entities/abuse-user-report.js"; -import { RegistrationTicket } from "@/models/entities/registration-tickets.js"; -import { MessagingMessage } from "@/models/entities/messaging-message.js"; -import { Signin } from "@/models/entities/signin.js"; -import { AuthSession } from "@/models/entities/auth-session.js"; -import { FollowRequest } from "@/models/entities/follow-request.js"; -import { Emoji } from "@/models/entities/emoji.js"; -import { UserNotePining } from "@/models/entities/user-note-pining.js"; -import { Poll } from "@/models/entities/poll.js"; -import { UserKeypair } from "@/models/entities/user-keypair.js"; -import { UserPublickey } from "@/models/entities/user-publickey.js"; -import { UserProfile } from "@/models/entities/user-profile.js"; -import { UserSecurityKey } from "@/models/entities/user-security-key.js"; -import { AttestationChallenge } from "@/models/entities/attestation-challenge.js"; -import { Page } from "@/models/entities/page.js"; -import { PageLike } from "@/models/entities/page-like.js"; -import { GalleryPost } from "@/models/entities/gallery-post.js"; -import { GalleryLike } from "@/models/entities/gallery-like.js"; -import { ModerationLog } from "@/models/entities/moderation-log.js"; -import { UsedUsername } from "@/models/entities/used-username.js"; -import { Announcement } from "@/models/entities/announcement.js"; +import { AccessToken } from "@/models/entities/access-token.js"; +import { Ad } from "@/models/entities/ad.js"; import { AnnouncementRead } from "@/models/entities/announcement-read.js"; -import { Clip } from "@/models/entities/clip.js"; -import { ClipNote } from "@/models/entities/clip-note.js"; +import { Announcement } from "@/models/entities/announcement.js"; import { Antenna } from "@/models/entities/antenna.js"; -import { PromoNote } from "@/models/entities/promo-note.js"; -import { PromoRead } from "@/models/entities/promo-read.js"; -import { Relay } from "@/models/entities/relay.js"; -import { MutedNote } from "@/models/entities/muted-note.js"; -import { Channel } from "@/models/entities/channel.js"; +import { App } from "@/models/entities/app.js"; +import { AttestationChallenge } from "@/models/entities/attestation-challenge.js"; +import { AuthSession } from "@/models/entities/auth-session.js"; +import { Blocking } from "@/models/entities/blocking.js"; import { ChannelFollowing } from "@/models/entities/channel-following.js"; import { ChannelNotePining } from "@/models/entities/channel-note-pining.js"; -import { RegistryItem } from "@/models/entities/registry-item.js"; -import { Ad } from "@/models/entities/ad.js"; -import { PasswordResetRequest } from "@/models/entities/password-reset-request.js"; -import { UserPending } from "@/models/entities/user-pending.js"; -import { Webhook } from "@/models/entities/webhook.js"; -import { UserIp } from "@/models/entities/user-ip.js"; +import { Channel } from "@/models/entities/channel.js"; +import { ClipNote } from "@/models/entities/clip-note.js"; +import { Clip } from "@/models/entities/clip.js"; +import { DriveFile } from "@/models/entities/drive-file.js"; +import { DriveFolder } from "@/models/entities/drive-folder.js"; +import { Emoji } from "@/models/entities/emoji.js"; +import { FollowRequest } from "@/models/entities/follow-request.js"; +import { Following } from "@/models/entities/following.js"; +import { GalleryLike } from "@/models/entities/gallery-like.js"; +import { GalleryPost } from "@/models/entities/gallery-post.js"; +import { Hashtag } from "@/models/entities/hashtag.js"; +import { Instance } from "@/models/entities/instance.js"; +import { MessagingMessage } from "@/models/entities/messaging-message.js"; +import { Meta } from "@/models/entities/meta.js"; +import { ModerationLog } from "@/models/entities/moderation-log.js"; +import { MutedNote } from "@/models/entities/muted-note.js"; +import { Muting } from "@/models/entities/muting.js"; import { NoteEdit } from "@/models/entities/note-edit.js"; +import { NoteFavorite } from "@/models/entities/note-favorite.js"; +import { NoteReaction } from "@/models/entities/note-reaction.js"; +import { NoteThreadMuting } from "@/models/entities/note-thread-muting.js"; +import { NoteUnread } from "@/models/entities/note-unread.js"; +import { NoteWatching } from "@/models/entities/note-watching.js"; +import { Note } from "@/models/entities/note.js"; +import { Notification } from "@/models/entities/notification.js"; +import { PageLike } from "@/models/entities/page-like.js"; +import { Page } from "@/models/entities/page.js"; +import { PasswordResetRequest } from "@/models/entities/password-reset-request.js"; +import { PollVote } from "@/models/entities/poll-vote.js"; +import { Poll } from "@/models/entities/poll.js"; +import { PromoNote } from "@/models/entities/promo-note.js"; +import { PromoRead } from "@/models/entities/promo-read.js"; +import { RegistrationTicket } from "@/models/entities/registration-tickets.js"; +import { RegistryItem } from "@/models/entities/registry-item.js"; +import { Relay } from "@/models/entities/relay.js"; +import { RenoteMuting } from "@/models/entities/renote-muting.js"; +import { Signin } from "@/models/entities/signin.js"; +import { SwSubscription } from "@/models/entities/sw-subscription.js"; +import { UsedUsername } from "@/models/entities/used-username.js"; +import { UserGroupInvitation } from "@/models/entities/user-group-invitation.js"; +import { UserGroupJoining } from "@/models/entities/user-group-joining.js"; +import { UserGroup } from "@/models/entities/user-group.js"; +import { UserIp } from "@/models/entities/user-ip.js"; +import { UserKeypair } from "@/models/entities/user-keypair.js"; +import { UserListJoining } from "@/models/entities/user-list-joining.js"; +import { UserList } from "@/models/entities/user-list.js"; +import { UserNotePining } from "@/models/entities/user-note-pining.js"; +import { UserPending } from "@/models/entities/user-pending.js"; +import { UserProfile } from "@/models/entities/user-profile.js"; +import { UserPublickey } from "@/models/entities/user-publickey.js"; +import { UserSecurityKey } from "@/models/entities/user-security-key.js"; +import { User } from "@/models/entities/user.js"; +import { Webhook } from "@/models/entities/webhook.js"; import { entities as charts } from "@/services/chart/entities.js"; import { dbLogger } from "./logger.js"; diff --git a/packages/backend/src/db/redis.ts b/packages/backend/src/db/redis.ts index 215effd8..aa7ffbb4 100644 --- a/packages/backend/src/db/redis.ts +++ b/packages/backend/src/db/redis.ts @@ -1,5 +1,5 @@ -import Redis from "ioredis"; import config from "@/config/index.js"; +import Redis from "ioredis"; export function createConnection() { let source = config.redis; diff --git a/packages/backend/src/mfm/to-html.ts b/packages/backend/src/mfm/to-html.ts index 47ee0c88..c2f4a9e7 100644 --- a/packages/backend/src/mfm/to-html.ts +++ b/packages/backend/src/mfm/to-html.ts @@ -1,8 +1,8 @@ +import config from "@/config/index.js"; +import type { IMentionedRemoteUsers } from "@/models/entities/note.js"; +import { intersperse } from "@/prelude/array.js"; import { Window } from "happy-dom"; import type * as mfm from "mfm-js"; -import config from "@/config/index.js"; -import { intersperse } from "@/prelude/array.js"; -import type { IMentionedRemoteUsers } from "@/models/entities/note.js"; export function toHtml( nodes: mfm.MfmNode[] | null, diff --git a/packages/backend/src/misc/antenna-cache.ts b/packages/backend/src/misc/antenna-cache.ts index 7f199c39..a4fc8741 100644 --- a/packages/backend/src/misc/antenna-cache.ts +++ b/packages/backend/src/misc/antenna-cache.ts @@ -1,6 +1,6 @@ -import { Antennas } from "@/models/index.js"; -import type { Antenna } from "@/models/entities/antenna.js"; import { subscriber } from "@/db/redis.js"; +import type { Antenna } from "@/models/entities/antenna.js"; +import { Antennas } from "@/models/index.js"; let antennasFetched = false; let antennas: Antenna[] = []; diff --git a/packages/backend/src/misc/before-shutdown.ts b/packages/backend/src/misc/before-shutdown.ts index 08204183..721e1af1 100644 --- a/packages/backend/src/misc/before-shutdown.ts +++ b/packages/backend/src/misc/before-shutdown.ts @@ -1,7 +1,5 @@ // https://gist.github.com/nfantone/1eaa803772025df69d07f4dbf5df7e58 -"use strict"; - /** * @callback BeforeShutdownListener * @param {string} [signalOrEvent] The exit signal or event name received on the process. diff --git a/packages/backend/src/misc/cache.ts b/packages/backend/src/misc/cache.ts index 913258f0..b86dd6ed 100644 --- a/packages/backend/src/misc/cache.ts +++ b/packages/backend/src/misc/cache.ts @@ -1,6 +1,6 @@ import { redisClient } from "@/db/redis.js"; -import { encode, decode } from "msgpackr"; import { ChainableCommander } from "ioredis"; +import { decode, encode } from "msgpackr"; export class Cache { private ttl: number; diff --git a/packages/backend/src/misc/captcha.ts b/packages/backend/src/misc/captcha.ts index b3b3dca3..4da04905 100644 --- a/packages/backend/src/misc/captcha.ts +++ b/packages/backend/src/misc/captcha.ts @@ -1,7 +1,7 @@ -import fetch from "node-fetch"; import { URLSearchParams } from "node:url"; -import { getAgentByUrl } from "@/misc/fetch.js"; import config from "@/config/index.js"; +import { getAgentByUrl } from "@/misc/fetch.js"; +import fetch from "node-fetch"; export async function verifyRecaptcha(secret: string, response: string) { const result = await getCaptchaResponse( diff --git a/packages/backend/src/misc/check-hit-antenna.ts b/packages/backend/src/misc/check-hit-antenna.ts index e0a3c792..0d0aa7fc 100644 --- a/packages/backend/src/misc/check-hit-antenna.ts +++ b/packages/backend/src/misc/check-hit-antenna.ts @@ -1,12 +1,12 @@ +import * as Acct from "@/misc/acct.js"; +import { Cache } from "@/misc/cache.js"; +import { getWordHardMute } from "@/misc/check-word-mute.js"; +import type { Packed } from "@/misc/schema.js"; import type { Antenna } from "@/models/entities/antenna.js"; import type { Note } from "@/models/entities/note.js"; import type { User } from "@/models/entities/user.js"; import { Blockings, Followings, UserProfiles } from "@/models/index.js"; import { getFullApAccount } from "./convert-host.js"; -import * as Acct from "@/misc/acct.js"; -import type { Packed } from "@/misc/schema.js"; -import { Cache } from "@/misc/cache.js"; -import { getWordHardMute } from "@/misc/check-word-mute.js"; const blockingCache = new Cache("blocking", 60 * 5); const mutedWordsCache = new Cache("mutedWords", 60 * 5); @@ -78,8 +78,8 @@ export async function checkHitAntenna( const matched = excludeKeywords.some((and) => and.every((keyword) => antenna.caseSensitive - ? note.text!.includes(keyword) - : note.text!.toLowerCase().includes(keyword.toLowerCase()), + ? note.text?.includes(keyword) + : note.text?.toLowerCase().includes(keyword.toLowerCase()), ), ); diff --git a/packages/backend/src/misc/check-word-mute.ts b/packages/backend/src/misc/check-word-mute.ts index 5686aef2..c5348d16 100644 --- a/packages/backend/src/misc/check-word-mute.ts +++ b/packages/backend/src/misc/check-word-mute.ts @@ -1,5 +1,5 @@ -import RE2 from "re2"; import type { Note } from "@/models/entities/note.js"; +import RE2 from "re2"; type NoteLike = { userId: Note["userId"]; diff --git a/packages/backend/src/misc/convert-host.ts b/packages/backend/src/misc/convert-host.ts index 856ce3c1..3d7a7abb 100644 --- a/packages/backend/src/misc/convert-host.ts +++ b/packages/backend/src/misc/convert-host.ts @@ -1,6 +1,6 @@ import { URL } from "node:url"; -import config from "@/config/index.js"; import { toASCII } from "punycode"; +import config from "@/config/index.js"; export function getFullApAccount(username: string, host: string | null) { return host diff --git a/packages/backend/src/misc/detect-language.ts b/packages/backend/src/misc/detect-language.ts index 6147247d..15763d5a 100644 --- a/packages/backend/src/misc/detect-language.ts +++ b/packages/backend/src/misc/detect-language.ts @@ -1,5 +1,5 @@ -import { detect } from "tinyld"; import * as mfm from "mfm-js"; +import { detect } from "tinyld"; export default function detectLanguage(text: string): string { const nodes = mfm.parse(text); diff --git a/packages/backend/src/misc/download-url.ts b/packages/backend/src/misc/download-url.ts index 83680c17..0112dcfb 100644 --- a/packages/backend/src/misc/download-url.ts +++ b/packages/backend/src/misc/download-url.ts @@ -1,13 +1,13 @@ import * as fs from "node:fs"; import * as stream from "node:stream"; import * as util from "node:util"; -import got, * as Got from "got"; -import { httpAgent, httpsAgent, StatusError } from "./fetch.js"; import config from "@/config/index.js"; -import chalk from "chalk"; import Logger from "@/services/logger.js"; +import chalk from "chalk"; +import got, * as Got from "got"; import IPCIDR from "ip-cidr"; import PrivateIp from "private-ip"; +import { StatusError, httpAgent, httpsAgent } from "./fetch.js"; const pipeline = util.promisify(stream.pipeline); diff --git a/packages/backend/src/misc/emoji-meta.ts b/packages/backend/src/misc/emoji-meta.ts index 2b9365b8..360cf931 100644 --- a/packages/backend/src/misc/emoji-meta.ts +++ b/packages/backend/src/misc/emoji-meta.ts @@ -2,9 +2,9 @@ import probeImageSize from "probe-image-size"; import { Mutex } from "redis-semaphore"; import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; +import { redisClient } from "@/db/redis.js"; import Logger from "@/services/logger.js"; import { Cache } from "./cache.js"; -import { redisClient } from "@/db/redis.js"; export type Size = { width: number; diff --git a/packages/backend/src/misc/extract-custom-emojis-from-mfm.ts b/packages/backend/src/misc/extract-custom-emojis-from-mfm.ts index 7de32e6d..f79f8c43 100644 --- a/packages/backend/src/misc/extract-custom-emojis-from-mfm.ts +++ b/packages/backend/src/misc/extract-custom-emojis-from-mfm.ts @@ -1,5 +1,5 @@ -import * as mfm from "mfm-js"; import { unique } from "@/prelude/array.js"; +import * as mfm from "mfm-js"; export function extractCustomEmojisFromMfm(nodes: mfm.MfmNode[]): string[] { const emojiNodes = mfm.extract(nodes, (node) => { diff --git a/packages/backend/src/misc/extract-hashtags.ts b/packages/backend/src/misc/extract-hashtags.ts index 826e3622..2b575e8a 100644 --- a/packages/backend/src/misc/extract-hashtags.ts +++ b/packages/backend/src/misc/extract-hashtags.ts @@ -1,5 +1,5 @@ -import * as mfm from "mfm-js"; import { unique } from "@/prelude/array.js"; +import * as mfm from "mfm-js"; export function extractHashtags(nodes: mfm.MfmNode[]): string[] { const hashtagNodes = mfm.extract(nodes, (node) => node.type === "hashtag"); diff --git a/packages/backend/src/misc/fetch-proxy-account.ts b/packages/backend/src/misc/fetch-proxy-account.ts index a277db6f..4aa20cbc 100644 --- a/packages/backend/src/misc/fetch-proxy-account.ts +++ b/packages/backend/src/misc/fetch-proxy-account.ts @@ -1,6 +1,6 @@ -import { fetchMeta } from "./fetch-meta.js"; import type { ILocalUser } from "@/models/entities/user.js"; import { Users } from "@/models/index.js"; +import { fetchMeta } from "./fetch-meta.js"; export async function fetchProxyAccount(): Promise { const meta = await fetchMeta(); diff --git a/packages/backend/src/misc/fetch.ts b/packages/backend/src/misc/fetch.ts index e47ef0d4..d7e8ce69 100644 --- a/packages/backend/src/misc/fetch.ts +++ b/packages/backend/src/misc/fetch.ts @@ -1,10 +1,10 @@ import * as http from "node:http"; import * as https from "node:https"; import type { URL } from "node:url"; -import CacheableLookup from "cacheable-lookup"; -import fetch from "node-fetch"; -import { HttpProxyAgent, HttpsProxyAgent } from "hpagent"; import config from "@/config/index.js"; +import CacheableLookup from "cacheable-lookup"; +import { HttpProxyAgent, HttpsProxyAgent } from "hpagent"; +import fetch from "node-fetch"; export async function getJson( url: string, diff --git a/packages/backend/src/misc/gen-id.ts b/packages/backend/src/misc/gen-id.ts index 737bbe48..5da622b9 100644 --- a/packages/backend/src/misc/gen-id.ts +++ b/packages/backend/src/misc/gen-id.ts @@ -1,8 +1,8 @@ import config from "@/config/index.js"; import { nativeCreateId, - nativeInitIdGenerator, nativeGetTimestamp, + nativeInitIdGenerator, } from "native-utils/built/index.js"; const length = Math.min(Math.max(config.cuid?.length ?? 16, 16), 24); diff --git a/packages/backend/src/misc/get-file-info.ts b/packages/backend/src/misc/get-file-info.ts index 76964890..a008e9c2 100644 --- a/packages/backend/src/misc/get-file-info.ts +++ b/packages/backend/src/misc/get-file-info.ts @@ -1,17 +1,17 @@ -import * as fs from "node:fs"; import * as crypto from "node:crypto"; +import * as fs from "node:fs"; import { join } from "node:path"; import * as stream from "node:stream"; import * as util from "node:util"; +import { detectSensitive } from "@/services/detect-sensitive.js"; +import { encode } from "blurhash"; import { FSWatcher } from "chokidar"; import { fileTypeFromFile } from "file-type"; -import probeImageSize from "probe-image-size"; import FFmpeg from "fluent-ffmpeg"; import isSvg from "is-svg"; import { type predictionType } from "nsfwjs"; +import probeImageSize from "probe-image-size"; import sharp from "sharp"; -import { encode } from "blurhash"; -import { detectSensitive } from "@/services/detect-sensitive.js"; import { createTempDir } from "./create-temp.js"; const pipeline = util.promisify(stream.pipeline); diff --git a/packages/backend/src/misc/id/aid.ts b/packages/backend/src/misc/id/aid.ts index a1236036..05576d4d 100644 --- a/packages/backend/src/misc/id/aid.ts +++ b/packages/backend/src/misc/id/aid.ts @@ -19,7 +19,7 @@ function getNoise() { export function genAid(date: Date): string { const t = date.getTime(); - if (isNaN(t)) throw "Failed to create AID: Invalid Date"; + if (Number.isNaN(t)) throw "Failed to create AID: Invalid Date"; counter++; return getTime(t) + getNoise(); } diff --git a/packages/backend/src/misc/keypair-store.ts b/packages/backend/src/misc/keypair-store.ts index 62557735..b8c0ed5d 100644 --- a/packages/backend/src/misc/keypair-store.ts +++ b/packages/backend/src/misc/keypair-store.ts @@ -1,6 +1,6 @@ -import { UserKeypairs } from "@/models/index.js"; -import type { User } from "@/models/entities/user.js"; import type { UserKeypair } from "@/models/entities/user-keypair.js"; +import type { User } from "@/models/entities/user.js"; +import { UserKeypairs } from "@/models/index.js"; import { Cache } from "./cache.js"; const cache = new Cache("keypairStore", 60 * 30); diff --git a/packages/backend/src/misc/password.ts b/packages/backend/src/misc/password.ts index c63f89f5..52c13934 100644 --- a/packages/backend/src/misc/password.ts +++ b/packages/backend/src/misc/password.ts @@ -1,5 +1,5 @@ -import bcrypt from "bcryptjs"; import * as argon2 from "argon2"; +import bcrypt from "bcryptjs"; export async function hashPassword(password: string): Promise { return argon2.hash(password); diff --git a/packages/backend/src/misc/populate-emojis.ts b/packages/backend/src/misc/populate-emojis.ts index 795a267f..eb68c2b2 100644 --- a/packages/backend/src/misc/populate-emojis.ts +++ b/packages/backend/src/misc/populate-emojis.ts @@ -1,13 +1,13 @@ -import { In, IsNull } from "typeorm"; -import { Emojis } from "@/models/index.js"; +import config from "@/config/index.js"; +import { redisClient } from "@/db/redis.js"; import type { Emoji } from "@/models/entities/emoji.js"; import type { Note } from "@/models/entities/note.js"; +import { Emojis } from "@/models/index.js"; +import { query } from "@/prelude/url.js"; +import { In, IsNull } from "typeorm"; import { Cache } from "./cache.js"; import { isSelfHost, toPunyNullable } from "./convert-host.js"; import { decodeReaction } from "./reaction-lib.js"; -import config from "@/config/index.js"; -import { query } from "@/prelude/url.js"; -import { redisClient } from "@/db/redis.js"; const cache = new Cache("populateEmojis", 60 * 60 * 12); @@ -118,12 +118,12 @@ export function aggregateNoteEmojis(notes: Note[]) { ); if (note.renote) { emojis = emojis.concat( - note.renote.emojis.map((e) => parseEmojiStr(e, note.renote!.userHost)), + note.renote.emojis.map((e) => parseEmojiStr(e, note.renote?.userHost)), ); if (note.renote.user) { emojis = emojis.concat( note.renote.user.emojis.map((e) => - parseEmojiStr(e, note.renote!.userHost), + parseEmojiStr(e, note.renote?.userHost), ), ); } diff --git a/packages/backend/src/misc/post.ts b/packages/backend/src/misc/post.ts index dbe703d1..0b107ed0 100644 --- a/packages/backend/src/misc/post.ts +++ b/packages/backend/src/misc/post.ts @@ -12,7 +12,7 @@ export function parse(acct: any): Post { cw: acct.cw, localOnly: acct.localOnly, createdAt: new Date(acct.createdAt), - visibility: "hidden" + (acct.visibility || ""), + visibility: `hidden${acct.visibility || ""}`, }; } diff --git a/packages/backend/src/misc/process-masto-notes.ts b/packages/backend/src/misc/process-masto-notes.ts index 1327b4cf..229756e9 100644 --- a/packages/backend/src/misc/process-masto-notes.ts +++ b/packages/backend/src/misc/process-masto-notes.ts @@ -1,13 +1,13 @@ import * as fs from "node:fs"; +import * as Path from "node:path"; +import { Users } from "@/models/index.js"; +import { addFile } from "@/services/drive/add-file.js"; import Logger from "@/services/logger.js"; +import decompress from "decompress"; +import gunzip from "gunzip-maybe"; +import * as tar from "tar-stream"; import { createTemp, createTempDir } from "./create-temp.js"; import { downloadUrl } from "./download-url.js"; -import { addFile } from "@/services/drive/add-file.js"; -import { Users } from "@/models/index.js"; -import * as tar from "tar-stream"; -import gunzip from "gunzip-maybe"; -import decompress from "decompress"; -import * as Path from "node:path"; const logger = new Logger("process-masto-notes"); @@ -108,7 +108,7 @@ function unzipTarGz(fn: string, dir: string) { }; try { const extract = tar.extract().on("error", onErr); - dir = dir.endsWith("/") ? dir : dir + "/"; + dir = dir.endsWith("/") ? dir : `${dir}/`; const ls: string[] = []; extract.on("entry", function (header: any, stream: any, next: any) { try { diff --git a/packages/backend/src/misc/reaction-lib.ts b/packages/backend/src/misc/reaction-lib.ts index db88b059..b3e4903f 100644 --- a/packages/backend/src/misc/reaction-lib.ts +++ b/packages/backend/src/misc/reaction-lib.ts @@ -1,8 +1,8 @@ +import { Emojis } from "@/models/index.js"; +import { IsNull } from "typeorm"; +import { toPunyNullable } from "./convert-host.js"; import { emojiRegex } from "./emoji-regex.js"; import { fetchMeta } from "./fetch-meta.js"; -import { Emojis } from "@/models/index.js"; -import { toPunyNullable } from "./convert-host.js"; -import { IsNull } from "typeorm"; export function convertReactions(reactions: Record) { const result = new Map(); diff --git a/packages/backend/src/misc/schema.ts b/packages/backend/src/misc/schema.ts index 6e03d30d..4e0fdc5d 100644 --- a/packages/backend/src/misc/schema.ts +++ b/packages/backend/src/misc/schema.ts @@ -1,36 +1,36 @@ -import { - packedUserLiteSchema, - packedUserDetailedNotMeOnlySchema, - packedMeDetailedOnlySchema, - packedUserDetailedNotMeSchema, - packedMeDetailedSchema, - packedUserDetailedSchema, - packedUserSchema, -} from "@/models/schema/user.js"; -import { packedNoteSchema } from "@/models/schema/note.js"; -import { packedUserListSchema } from "@/models/schema/user-list.js"; +import { packedAntennaSchema } from "@/models/schema/antenna.js"; import { packedAppSchema } from "@/models/schema/app.js"; -import { packedMessagingMessageSchema } from "@/models/schema/messaging-message.js"; -import { packedNotificationSchema } from "@/models/schema/notification.js"; +import { packedBlockingSchema } from "@/models/schema/blocking.js"; +import { packedChannelSchema } from "@/models/schema/channel.js"; +import { packedClipSchema } from "@/models/schema/clip.js"; import { packedDriveFileSchema } from "@/models/schema/drive-file.js"; import { packedDriveFolderSchema } from "@/models/schema/drive-folder.js"; -import { packedFollowingSchema } from "@/models/schema/following.js"; -import { packedMutingSchema } from "@/models/schema/muting.js"; -import { packedRenoteMutingSchema } from "@/models/schema/renote-muting.js"; -import { packedBlockingSchema } from "@/models/schema/blocking.js"; -import { packedNoteReactionSchema } from "@/models/schema/note-reaction.js"; -import { packedHashtagSchema } from "@/models/schema/hashtag.js"; -import { packedPageSchema } from "@/models/schema/page.js"; -import { packedUserGroupSchema } from "@/models/schema/user-group.js"; -import { packedNoteFavoriteSchema } from "@/models/schema/note-favorite.js"; -import { packedChannelSchema } from "@/models/schema/channel.js"; -import { packedAntennaSchema } from "@/models/schema/antenna.js"; -import { packedClipSchema } from "@/models/schema/clip.js"; -import { packedFederationInstanceSchema } from "@/models/schema/federation-instance.js"; -import { packedQueueCountSchema } from "@/models/schema/queue.js"; -import { packedGalleryPostSchema } from "@/models/schema/gallery-post.js"; import { packedEmojiSchema } from "@/models/schema/emoji.js"; +import { packedFederationInstanceSchema } from "@/models/schema/federation-instance.js"; +import { packedFollowingSchema } from "@/models/schema/following.js"; +import { packedGalleryPostSchema } from "@/models/schema/gallery-post.js"; +import { packedHashtagSchema } from "@/models/schema/hashtag.js"; +import { packedMessagingMessageSchema } from "@/models/schema/messaging-message.js"; +import { packedMutingSchema } from "@/models/schema/muting.js"; import { packedNoteEdit } from "@/models/schema/note-edit.js"; +import { packedNoteFavoriteSchema } from "@/models/schema/note-favorite.js"; +import { packedNoteReactionSchema } from "@/models/schema/note-reaction.js"; +import { packedNoteSchema } from "@/models/schema/note.js"; +import { packedNotificationSchema } from "@/models/schema/notification.js"; +import { packedPageSchema } from "@/models/schema/page.js"; +import { packedQueueCountSchema } from "@/models/schema/queue.js"; +import { packedRenoteMutingSchema } from "@/models/schema/renote-muting.js"; +import { packedUserGroupSchema } from "@/models/schema/user-group.js"; +import { packedUserListSchema } from "@/models/schema/user-list.js"; +import { + packedMeDetailedOnlySchema, + packedMeDetailedSchema, + packedUserDetailedNotMeOnlySchema, + packedUserDetailedNotMeSchema, + packedUserDetailedSchema, + packedUserLiteSchema, + packedUserSchema, +} from "@/models/schema/user.js"; export const refs = { UserLite: packedUserLiteSchema, diff --git a/packages/backend/src/misc/show-machine-info.ts b/packages/backend/src/misc/show-machine-info.ts index d3a28cbd..7b5db8d2 100644 --- a/packages/backend/src/misc/show-machine-info.ts +++ b/packages/backend/src/misc/show-machine-info.ts @@ -1,6 +1,6 @@ import * as os from "node:os"; -import sysUtils from "systeminformation"; import type Logger from "@/services/logger.js"; +import sysUtils from "systeminformation"; export async function showMachineInfo(parentLogger: Logger) { const logger = parentLogger.createSubLogger("machine"); diff --git a/packages/backend/src/misc/skipped-instances.ts b/packages/backend/src/misc/skipped-instances.ts index 78539302..59d5a2fc 100644 --- a/packages/backend/src/misc/skipped-instances.ts +++ b/packages/backend/src/misc/skipped-instances.ts @@ -1,8 +1,8 @@ -import { Brackets } from "typeorm"; -import { fetchMeta } from "@/misc/fetch-meta.js"; -import { Instances } from "@/models/index.js"; -import type { Instance } from "@/models/entities/instance.js"; import { DAY } from "@/const.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; +import type { Instance } from "@/models/entities/instance.js"; +import { Instances } from "@/models/index.js"; +import { Brackets } from "typeorm"; import { shouldBlockInstance } from "./should-block-instance.js"; // Threshold from last contact after which an instance will be considered diff --git a/packages/backend/src/misc/webhook-cache.ts b/packages/backend/src/misc/webhook-cache.ts index 1eda5eae..6ffbde5c 100644 --- a/packages/backend/src/misc/webhook-cache.ts +++ b/packages/backend/src/misc/webhook-cache.ts @@ -1,6 +1,6 @@ -import { Webhooks } from "@/models/index.js"; -import type { Webhook } from "@/models/entities/webhook.js"; import { subscriber } from "@/db/redis.js"; +import type { Webhook } from "@/models/entities/webhook.js"; +import { Webhooks } from "@/models/index.js"; let webhooksFetched = false; let webhooks: Webhook[] = []; diff --git a/packages/backend/src/models/entities/abuse-user-report.ts b/packages/backend/src/models/entities/abuse-user-report.ts index cb4d5585..47063cca 100644 --- a/packages/backend/src/models/entities/abuse-user-report.ts +++ b/packages/backend/src/models/entities/abuse-user-report.ts @@ -1,13 +1,13 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; +import { User } from "./user.js"; @Entity() export class AbuseUserReport { diff --git a/packages/backend/src/models/entities/access-token.ts b/packages/backend/src/models/entities/access-token.ts index 8b950b17..260f3f83 100644 --- a/packages/backend/src/models/entities/access-token.ts +++ b/packages/backend/src/models/entities/access-token.ts @@ -1,14 +1,14 @@ import { - Entity, - PrimaryColumn, - Index, Column, - ManyToOne, + Entity, + Index, JoinColumn, + ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; -import { App } from "./app.js"; import { id } from "../id.js"; +import { App } from "./app.js"; +import { User } from "./user.js"; @Entity() export class AccessToken { diff --git a/packages/backend/src/models/entities/ad.ts b/packages/backend/src/models/entities/ad.ts index 80d54ddd..0fad2bdb 100644 --- a/packages/backend/src/models/entities/ad.ts +++ b/packages/backend/src/models/entities/ad.ts @@ -1,4 +1,4 @@ -import { Entity, Index, Column, PrimaryColumn } from "typeorm"; +import { Column, Entity, Index, PrimaryColumn } from "typeorm"; import { id } from "../id.js"; @Entity() diff --git a/packages/backend/src/models/entities/announcement-read.ts b/packages/backend/src/models/entities/announcement-read.ts index 79af9e48..68dcbffc 100644 --- a/packages/backend/src/models/entities/announcement-read.ts +++ b/packages/backend/src/models/entities/announcement-read.ts @@ -1,14 +1,14 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; -import { Announcement } from "./announcement.js"; import { id } from "../id.js"; +import { Announcement } from "./announcement.js"; +import { User } from "./user.js"; @Entity() @Index(["userId", "announcementId"], { unique: true }) diff --git a/packages/backend/src/models/entities/announcement.ts b/packages/backend/src/models/entities/announcement.ts index 7872c0fe..baa69ebe 100644 --- a/packages/backend/src/models/entities/announcement.ts +++ b/packages/backend/src/models/entities/announcement.ts @@ -1,4 +1,4 @@ -import { Entity, Index, Column, PrimaryColumn } from "typeorm"; +import { Column, Entity, Index, PrimaryColumn } from "typeorm"; import { id } from "../id.js"; @Entity() diff --git a/packages/backend/src/models/entities/antenna.ts b/packages/backend/src/models/entities/antenna.ts index 633dcc1d..b535afc1 100644 --- a/packages/backend/src/models/entities/antenna.ts +++ b/packages/backend/src/models/entities/antenna.ts @@ -1,15 +1,15 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; -import { UserList } from "./user-list.js"; import { UserGroupJoining } from "./user-group-joining.js"; +import { UserList } from "./user-list.js"; +import { User } from "./user.js"; @Entity() export class Antenna { diff --git a/packages/backend/src/models/entities/app.ts b/packages/backend/src/models/entities/app.ts index a41e35aa..30f893c1 100644 --- a/packages/backend/src/models/entities/app.ts +++ b/packages/backend/src/models/entities/app.ts @@ -1,6 +1,6 @@ -import { Entity, PrimaryColumn, Column, Index, ManyToOne } from "typeorm"; -import { User } from "./user.js"; +import { Column, Entity, Index, ManyToOne, PrimaryColumn } from "typeorm"; import { id } from "../id.js"; +import { User } from "./user.js"; @Entity() export class App { diff --git a/packages/backend/src/models/entities/attestation-challenge.ts b/packages/backend/src/models/entities/attestation-challenge.ts index 6a3a9c8e..1fe363a2 100644 --- a/packages/backend/src/models/entities/attestation-challenge.ts +++ b/packages/backend/src/models/entities/attestation-challenge.ts @@ -1,13 +1,13 @@ import { - PrimaryColumn, - Entity, - JoinColumn, Column, - ManyToOne, + Entity, Index, + JoinColumn, + ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; +import { User } from "./user.js"; @Entity() export class AttestationChallenge { diff --git a/packages/backend/src/models/entities/auth-session.ts b/packages/backend/src/models/entities/auth-session.ts index b31dca56..c7028cff 100644 --- a/packages/backend/src/models/entities/auth-session.ts +++ b/packages/backend/src/models/entities/auth-session.ts @@ -1,14 +1,14 @@ import { - Entity, - PrimaryColumn, - Index, Column, - ManyToOne, + Entity, + Index, JoinColumn, + ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; -import { App } from "./app.js"; import { id } from "../id.js"; +import { App } from "./app.js"; +import { User } from "./user.js"; @Entity() export class AuthSession { diff --git a/packages/backend/src/models/entities/blocking.ts b/packages/backend/src/models/entities/blocking.ts index 55f677a9..edbbca9c 100644 --- a/packages/backend/src/models/entities/blocking.ts +++ b/packages/backend/src/models/entities/blocking.ts @@ -1,13 +1,13 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; +import { User } from "./user.js"; @Entity() @Index(["blockerId", "blockeeId"], { unique: true }) diff --git a/packages/backend/src/models/entities/channel-following.ts b/packages/backend/src/models/entities/channel-following.ts index ee329fa5..9c1ac9ea 100644 --- a/packages/backend/src/models/entities/channel-following.ts +++ b/packages/backend/src/models/entities/channel-following.ts @@ -1,14 +1,14 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; import { Channel } from "./channel.js"; +import { User } from "./user.js"; @Entity() @Index(["followerId", "followeeId"], { unique: true }) diff --git a/packages/backend/src/models/entities/channel-note-pining.ts b/packages/backend/src/models/entities/channel-note-pining.ts index 67d1d48c..adef9a46 100644 --- a/packages/backend/src/models/entities/channel-note-pining.ts +++ b/packages/backend/src/models/entities/channel-note-pining.ts @@ -1,14 +1,14 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { Note } from "./note.js"; -import { Channel } from "./channel.js"; import { id } from "../id.js"; +import { Channel } from "./channel.js"; +import { Note } from "./note.js"; @Entity() @Index(["channelId", "noteId"], { unique: true }) diff --git a/packages/backend/src/models/entities/channel.ts b/packages/backend/src/models/entities/channel.ts index ea22fed5..06b835c0 100644 --- a/packages/backend/src/models/entities/channel.ts +++ b/packages/backend/src/models/entities/channel.ts @@ -1,14 +1,14 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; import { DriveFile } from "./drive-file.js"; +import { User } from "./user.js"; @Entity() export class Channel { diff --git a/packages/backend/src/models/entities/clip-note.ts b/packages/backend/src/models/entities/clip-note.ts index 1697474a..1e2c0f89 100644 --- a/packages/backend/src/models/entities/clip-note.ts +++ b/packages/backend/src/models/entities/clip-note.ts @@ -1,14 +1,14 @@ import { + Column, Entity, Index, JoinColumn, - Column, ManyToOne, PrimaryColumn, } from "typeorm"; -import { Note } from "./note.js"; -import { Clip } from "./clip.js"; import { id } from "../id.js"; +import { Clip } from "./clip.js"; +import { Note } from "./note.js"; @Entity() @Index(["noteId", "clipId"], { unique: true }) diff --git a/packages/backend/src/models/entities/clip.ts b/packages/backend/src/models/entities/clip.ts index 9554703a..8f5ce524 100644 --- a/packages/backend/src/models/entities/clip.ts +++ b/packages/backend/src/models/entities/clip.ts @@ -1,13 +1,13 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; +import { User } from "./user.js"; @Entity() export class Clip { diff --git a/packages/backend/src/models/entities/drive-file.ts b/packages/backend/src/models/entities/drive-file.ts index da93f32a..1174a628 100644 --- a/packages/backend/src/models/entities/drive-file.ts +++ b/packages/backend/src/models/entities/drive-file.ts @@ -1,15 +1,15 @@ +import { DB_MAX_IMAGE_COMMENT_LENGTH } from "@/misc/hard-limits.js"; import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; import { id } from "../id.js"; -import { User } from "./user.js"; import { DriveFolder } from "./drive-folder.js"; -import { DB_MAX_IMAGE_COMMENT_LENGTH } from "@/misc/hard-limits.js"; +import { User } from "./user.js"; @Entity() @Index(["userId", "folderId", "id"]) diff --git a/packages/backend/src/models/entities/drive-folder.ts b/packages/backend/src/models/entities/drive-folder.ts index 0bb2c7a3..bc4ef9d3 100644 --- a/packages/backend/src/models/entities/drive-folder.ts +++ b/packages/backend/src/models/entities/drive-folder.ts @@ -1,13 +1,13 @@ import { + Column, + Entity, + Index, JoinColumn, ManyToOne, - Entity, PrimaryColumn, - Index, - Column, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; +import { User } from "./user.js"; @Entity() export class DriveFolder { diff --git a/packages/backend/src/models/entities/emoji.ts b/packages/backend/src/models/entities/emoji.ts index 87b525dc..760213e6 100644 --- a/packages/backend/src/models/entities/emoji.ts +++ b/packages/backend/src/models/entities/emoji.ts @@ -1,4 +1,4 @@ -import { PrimaryColumn, Entity, Index, Column } from "typeorm"; +import { Column, Entity, Index, PrimaryColumn } from "typeorm"; import { id } from "../id.js"; @Entity() diff --git a/packages/backend/src/models/entities/follow-request.ts b/packages/backend/src/models/entities/follow-request.ts index 281eab91..3e4bf423 100644 --- a/packages/backend/src/models/entities/follow-request.ts +++ b/packages/backend/src/models/entities/follow-request.ts @@ -1,13 +1,13 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; +import { User } from "./user.js"; @Entity() @Index(["followerId", "followeeId"], { unique: true }) diff --git a/packages/backend/src/models/entities/following.ts b/packages/backend/src/models/entities/following.ts index ea8f3256..841553e5 100644 --- a/packages/backend/src/models/entities/following.ts +++ b/packages/backend/src/models/entities/following.ts @@ -1,13 +1,13 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; +import { User } from "./user.js"; @Entity() @Index(["followerId", "followeeId"], { unique: true }) diff --git a/packages/backend/src/models/entities/gallery-like.ts b/packages/backend/src/models/entities/gallery-like.ts index 259feb8b..8393930a 100644 --- a/packages/backend/src/models/entities/gallery-like.ts +++ b/packages/backend/src/models/entities/gallery-like.ts @@ -1,14 +1,14 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; import { GalleryPost } from "./gallery-post.js"; +import { User } from "./user.js"; @Entity() @Index(["userId", "postId"], { unique: true }) diff --git a/packages/backend/src/models/entities/gallery-post.ts b/packages/backend/src/models/entities/gallery-post.ts index 93834865..601d323a 100644 --- a/packages/backend/src/models/entities/gallery-post.ts +++ b/packages/backend/src/models/entities/gallery-post.ts @@ -1,14 +1,14 @@ import { + Column, Entity, Index, JoinColumn, - Column, - PrimaryColumn, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; import type { DriveFile } from "./drive-file.js"; +import { User } from "./user.js"; @Entity() export class GalleryPost { diff --git a/packages/backend/src/models/entities/hashtag.ts b/packages/backend/src/models/entities/hashtag.ts index 7b3df1cc..60a4c404 100644 --- a/packages/backend/src/models/entities/hashtag.ts +++ b/packages/backend/src/models/entities/hashtag.ts @@ -1,6 +1,6 @@ -import { Entity, PrimaryColumn, Index, Column } from "typeorm"; -import type { User } from "./user.js"; +import { Column, Entity, Index, PrimaryColumn } from "typeorm"; import { id } from "../id.js"; +import type { User } from "./user.js"; @Entity() export class Hashtag { diff --git a/packages/backend/src/models/entities/instance.ts b/packages/backend/src/models/entities/instance.ts index 7b7701d0..d2e14780 100644 --- a/packages/backend/src/models/entities/instance.ts +++ b/packages/backend/src/models/entities/instance.ts @@ -1,4 +1,4 @@ -import { Entity, PrimaryColumn, Index, Column } from "typeorm"; +import { Column, Entity, Index, PrimaryColumn } from "typeorm"; import { id } from "../id.js"; @Entity() diff --git a/packages/backend/src/models/entities/messaging-message.ts b/packages/backend/src/models/entities/messaging-message.ts index d1da00ea..38fcb92d 100644 --- a/packages/backend/src/models/entities/messaging-message.ts +++ b/packages/backend/src/models/entities/messaging-message.ts @@ -1,15 +1,15 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; -import { DriveFile } from "./drive-file.js"; import { id } from "../id.js"; +import { DriveFile } from "./drive-file.js"; import { UserGroup } from "./user-group.js"; +import { User } from "./user.js"; @Entity() export class MessagingMessage { diff --git a/packages/backend/src/models/entities/meta.ts b/packages/backend/src/models/entities/meta.ts index 25112ed4..179895e3 100644 --- a/packages/backend/src/models/entities/meta.ts +++ b/packages/backend/src/models/entities/meta.ts @@ -1,7 +1,7 @@ -import { Entity, Column, PrimaryColumn, ManyToOne, JoinColumn } from "typeorm"; +import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from "typeorm"; import { id } from "../id.js"; -import { User } from "./user.js"; import type { Clip } from "./clip.js"; +import { User } from "./user.js"; @Entity() export class Meta { diff --git a/packages/backend/src/models/entities/moderation-log.ts b/packages/backend/src/models/entities/moderation-log.ts index 26bf1cdf..dd811395 100644 --- a/packages/backend/src/models/entities/moderation-log.ts +++ b/packages/backend/src/models/entities/moderation-log.ts @@ -1,13 +1,13 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; +import { User } from "./user.js"; @Entity() export class ModerationLog { diff --git a/packages/backend/src/models/entities/muted-note.ts b/packages/backend/src/models/entities/muted-note.ts index 0ee245ae..5d9566a1 100644 --- a/packages/backend/src/models/entities/muted-note.ts +++ b/packages/backend/src/models/entities/muted-note.ts @@ -1,15 +1,15 @@ import { + Column, Entity, Index, JoinColumn, - Column, ManyToOne, PrimaryColumn, } from "typeorm"; +import { mutedNoteReasons } from "../../types.js"; +import { id } from "../id.js"; import { Note } from "./note.js"; import { User } from "./user.js"; -import { id } from "../id.js"; -import { mutedNoteReasons } from "../../types.js"; @Entity() @Index(["noteId", "userId"], { unique: true }) diff --git a/packages/backend/src/models/entities/muting.ts b/packages/backend/src/models/entities/muting.ts index 603619b4..b4c3a580 100644 --- a/packages/backend/src/models/entities/muting.ts +++ b/packages/backend/src/models/entities/muting.ts @@ -1,13 +1,13 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; +import { User } from "./user.js"; @Entity() @Index(["muterId", "muteeId"], { unique: true }) diff --git a/packages/backend/src/models/entities/note-edit.ts b/packages/backend/src/models/entities/note-edit.ts index 8761e2b1..fea5c352 100644 --- a/packages/backend/src/models/entities/note-edit.ts +++ b/packages/backend/src/models/entities/note-edit.ts @@ -1,14 +1,14 @@ import { - Entity, - JoinColumn, Column, + Entity, + Index, + JoinColumn, ManyToOne, PrimaryColumn, - Index, } from "typeorm"; -import { Note } from "./note.js"; import { id } from "../id.js"; import { DriveFile } from "./drive-file.js"; +import { Note } from "./note.js"; @Entity() export class NoteEdit { diff --git a/packages/backend/src/models/entities/note-favorite.ts b/packages/backend/src/models/entities/note-favorite.ts index 19641ecf..5076695c 100644 --- a/packages/backend/src/models/entities/note-favorite.ts +++ b/packages/backend/src/models/entities/note-favorite.ts @@ -1,14 +1,14 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; +import { id } from "../id.js"; import { Note } from "./note.js"; import { User } from "./user.js"; -import { id } from "../id.js"; @Entity() @Index(["userId", "noteId"], { unique: true }) diff --git a/packages/backend/src/models/entities/note-reaction.ts b/packages/backend/src/models/entities/note-reaction.ts index 5e2a8d3e..35bac22b 100644 --- a/packages/backend/src/models/entities/note-reaction.ts +++ b/packages/backend/src/models/entities/note-reaction.ts @@ -1,14 +1,14 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; -import { Note } from "./note.js"; import { id } from "../id.js"; +import { Note } from "./note.js"; +import { User } from "./user.js"; @Entity() @Index(["userId", "noteId"], { unique: true }) diff --git a/packages/backend/src/models/entities/note-thread-muting.ts b/packages/backend/src/models/entities/note-thread-muting.ts index 7e5fad59..1b2bbebd 100644 --- a/packages/backend/src/models/entities/note-thread-muting.ts +++ b/packages/backend/src/models/entities/note-thread-muting.ts @@ -1,13 +1,13 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; +import { User } from "./user.js"; @Entity() @Index(["userId", "threadId"], { unique: true }) diff --git a/packages/backend/src/models/entities/note-unread.ts b/packages/backend/src/models/entities/note-unread.ts index 95695cbc..a85db909 100644 --- a/packages/backend/src/models/entities/note-unread.ts +++ b/packages/backend/src/models/entities/note-unread.ts @@ -1,15 +1,15 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; -import { Note } from "./note.js"; import { id } from "../id.js"; import type { Channel } from "./channel.js"; +import { Note } from "./note.js"; +import { User } from "./user.js"; @Entity() @Index(["userId", "noteId"], { unique: true }) diff --git a/packages/backend/src/models/entities/note-watching.ts b/packages/backend/src/models/entities/note-watching.ts index 724b084a..8bc296df 100644 --- a/packages/backend/src/models/entities/note-watching.ts +++ b/packages/backend/src/models/entities/note-watching.ts @@ -1,14 +1,14 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; -import { Note } from "./note.js"; import { id } from "../id.js"; +import { Note } from "./note.js"; +import { User } from "./user.js"; @Entity() @Index(["userId", "noteId"], { unique: true }) diff --git a/packages/backend/src/models/entities/note.ts b/packages/backend/src/models/entities/note.ts index e4e57e8e..c6f06220 100644 --- a/packages/backend/src/models/entities/note.ts +++ b/packages/backend/src/models/entities/note.ts @@ -1,16 +1,16 @@ import { + Column, Entity, Index, JoinColumn, - Column, - PrimaryColumn, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; -import type { DriveFile } from "./drive-file.js"; -import { id } from "../id.js"; import { noteVisibilities } from "../../types.js"; +import { id } from "../id.js"; import { Channel } from "./channel.js"; +import type { DriveFile } from "./drive-file.js"; +import { User } from "./user.js"; @Entity() @Index("IDX_NOTE_TAGS", { synchronize: false }) diff --git a/packages/backend/src/models/entities/notification.ts b/packages/backend/src/models/entities/notification.ts index da23f7d3..ea1a0f8c 100644 --- a/packages/backend/src/models/entities/notification.ts +++ b/packages/backend/src/models/entities/notification.ts @@ -1,18 +1,18 @@ +import { notificationTypes } from "@/types.js"; import { + Column, Entity, Index, JoinColumn, ManyToOne, - Column, PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; -import { Note } from "./note.js"; -import { FollowRequest } from "./follow-request.js"; -import { UserGroupInvitation } from "./user-group-invitation.js"; import { AccessToken } from "./access-token.js"; -import { notificationTypes } from "@/types.js"; +import { FollowRequest } from "./follow-request.js"; +import { Note } from "./note.js"; +import { UserGroupInvitation } from "./user-group-invitation.js"; +import { User } from "./user.js"; @Entity() export class Notification { diff --git a/packages/backend/src/models/entities/page-like.ts b/packages/backend/src/models/entities/page-like.ts index 6304e0b2..f93221e2 100644 --- a/packages/backend/src/models/entities/page-like.ts +++ b/packages/backend/src/models/entities/page-like.ts @@ -1,14 +1,14 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; import { Page } from "./page.js"; +import { User } from "./user.js"; @Entity() @Index(["userId", "pageId"], { unique: true }) diff --git a/packages/backend/src/models/entities/page.ts b/packages/backend/src/models/entities/page.ts index d0733c8c..f80ac570 100644 --- a/packages/backend/src/models/entities/page.ts +++ b/packages/backend/src/models/entities/page.ts @@ -1,14 +1,14 @@ import { + Column, Entity, Index, JoinColumn, - Column, - PrimaryColumn, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; import { DriveFile } from "./drive-file.js"; +import { User } from "./user.js"; @Entity() @Index(["userId", "name"], { unique: true }) diff --git a/packages/backend/src/models/entities/password-reset-request.ts b/packages/backend/src/models/entities/password-reset-request.ts index ab0bccbb..48335196 100644 --- a/packages/backend/src/models/entities/password-reset-request.ts +++ b/packages/backend/src/models/entities/password-reset-request.ts @@ -1,10 +1,10 @@ import { - PrimaryColumn, + Column, Entity, Index, - Column, - ManyToOne, JoinColumn, + ManyToOne, + PrimaryColumn, } from "typeorm"; import { id } from "../id.js"; import { User } from "./user.js"; diff --git a/packages/backend/src/models/entities/poll-vote.ts b/packages/backend/src/models/entities/poll-vote.ts index d59a720c..e14734a7 100644 --- a/packages/backend/src/models/entities/poll-vote.ts +++ b/packages/backend/src/models/entities/poll-vote.ts @@ -1,14 +1,14 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; -import { Note } from "./note.js"; import { id } from "../id.js"; +import { Note } from "./note.js"; +import { User } from "./user.js"; @Entity() @Index(["userId", "noteId", "choice"], { unique: true }) diff --git a/packages/backend/src/models/entities/poll.ts b/packages/backend/src/models/entities/poll.ts index c117d4e7..ae6be599 100644 --- a/packages/backend/src/models/entities/poll.ts +++ b/packages/backend/src/models/entities/poll.ts @@ -1,15 +1,15 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, OneToOne, + PrimaryColumn, } from "typeorm"; +import { noteVisibilities } from "../../types.js"; import { id } from "../id.js"; import { Note } from "./note.js"; import type { User } from "./user.js"; -import { noteVisibilities } from "../../types.js"; @Entity() export class Poll { diff --git a/packages/backend/src/models/entities/promo-note.ts b/packages/backend/src/models/entities/promo-note.ts index caa64927..142634c2 100644 --- a/packages/backend/src/models/entities/promo-note.ts +++ b/packages/backend/src/models/entities/promo-note.ts @@ -1,14 +1,14 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, OneToOne, + PrimaryColumn, } from "typeorm"; +import { id } from "../id.js"; import { Note } from "./note.js"; import type { User } from "./user.js"; -import { id } from "../id.js"; @Entity() export class PromoNote { diff --git a/packages/backend/src/models/entities/promo-read.ts b/packages/backend/src/models/entities/promo-read.ts index b31877dc..a5a54af4 100644 --- a/packages/backend/src/models/entities/promo-read.ts +++ b/packages/backend/src/models/entities/promo-read.ts @@ -1,14 +1,14 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; +import { id } from "../id.js"; import { Note } from "./note.js"; import { User } from "./user.js"; -import { id } from "../id.js"; @Entity() @Index(["userId", "noteId"], { unique: true }) diff --git a/packages/backend/src/models/entities/registration-tickets.ts b/packages/backend/src/models/entities/registration-tickets.ts index 549f05d0..cb4547fb 100644 --- a/packages/backend/src/models/entities/registration-tickets.ts +++ b/packages/backend/src/models/entities/registration-tickets.ts @@ -1,4 +1,4 @@ -import { PrimaryColumn, Entity, Index, Column } from "typeorm"; +import { Column, Entity, Index, PrimaryColumn } from "typeorm"; import { id } from "../id.js"; @Entity() diff --git a/packages/backend/src/models/entities/registry-item.ts b/packages/backend/src/models/entities/registry-item.ts index d044222e..d2c70f7b 100644 --- a/packages/backend/src/models/entities/registry-item.ts +++ b/packages/backend/src/models/entities/registry-item.ts @@ -1,13 +1,13 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; +import { User } from "./user.js"; // TODO: 同じdomain、同じscope、同じkeyのレコードは二つ以上存在しないように制約付けたい @Entity() diff --git a/packages/backend/src/models/entities/relay.ts b/packages/backend/src/models/entities/relay.ts index c7509dcf..5b3ebef5 100644 --- a/packages/backend/src/models/entities/relay.ts +++ b/packages/backend/src/models/entities/relay.ts @@ -1,4 +1,4 @@ -import { PrimaryColumn, Entity, Index, Column } from "typeorm"; +import { Column, Entity, Index, PrimaryColumn } from "typeorm"; import { id } from "../id.js"; @Entity() diff --git a/packages/backend/src/models/entities/renote-muting.ts b/packages/backend/src/models/entities/renote-muting.ts index e8856492..793c39df 100644 --- a/packages/backend/src/models/entities/renote-muting.ts +++ b/packages/backend/src/models/entities/renote-muting.ts @@ -1,10 +1,10 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; import { id } from "../id.js"; import { User } from "./user.js"; diff --git a/packages/backend/src/models/entities/signin.ts b/packages/backend/src/models/entities/signin.ts index 517e71c8..6ecb452e 100644 --- a/packages/backend/src/models/entities/signin.ts +++ b/packages/backend/src/models/entities/signin.ts @@ -1,13 +1,13 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; +import { User } from "./user.js"; @Entity() export class Signin { diff --git a/packages/backend/src/models/entities/sw-subscription.ts b/packages/backend/src/models/entities/sw-subscription.ts index f7823fba..9e65fff5 100644 --- a/packages/backend/src/models/entities/sw-subscription.ts +++ b/packages/backend/src/models/entities/sw-subscription.ts @@ -1,13 +1,13 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; +import { User } from "./user.js"; @Entity() export class SwSubscription { diff --git a/packages/backend/src/models/entities/used-username.ts b/packages/backend/src/models/entities/used-username.ts index d00a2599..b7937f64 100644 --- a/packages/backend/src/models/entities/used-username.ts +++ b/packages/backend/src/models/entities/used-username.ts @@ -1,4 +1,4 @@ -import { PrimaryColumn, Entity, Column } from "typeorm"; +import { Column, Entity, PrimaryColumn } from "typeorm"; @Entity() export class UsedUsername { diff --git a/packages/backend/src/models/entities/user-group-invitation.ts b/packages/backend/src/models/entities/user-group-invitation.ts index fa2655ab..7af3ad61 100644 --- a/packages/backend/src/models/entities/user-group-invitation.ts +++ b/packages/backend/src/models/entities/user-group-invitation.ts @@ -1,14 +1,14 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; -import { UserGroup } from "./user-group.js"; import { id } from "../id.js"; +import { UserGroup } from "./user-group.js"; +import { User } from "./user.js"; @Entity() @Index(["userId", "userGroupId"], { unique: true }) diff --git a/packages/backend/src/models/entities/user-group-joining.ts b/packages/backend/src/models/entities/user-group-joining.ts index 78f820d0..a60d6f03 100644 --- a/packages/backend/src/models/entities/user-group-joining.ts +++ b/packages/backend/src/models/entities/user-group-joining.ts @@ -1,14 +1,14 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; -import { UserGroup } from "./user-group.js"; import { id } from "../id.js"; +import { UserGroup } from "./user-group.js"; +import { User } from "./user.js"; @Entity() @Index(["userId", "userGroupId"], { unique: true }) diff --git a/packages/backend/src/models/entities/user-group.ts b/packages/backend/src/models/entities/user-group.ts index 23876ec8..9e374858 100644 --- a/packages/backend/src/models/entities/user-group.ts +++ b/packages/backend/src/models/entities/user-group.ts @@ -1,13 +1,13 @@ import { + Column, Entity, Index, JoinColumn, - Column, - PrimaryColumn, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; +import { User } from "./user.js"; @Entity() export class UserGroup { diff --git a/packages/backend/src/models/entities/user-ip.ts b/packages/backend/src/models/entities/user-ip.ts index adef48e4..b7226c52 100644 --- a/packages/backend/src/models/entities/user-ip.ts +++ b/packages/backend/src/models/entities/user-ip.ts @@ -1,4 +1,4 @@ -import { Entity, Index, Column, PrimaryGeneratedColumn } from "typeorm"; +import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm"; import { id } from "../id.js"; import type { User } from "./user.js"; diff --git a/packages/backend/src/models/entities/user-keypair.ts b/packages/backend/src/models/entities/user-keypair.ts index f98384f5..eb0e2593 100644 --- a/packages/backend/src/models/entities/user-keypair.ts +++ b/packages/backend/src/models/entities/user-keypair.ts @@ -1,6 +1,6 @@ -import { PrimaryColumn, Entity, JoinColumn, Column, OneToOne } from "typeorm"; -import { User } from "./user.js"; +import { Column, Entity, JoinColumn, OneToOne, PrimaryColumn } from "typeorm"; import { id } from "../id.js"; +import { User } from "./user.js"; @Entity() export class UserKeypair { diff --git a/packages/backend/src/models/entities/user-list-joining.ts b/packages/backend/src/models/entities/user-list-joining.ts index 4caa71ad..a692deca 100644 --- a/packages/backend/src/models/entities/user-list-joining.ts +++ b/packages/backend/src/models/entities/user-list-joining.ts @@ -1,14 +1,14 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; -import { UserList } from "./user-list.js"; import { id } from "../id.js"; +import { UserList } from "./user-list.js"; +import { User } from "./user.js"; @Entity() @Index(["userId", "userListId"], { unique: true }) diff --git a/packages/backend/src/models/entities/user-list.ts b/packages/backend/src/models/entities/user-list.ts index 3c95d44d..add0454a 100644 --- a/packages/backend/src/models/entities/user-list.ts +++ b/packages/backend/src/models/entities/user-list.ts @@ -1,13 +1,13 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; +import { User } from "./user.js"; @Entity() export class UserList { diff --git a/packages/backend/src/models/entities/user-note-pining.ts b/packages/backend/src/models/entities/user-note-pining.ts index c30fe1e0..2417f73a 100644 --- a/packages/backend/src/models/entities/user-note-pining.ts +++ b/packages/backend/src/models/entities/user-note-pining.ts @@ -1,14 +1,14 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; +import { id } from "../id.js"; import { Note } from "./note.js"; import { User } from "./user.js"; -import { id } from "../id.js"; @Entity() @Index(["userId", "noteId"], { unique: true }) diff --git a/packages/backend/src/models/entities/user-pending.ts b/packages/backend/src/models/entities/user-pending.ts index 18ae5ad9..f36decc1 100644 --- a/packages/backend/src/models/entities/user-pending.ts +++ b/packages/backend/src/models/entities/user-pending.ts @@ -1,4 +1,4 @@ -import { PrimaryColumn, Entity, Index, Column } from "typeorm"; +import { Column, Entity, Index, PrimaryColumn } from "typeorm"; import { id } from "../id.js"; @Entity() diff --git a/packages/backend/src/models/entities/user-profile.ts b/packages/backend/src/models/entities/user-profile.ts index cb9161ce..181a9eda 100644 --- a/packages/backend/src/models/entities/user-profile.ts +++ b/packages/backend/src/models/entities/user-profile.ts @@ -1,15 +1,15 @@ +import { ffVisibility, notificationTypes } from "@/types.js"; import { - Entity, Column, + Entity, Index, - OneToOne, JoinColumn, + OneToOne, PrimaryColumn, } from "typeorm"; -import { ffVisibility, notificationTypes } from "@/types.js"; import { id } from "../id.js"; -import { User } from "./user.js"; import { Page } from "./page.js"; +import { User } from "./user.js"; // TODO: このテーブルで管理している情報すべてレジストリで管理するようにしても良いかも // ただ、「emailVerified が true なユーザーを find する」のようなクエリは書けなくなるからウーン diff --git a/packages/backend/src/models/entities/user-publickey.ts b/packages/backend/src/models/entities/user-publickey.ts index e39b084d..ea13e049 100644 --- a/packages/backend/src/models/entities/user-publickey.ts +++ b/packages/backend/src/models/entities/user-publickey.ts @@ -1,13 +1,13 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, OneToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; +import { User } from "./user.js"; @Entity() export class UserPublickey { diff --git a/packages/backend/src/models/entities/user-security-key.ts b/packages/backend/src/models/entities/user-security-key.ts index 511cab4a..ae721d7e 100644 --- a/packages/backend/src/models/entities/user-security-key.ts +++ b/packages/backend/src/models/entities/user-security-key.ts @@ -1,13 +1,13 @@ import { - PrimaryColumn, - Entity, - JoinColumn, Column, - ManyToOne, + Entity, Index, + JoinColumn, + ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; +import { User } from "./user.js"; @Entity() export class UserSecurityKey { diff --git a/packages/backend/src/models/entities/user.ts b/packages/backend/src/models/entities/user.ts index 6d730071..37d61b31 100644 --- a/packages/backend/src/models/entities/user.ts +++ b/packages/backend/src/models/entities/user.ts @@ -1,9 +1,9 @@ import { - Entity, Column, + Entity, Index, - OneToOne, JoinColumn, + OneToOne, PrimaryColumn, } from "typeorm"; import { id } from "../id.js"; diff --git a/packages/backend/src/models/entities/webhook.ts b/packages/backend/src/models/entities/webhook.ts index 47fd7996..fa8b6145 100644 --- a/packages/backend/src/models/entities/webhook.ts +++ b/packages/backend/src/models/entities/webhook.ts @@ -1,13 +1,13 @@ import { - PrimaryColumn, + Column, Entity, Index, JoinColumn, - Column, ManyToOne, + PrimaryColumn, } from "typeorm"; -import { User } from "./user.js"; import { id } from "../id.js"; +import { User } from "./user.js"; export const webhookEventTypes = [ "mention", diff --git a/packages/backend/src/models/index.ts b/packages/backend/src/models/index.ts index c1f37cf6..f842f024 100644 --- a/packages/backend/src/models/index.ts +++ b/packages/backend/src/models/index.ts @@ -1,70 +1,70 @@ import { db } from "@/db/postgre.js"; -import { Announcement } from "./entities/announcement.js"; -import { AnnouncementRead } from "./entities/announcement-read.js"; -import { Poll } from "./entities/poll.js"; -import { PollVote } from "./entities/poll-vote.js"; -import { Meta } from "./entities/meta.js"; -import { SwSubscription } from "./entities/sw-subscription.js"; -import { NoteWatching } from "./entities/note-watching.js"; -import { NoteThreadMuting } from "./entities/note-thread-muting.js"; -import { NoteUnread } from "./entities/note-unread.js"; -import { RegistrationTicket } from "./entities/registration-tickets.js"; -import { UserRepository } from "./repositories/user.js"; -import { NoteRepository } from "./repositories/note.js"; -import { DriveFileRepository } from "./repositories/drive-file.js"; -import { DriveFolderRepository } from "./repositories/drive-folder.js"; import { AccessToken } from "./entities/access-token.js"; -import { UserNotePining } from "./entities/user-note-pining.js"; -import { SigninRepository } from "./repositories/signin.js"; -import { MessagingMessageRepository } from "./repositories/messaging-message.js"; -import { UserListRepository } from "./repositories/user-list.js"; -import { UserListJoining } from "./entities/user-list-joining.js"; -import { UserGroupRepository } from "./repositories/user-group.js"; -import { UserGroupJoining } from "./entities/user-group-joining.js"; -import { UserGroupInvitationRepository } from "./repositories/user-group-invitation.js"; -import { FollowRequestRepository } from "./repositories/follow-request.js"; -import { MutingRepository } from "./repositories/muting.js"; -import { RenoteMutingRepository } from "./repositories/renote-muting.js"; -import { BlockingRepository } from "./repositories/blocking.js"; -import { NoteReactionRepository } from "./repositories/note-reaction.js"; -import { NotificationRepository } from "./repositories/notification.js"; -import { NoteFavoriteRepository } from "./repositories/note-favorite.js"; -import { UserPublickey } from "./entities/user-publickey.js"; -import { UserKeypair } from "./entities/user-keypair.js"; -import { AppRepository } from "./repositories/app.js"; -import { FollowingRepository } from "./repositories/following.js"; -import { AbuseUserReportRepository } from "./repositories/abuse-user-report.js"; -import { AuthSessionRepository } from "./repositories/auth-session.js"; -import { UserProfile } from "./entities/user-profile.js"; +import { Ad } from "./entities/ad.js"; +import { AnnouncementRead } from "./entities/announcement-read.js"; +import { Announcement } from "./entities/announcement.js"; import { AttestationChallenge } from "./entities/attestation-challenge.js"; -import { UserSecurityKey } from "./entities/user-security-key.js"; -import { HashtagRepository } from "./repositories/hashtag.js"; -import { PageRepository } from "./repositories/page.js"; -import { PageLikeRepository } from "./repositories/page-like.js"; -import { GalleryPostRepository } from "./repositories/gallery-post.js"; -import { GalleryLikeRepository } from "./repositories/gallery-like.js"; -import { ModerationLogRepository } from "./repositories/moderation-logs.js"; -import { UsedUsername } from "./entities/used-username.js"; -import { ClipRepository } from "./repositories/clip.js"; -import { ClipNote } from "./entities/clip-note.js"; -import { AntennaRepository } from "./repositories/antenna.js"; -import { PromoNote } from "./entities/promo-note.js"; -import { PromoRead } from "./entities/promo-read.js"; -import { EmojiRepository } from "./repositories/emoji.js"; -import { RelayRepository } from "./repositories/relay.js"; -import { ChannelRepository } from "./repositories/channel.js"; -import { MutedNote } from "./entities/muted-note.js"; import { ChannelFollowing } from "./entities/channel-following.js"; import { ChannelNotePining } from "./entities/channel-note-pining.js"; -import { RegistryItem } from "./entities/registry-item.js"; -import { Ad } from "./entities/ad.js"; -import { PasswordResetRequest } from "./entities/password-reset-request.js"; -import { UserPending } from "./entities/user-pending.js"; -import { InstanceRepository } from "./repositories/instance.js"; -import { Webhook } from "./entities/webhook.js"; -import { UserIp } from "./entities/user-ip.js"; +import { ClipNote } from "./entities/clip-note.js"; +import { Meta } from "./entities/meta.js"; +import { MutedNote } from "./entities/muted-note.js"; import { NoteEdit } from "./entities/note-edit.js"; +import { NoteThreadMuting } from "./entities/note-thread-muting.js"; +import { NoteUnread } from "./entities/note-unread.js"; +import { NoteWatching } from "./entities/note-watching.js"; +import { PasswordResetRequest } from "./entities/password-reset-request.js"; +import { PollVote } from "./entities/poll-vote.js"; +import { Poll } from "./entities/poll.js"; +import { PromoNote } from "./entities/promo-note.js"; +import { PromoRead } from "./entities/promo-read.js"; +import { RegistrationTicket } from "./entities/registration-tickets.js"; +import { RegistryItem } from "./entities/registry-item.js"; +import { SwSubscription } from "./entities/sw-subscription.js"; +import { UsedUsername } from "./entities/used-username.js"; +import { UserGroupJoining } from "./entities/user-group-joining.js"; +import { UserIp } from "./entities/user-ip.js"; +import { UserKeypair } from "./entities/user-keypair.js"; +import { UserListJoining } from "./entities/user-list-joining.js"; +import { UserNotePining } from "./entities/user-note-pining.js"; +import { UserPending } from "./entities/user-pending.js"; +import { UserProfile } from "./entities/user-profile.js"; +import { UserPublickey } from "./entities/user-publickey.js"; +import { UserSecurityKey } from "./entities/user-security-key.js"; +import { Webhook } from "./entities/webhook.js"; +import { AbuseUserReportRepository } from "./repositories/abuse-user-report.js"; +import { AntennaRepository } from "./repositories/antenna.js"; +import { AppRepository } from "./repositories/app.js"; +import { AuthSessionRepository } from "./repositories/auth-session.js"; +import { BlockingRepository } from "./repositories/blocking.js"; +import { ChannelRepository } from "./repositories/channel.js"; +import { ClipRepository } from "./repositories/clip.js"; +import { DriveFileRepository } from "./repositories/drive-file.js"; +import { DriveFolderRepository } from "./repositories/drive-folder.js"; +import { EmojiRepository } from "./repositories/emoji.js"; +import { FollowRequestRepository } from "./repositories/follow-request.js"; +import { FollowingRepository } from "./repositories/following.js"; +import { GalleryLikeRepository } from "./repositories/gallery-like.js"; +import { GalleryPostRepository } from "./repositories/gallery-post.js"; +import { HashtagRepository } from "./repositories/hashtag.js"; +import { InstanceRepository } from "./repositories/instance.js"; +import { MessagingMessageRepository } from "./repositories/messaging-message.js"; +import { ModerationLogRepository } from "./repositories/moderation-logs.js"; +import { MutingRepository } from "./repositories/muting.js"; +import { NoteFavoriteRepository } from "./repositories/note-favorite.js"; +import { NoteReactionRepository } from "./repositories/note-reaction.js"; +import { NoteRepository } from "./repositories/note.js"; +import { NotificationRepository } from "./repositories/notification.js"; +import { PageLikeRepository } from "./repositories/page-like.js"; +import { PageRepository } from "./repositories/page.js"; +import { RelayRepository } from "./repositories/relay.js"; +import { RenoteMutingRepository } from "./repositories/renote-muting.js"; +import { SigninRepository } from "./repositories/signin.js"; +import { UserGroupInvitationRepository } from "./repositories/user-group-invitation.js"; +import { UserGroupRepository } from "./repositories/user-group.js"; +import { UserListRepository } from "./repositories/user-list.js"; +import { UserRepository } from "./repositories/user.js"; export const Announcements = db.getRepository(Announcement); export const AnnouncementReads = db.getRepository(AnnouncementRead); diff --git a/packages/backend/src/models/repositories/abuse-user-report.ts b/packages/backend/src/models/repositories/abuse-user-report.ts index 07afef48..071c399a 100644 --- a/packages/backend/src/models/repositories/abuse-user-report.ts +++ b/packages/backend/src/models/repositories/abuse-user-report.ts @@ -1,7 +1,7 @@ import { db } from "@/db/postgre.js"; -import { Users } from "../index.js"; import { AbuseUserReport } from "@/models/entities/abuse-user-report.js"; import { awaitAll } from "@/prelude/await-all.js"; +import { Users } from "../index.js"; export const AbuseUserReportRepository = db .getRepository(AbuseUserReport) diff --git a/packages/backend/src/models/repositories/app.ts b/packages/backend/src/models/repositories/app.ts index af3dfb81..abad561f 100644 --- a/packages/backend/src/models/repositories/app.ts +++ b/packages/backend/src/models/repositories/app.ts @@ -1,8 +1,8 @@ import { db } from "@/db/postgre.js"; -import { App } from "@/models/entities/app.js"; -import { AccessTokens } from "../index.js"; import type { Packed } from "@/misc/schema.js"; +import { App } from "@/models/entities/app.js"; import type { User } from "../entities/user.js"; +import { AccessTokens } from "../index.js"; export const AppRepository = db.getRepository(App).extend({ async pack( diff --git a/packages/backend/src/models/repositories/auth-session.ts b/packages/backend/src/models/repositories/auth-session.ts index d3e1d45d..c129f734 100644 --- a/packages/backend/src/models/repositories/auth-session.ts +++ b/packages/backend/src/models/repositories/auth-session.ts @@ -1,8 +1,8 @@ import { db } from "@/db/postgre.js"; -import { Apps } from "../index.js"; import { AuthSession } from "@/models/entities/auth-session.js"; -import { awaitAll } from "@/prelude/await-all.js"; import type { User } from "@/models/entities/user.js"; +import { awaitAll } from "@/prelude/await-all.js"; +import { Apps } from "../index.js"; export const AuthSessionRepository = db.getRepository(AuthSession).extend({ async pack( diff --git a/packages/backend/src/models/repositories/blocking.ts b/packages/backend/src/models/repositories/blocking.ts index 3dfa74e7..280631e7 100644 --- a/packages/backend/src/models/repositories/blocking.ts +++ b/packages/backend/src/models/repositories/blocking.ts @@ -1,9 +1,9 @@ import { db } from "@/db/postgre.js"; -import { Users } from "../index.js"; -import { Blocking } from "@/models/entities/blocking.js"; -import { awaitAll } from "@/prelude/await-all.js"; import type { Packed } from "@/misc/schema.js"; +import { Blocking } from "@/models/entities/blocking.js"; import type { User } from "@/models/entities/user.js"; +import { awaitAll } from "@/prelude/await-all.js"; +import { Users } from "../index.js"; export const BlockingRepository = db.getRepository(Blocking).extend({ async pack( diff --git a/packages/backend/src/models/repositories/channel.ts b/packages/backend/src/models/repositories/channel.ts index 7800a659..9012c5e6 100644 --- a/packages/backend/src/models/repositories/channel.ts +++ b/packages/backend/src/models/repositories/channel.ts @@ -1,8 +1,8 @@ import { db } from "@/db/postgre.js"; -import { Channel } from "@/models/entities/channel.js"; import type { Packed } from "@/misc/schema.js"; -import { DriveFiles, ChannelFollowings, NoteUnreads } from "../index.js"; +import { Channel } from "@/models/entities/channel.js"; import type { User } from "@/models/entities/user.js"; +import { ChannelFollowings, DriveFiles, NoteUnreads } from "../index.js"; export const ChannelRepository = db.getRepository(Channel).extend({ async pack( diff --git a/packages/backend/src/models/repositories/clip.ts b/packages/backend/src/models/repositories/clip.ts index 0c21691b..87c796ae 100644 --- a/packages/backend/src/models/repositories/clip.ts +++ b/packages/backend/src/models/repositories/clip.ts @@ -1,8 +1,8 @@ import { db } from "@/db/postgre.js"; -import { Clip } from "@/models/entities/clip.js"; import type { Packed } from "@/misc/schema.js"; -import { Users } from "../index.js"; +import { Clip } from "@/models/entities/clip.js"; import { awaitAll } from "@/prelude/await-all.js"; +import { Users } from "../index.js"; export const ClipRepository = db.getRepository(Clip).extend({ async pack(src: Clip["id"] | Clip): Promise> { diff --git a/packages/backend/src/models/repositories/drive-file.ts b/packages/backend/src/models/repositories/drive-file.ts index 1b4f477d..2de8d7fa 100644 --- a/packages/backend/src/models/repositories/drive-file.ts +++ b/packages/backend/src/models/repositories/drive-file.ts @@ -1,13 +1,13 @@ +import config from "@/config/index.js"; import { db } from "@/db/postgre.js"; +import { deepClone } from "@/misc/clone.js"; +import { toPuny } from "@/misc/convert-host.js"; +import type { Packed } from "@/misc/schema.js"; import { DriveFile } from "@/models/entities/drive-file.js"; import type { User } from "@/models/entities/user.js"; -import { toPuny } from "@/misc/convert-host.js"; import { awaitAll } from "@/prelude/await-all.js"; -import type { Packed } from "@/misc/schema.js"; -import config from "@/config/index.js"; -import { query, appendQuery } from "@/prelude/url.js"; -import { Users, DriveFolders } from "../index.js"; -import { deepClone } from "@/misc/clone.js"; +import { appendQuery, query } from "@/prelude/url.js"; +import { DriveFolders, Users } from "../index.js"; type PackOptions = { detail?: boolean; diff --git a/packages/backend/src/models/repositories/drive-folder.ts b/packages/backend/src/models/repositories/drive-folder.ts index 9823561d..7c73d261 100644 --- a/packages/backend/src/models/repositories/drive-folder.ts +++ b/packages/backend/src/models/repositories/drive-folder.ts @@ -1,8 +1,8 @@ import { db } from "@/db/postgre.js"; -import { DriveFolders, DriveFiles } from "../index.js"; +import type { Packed } from "@/misc/schema.js"; import { DriveFolder } from "@/models/entities/drive-folder.js"; import { awaitAll } from "@/prelude/await-all.js"; -import type { Packed } from "@/misc/schema.js"; +import { DriveFiles, DriveFolders } from "../index.js"; export const DriveFolderRepository = db.getRepository(DriveFolder).extend({ async pack( diff --git a/packages/backend/src/models/repositories/emoji.ts b/packages/backend/src/models/repositories/emoji.ts index e9a940f9..0589097a 100644 --- a/packages/backend/src/models/repositories/emoji.ts +++ b/packages/backend/src/models/repositories/emoji.ts @@ -1,6 +1,6 @@ import { db } from "@/db/postgre.js"; -import { Emoji } from "@/models/entities/emoji.js"; import type { Packed } from "@/misc/schema.js"; +import { Emoji } from "@/models/entities/emoji.js"; export const EmojiRepository = db.getRepository(Emoji).extend({ async pack(src: Emoji["id"] | Emoji): Promise> { diff --git a/packages/backend/src/models/repositories/follow-request.ts b/packages/backend/src/models/repositories/follow-request.ts index cef6ea72..17100c15 100644 --- a/packages/backend/src/models/repositories/follow-request.ts +++ b/packages/backend/src/models/repositories/follow-request.ts @@ -1,7 +1,7 @@ import { db } from "@/db/postgre.js"; import { FollowRequest } from "@/models/entities/follow-request.js"; -import { Users } from "../index.js"; import type { User } from "@/models/entities/user.js"; +import { Users } from "../index.js"; export const FollowRequestRepository = db.getRepository(FollowRequest).extend({ async pack( diff --git a/packages/backend/src/models/repositories/following.ts b/packages/backend/src/models/repositories/following.ts index b102365e..12e5380c 100644 --- a/packages/backend/src/models/repositories/following.ts +++ b/packages/backend/src/models/repositories/following.ts @@ -1,9 +1,9 @@ import { db } from "@/db/postgre.js"; -import { Users } from "../index.js"; -import { Following } from "@/models/entities/following.js"; -import { awaitAll } from "@/prelude/await-all.js"; import type { Packed } from "@/misc/schema.js"; +import { Following } from "@/models/entities/following.js"; import type { User } from "@/models/entities/user.js"; +import { awaitAll } from "@/prelude/await-all.js"; +import { Users } from "../index.js"; type LocalFollowerFollowing = Following & { followerHost: null; diff --git a/packages/backend/src/models/repositories/gallery-post.ts b/packages/backend/src/models/repositories/gallery-post.ts index b4206b0b..3d91d47c 100644 --- a/packages/backend/src/models/repositories/gallery-post.ts +++ b/packages/backend/src/models/repositories/gallery-post.ts @@ -1,9 +1,9 @@ import { db } from "@/db/postgre.js"; -import { GalleryPost } from "@/models/entities/gallery-post.js"; import type { Packed } from "@/misc/schema.js"; -import { Users, DriveFiles, GalleryLikes } from "../index.js"; -import { awaitAll } from "@/prelude/await-all.js"; +import { GalleryPost } from "@/models/entities/gallery-post.js"; import type { User } from "@/models/entities/user.js"; +import { awaitAll } from "@/prelude/await-all.js"; +import { DriveFiles, GalleryLikes, Users } from "../index.js"; export const GalleryPostRepository = db.getRepository(GalleryPost).extend({ async pack( diff --git a/packages/backend/src/models/repositories/hashtag.ts b/packages/backend/src/models/repositories/hashtag.ts index 7bd76c1c..e3b90c15 100644 --- a/packages/backend/src/models/repositories/hashtag.ts +++ b/packages/backend/src/models/repositories/hashtag.ts @@ -1,6 +1,6 @@ import { db } from "@/db/postgre.js"; -import { Hashtag } from "@/models/entities/hashtag.js"; import type { Packed } from "@/misc/schema.js"; +import { Hashtag } from "@/models/entities/hashtag.js"; export const HashtagRepository = db.getRepository(Hashtag).extend({ async pack(src: Hashtag): Promise> { diff --git a/packages/backend/src/models/repositories/instance.ts b/packages/backend/src/models/repositories/instance.ts index 667ec948..f2cce2ac 100644 --- a/packages/backend/src/models/repositories/instance.ts +++ b/packages/backend/src/models/repositories/instance.ts @@ -1,10 +1,10 @@ import { db } from "@/db/postgre.js"; -import { Instance } from "@/models/entities/instance.js"; import type { Packed } from "@/misc/schema.js"; import { shouldBlockInstance, shouldSilenceInstance, } from "@/misc/should-block-instance.js"; +import { Instance } from "@/models/entities/instance.js"; export const InstanceRepository = db.getRepository(Instance).extend({ async pack(instance: Instance): Promise> { diff --git a/packages/backend/src/models/repositories/messaging-message.ts b/packages/backend/src/models/repositories/messaging-message.ts index 6c0987bf..85d2053a 100644 --- a/packages/backend/src/models/repositories/messaging-message.ts +++ b/packages/backend/src/models/repositories/messaging-message.ts @@ -1,8 +1,8 @@ import { db } from "@/db/postgre.js"; -import { MessagingMessage } from "@/models/entities/messaging-message.js"; -import { Users, DriveFiles, UserGroups } from "../index.js"; import type { Packed } from "@/misc/schema.js"; +import { MessagingMessage } from "@/models/entities/messaging-message.js"; import type { User } from "@/models/entities/user.js"; +import { DriveFiles, UserGroups, Users } from "../index.js"; export const MessagingMessageRepository = db .getRepository(MessagingMessage) diff --git a/packages/backend/src/models/repositories/moderation-logs.ts b/packages/backend/src/models/repositories/moderation-logs.ts index 3858b950..03f91c6f 100644 --- a/packages/backend/src/models/repositories/moderation-logs.ts +++ b/packages/backend/src/models/repositories/moderation-logs.ts @@ -1,7 +1,7 @@ import { db } from "@/db/postgre.js"; -import { Users } from "../index.js"; import { ModerationLog } from "@/models/entities/moderation-log.js"; import { awaitAll } from "@/prelude/await-all.js"; +import { Users } from "../index.js"; export const ModerationLogRepository = db.getRepository(ModerationLog).extend({ async pack(src: ModerationLog["id"] | ModerationLog) { diff --git a/packages/backend/src/models/repositories/muting.ts b/packages/backend/src/models/repositories/muting.ts index 4d0201d5..29686c33 100644 --- a/packages/backend/src/models/repositories/muting.ts +++ b/packages/backend/src/models/repositories/muting.ts @@ -1,9 +1,9 @@ import { db } from "@/db/postgre.js"; -import { Users } from "../index.js"; -import { Muting } from "@/models/entities/muting.js"; -import { awaitAll } from "@/prelude/await-all.js"; import type { Packed } from "@/misc/schema.js"; +import { Muting } from "@/models/entities/muting.js"; import type { User } from "@/models/entities/user.js"; +import { awaitAll } from "@/prelude/await-all.js"; +import { Users } from "../index.js"; export const MutingRepository = db.getRepository(Muting).extend({ async pack( diff --git a/packages/backend/src/models/repositories/note-favorite.ts b/packages/backend/src/models/repositories/note-favorite.ts index ba43e3c3..a472fb93 100644 --- a/packages/backend/src/models/repositories/note-favorite.ts +++ b/packages/backend/src/models/repositories/note-favorite.ts @@ -1,7 +1,7 @@ import { db } from "@/db/postgre.js"; import { NoteFavorite } from "@/models/entities/note-favorite.js"; -import { Notes } from "../index.js"; import type { User } from "@/models/entities/user.js"; +import { Notes } from "../index.js"; export const NoteFavoriteRepository = db.getRepository(NoteFavorite).extend({ async pack( diff --git a/packages/backend/src/models/repositories/note-reaction.ts b/packages/backend/src/models/repositories/note-reaction.ts index 4075c7d4..4c182b24 100644 --- a/packages/backend/src/models/repositories/note-reaction.ts +++ b/packages/backend/src/models/repositories/note-reaction.ts @@ -1,9 +1,9 @@ import { db } from "@/db/postgre.js"; -import { NoteReaction } from "@/models/entities/note-reaction.js"; -import { Notes, Users } from "../index.js"; -import type { Packed } from "@/misc/schema.js"; import { decodeReaction } from "@/misc/reaction-lib.js"; +import type { Packed } from "@/misc/schema.js"; +import { NoteReaction } from "@/models/entities/note-reaction.js"; import type { User } from "@/models/entities/user.js"; +import { Notes, Users } from "../index.js"; export const NoteReactionRepository = db.getRepository(NoteReaction).extend({ async pack( diff --git a/packages/backend/src/models/repositories/note.ts b/packages/backend/src/models/repositories/note.ts index 60e5a8d5..e946c30e 100644 --- a/packages/backend/src/models/repositories/note.ts +++ b/packages/backend/src/models/repositories/note.ts @@ -1,28 +1,28 @@ -import { In } from "typeorm"; -import * as mfm from "mfm-js"; -import { Note } from "@/models/entities/note.js"; -import type { User } from "@/models/entities/user.js"; -import { - Users, - PollVotes, - DriveFiles, - NoteReactions, - Followings, - Polls, - Channels, -} from "../index.js"; -import type { Packed } from "@/misc/schema.js"; +import { db } from "@/db/postgre.js"; +import { IdentifiableError } from "@/misc/identifiable-error.js"; import { nyaize } from "@/misc/nyaize.js"; -import { awaitAll } from "@/prelude/await-all.js"; -import { convertReactions, decodeReaction } from "@/misc/reaction-lib.js"; -import type { NoteReaction } from "@/models/entities/note-reaction.js"; import { aggregateNoteEmojis, populateEmojis, prefetchEmojis, } from "@/misc/populate-emojis.js"; -import { db } from "@/db/postgre.js"; -import { IdentifiableError } from "@/misc/identifiable-error.js"; +import { convertReactions, decodeReaction } from "@/misc/reaction-lib.js"; +import type { Packed } from "@/misc/schema.js"; +import type { NoteReaction } from "@/models/entities/note-reaction.js"; +import { Note } from "@/models/entities/note.js"; +import type { User } from "@/models/entities/user.js"; +import { awaitAll } from "@/prelude/await-all.js"; +import * as mfm from "mfm-js"; +import { In } from "typeorm"; +import { + Channels, + DriveFiles, + Followings, + NoteReactions, + PollVotes, + Polls, + Users, +} from "../index.js"; export async function populatePoll(note: Note, meId: User["id"] | null) { const poll = await Polls.findOneByOrFail({ noteId: note.id }); diff --git a/packages/backend/src/models/repositories/notification.ts b/packages/backend/src/models/repositories/notification.ts index 90dfbd73..9dd49342 100644 --- a/packages/backend/src/models/repositories/notification.ts +++ b/packages/backend/src/models/repositories/notification.ts @@ -1,18 +1,18 @@ -import { In } from "typeorm"; -import { Notification } from "@/models/entities/notification.js"; -import { awaitAll } from "@/prelude/await-all.js"; -import type { Packed } from "@/misc/schema.js"; -import type { Note } from "@/models/entities/note.js"; -import type { NoteReaction } from "@/models/entities/note-reaction.js"; -import type { User } from "@/models/entities/user.js"; -import { aggregateNoteEmojis, prefetchEmojis } from "@/misc/populate-emojis.js"; import { db } from "@/db/postgre.js"; +import { aggregateNoteEmojis, prefetchEmojis } from "@/misc/populate-emojis.js"; +import type { Packed } from "@/misc/schema.js"; +import type { NoteReaction } from "@/models/entities/note-reaction.js"; +import type { Note } from "@/models/entities/note.js"; +import { Notification } from "@/models/entities/notification.js"; +import type { User } from "@/models/entities/user.js"; +import { awaitAll } from "@/prelude/await-all.js"; +import { In } from "typeorm"; import { - Users, - Notes, - UserGroupInvitations, AccessTokens, NoteReactions, + Notes, + UserGroupInvitations, + Users, } from "../index.js"; export const NotificationRepository = db.getRepository(Notification).extend({ diff --git a/packages/backend/src/models/repositories/page.ts b/packages/backend/src/models/repositories/page.ts index d9241c36..0f335164 100644 --- a/packages/backend/src/models/repositories/page.ts +++ b/packages/backend/src/models/repositories/page.ts @@ -1,10 +1,10 @@ import { db } from "@/db/postgre.js"; -import { Page } from "@/models/entities/page.js"; import type { Packed } from "@/misc/schema.js"; -import { awaitAll } from "@/prelude/await-all.js"; import type { DriveFile } from "@/models/entities/drive-file.js"; +import { Page } from "@/models/entities/page.js"; import type { User } from "@/models/entities/user.js"; -import { Users, DriveFiles, PageLikes } from "../index.js"; +import { awaitAll } from "@/prelude/await-all.js"; +import { DriveFiles, PageLikes, Users } from "../index.js"; export const PageRepository = db.getRepository(Page).extend({ async pack( diff --git a/packages/backend/src/models/repositories/user-group.ts b/packages/backend/src/models/repositories/user-group.ts index daec9449..6a70f83d 100644 --- a/packages/backend/src/models/repositories/user-group.ts +++ b/packages/backend/src/models/repositories/user-group.ts @@ -1,7 +1,7 @@ import { db } from "@/db/postgre.js"; +import type { Packed } from "@/misc/schema.js"; import { UserGroup } from "@/models/entities/user-group.js"; import { UserGroupJoinings } from "../index.js"; -import type { Packed } from "@/misc/schema.js"; export const UserGroupRepository = db.getRepository(UserGroup).extend({ async pack(src: UserGroup["id"] | UserGroup): Promise> { diff --git a/packages/backend/src/models/repositories/user-list.ts b/packages/backend/src/models/repositories/user-list.ts index e3abeac3..33133a05 100644 --- a/packages/backend/src/models/repositories/user-list.ts +++ b/packages/backend/src/models/repositories/user-list.ts @@ -1,7 +1,7 @@ import { db } from "@/db/postgre.js"; +import type { Packed } from "@/misc/schema.js"; import { UserList } from "@/models/entities/user-list.js"; import { UserListJoinings } from "../index.js"; -import type { Packed } from "@/misc/schema.js"; export const UserListRepository = db.getRepository(UserList).extend({ async pack(src: UserList["id"] | UserList): Promise> { diff --git a/packages/backend/src/models/repositories/user.ts b/packages/backend/src/models/repositories/user.ts index 6b74dd66..f310b0dc 100644 --- a/packages/backend/src/models/repositories/user.ts +++ b/packages/backend/src/models/repositories/user.ts @@ -1,41 +1,41 @@ -import { In, Not } from "typeorm"; -import Ajv from "ajv"; +import config from "@/config/index.js"; +import { USER_ACTIVE_THRESHOLD, USER_ONLINE_THRESHOLD } from "@/const.js"; +import { db } from "@/db/postgre.js"; +import { Cache } from "@/misc/cache.js"; +import { populateEmojis } from "@/misc/populate-emojis.js"; +import type { Packed } from "@/misc/schema.js"; import type { ILocalUser, IRemoteUser } from "@/models/entities/user.js"; import { User } from "@/models/entities/user.js"; -import config from "@/config/index.js"; -import type { Packed } from "@/misc/schema.js"; import type { Promiseable } from "@/prelude/await-all.js"; import { awaitAll } from "@/prelude/await-all.js"; -import { populateEmojis } from "@/misc/populate-emojis.js"; -import { USER_ACTIVE_THRESHOLD, USER_ONLINE_THRESHOLD } from "@/const.js"; -import { Cache } from "@/misc/cache.js"; -import { db } from "@/db/postgre.js"; -import { isActor, getApId } from "@/remote/activitypub/type.js"; import DbResolver from "@/remote/activitypub/db-resolver.js"; -import Resolver from "@/remote/activitypub/resolver.js"; import { createPerson } from "@/remote/activitypub/models/person.js"; +import Resolver from "@/remote/activitypub/resolver.js"; +import { getApId, isActor } from "@/remote/activitypub/type.js"; +import Ajv from "ajv"; +import { In, Not } from "typeorm"; +import type { Instance } from "../entities/instance.js"; import { AnnouncementReads, Announcements, Blockings, ChannelFollowings, DriveFiles, - Followings, FollowRequests, + Followings, Instances, MessagingMessages, Mutings, - RenoteMutings, - Notes, NoteUnreads, + Notes, Notifications, Pages, + RenoteMutings, UserGroupJoinings, UserNotePinings, UserProfiles, UserSecurityKeys, } from "../index.js"; -import type { Instance } from "../entities/instance.js"; const userInstanceCache = new Cache( "userInstance", @@ -483,7 +483,7 @@ export const UserRepository = db.getRepository(User).extend({ ...(opts.detail ? { - url: profile!.url, + url: profile?.url, uri: user.uri, movedToUri: user.movedToUri ? await this.userFromURI(user.movedToUri) @@ -501,11 +501,11 @@ export const UserRepository = db.getRepository(User).extend({ bannerColor: null, // 後方互換性のため isSilenced: user.isSilenced || falsy, isSuspended: user.isSuspended || falsy, - description: profile!.description, - location: profile!.location, - birthday: profile!.birthday, - lang: profile!.lang, - fields: profile!.fields, + description: profile?.description, + location: profile?.location, + birthday: profile?.birthday, + lang: profile?.lang, + fields: profile?.fields, followersCount: followersCount || 0, followingCount: followingCount || 0, notesCount: user.notesCount, @@ -517,15 +517,15 @@ export const UserRepository = db.getRepository(User).extend({ detail: true, }, ), - pinnedPageId: profile!.pinnedPageId, - pinnedPage: profile!.pinnedPageId - ? Pages.pack(profile!.pinnedPageId, me) + pinnedPageId: profile?.pinnedPageId, + pinnedPage: profile?.pinnedPageId + ? Pages.pack(profile?.pinnedPageId, me) : null, - publicReactions: profile!.publicReactions, - ffVisibility: profile!.ffVisibility, - twoFactorEnabled: profile!.twoFactorEnabled, - usePasswordLessLogin: profile!.usePasswordLessLogin, - securityKeys: profile!.twoFactorEnabled + publicReactions: profile?.publicReactions, + ffVisibility: profile?.ffVisibility, + twoFactorEnabled: profile?.twoFactorEnabled, + usePasswordLessLogin: profile?.usePasswordLessLogin, + securityKeys: profile?.twoFactorEnabled ? UserSecurityKeys.countBy({ userId: user.id, }).then((result) => result >= 1) @@ -537,14 +537,14 @@ export const UserRepository = db.getRepository(User).extend({ ? { avatarId: user.avatarId, bannerId: user.bannerId, - injectFeaturedNote: profile!.injectFeaturedNote, - receiveAnnouncementEmail: profile!.receiveAnnouncementEmail, - alwaysMarkNsfw: profile!.alwaysMarkNsfw, - autoSensitive: profile!.autoSensitive, - carefulBot: profile!.carefulBot, - autoAcceptFollowed: profile!.autoAcceptFollowed, - noCrawle: profile!.noCrawle, - preventAiLearning: profile!.preventAiLearning, + injectFeaturedNote: profile?.injectFeaturedNote, + receiveAnnouncementEmail: profile?.receiveAnnouncementEmail, + alwaysMarkNsfw: profile?.alwaysMarkNsfw, + autoSensitive: profile?.autoSensitive, + carefulBot: profile?.carefulBot, + autoAcceptFollowed: profile?.autoAcceptFollowed, + noCrawle: profile?.noCrawle, + preventAiLearning: profile?.preventAiLearning, isExplorable: user.isExplorable, isDeleted: user.isDeleted, hideOnlineStatus: user.hideOnlineStatus, @@ -565,18 +565,18 @@ export const UserRepository = db.getRepository(User).extend({ hasUnreadNotification: this.getHasUnreadNotification(user.id), hasPendingReceivedFollowRequest: this.getHasPendingReceivedFollowRequest(user.id), - mutedWords: profile!.mutedWords, - mutedInstances: profile!.mutedInstances, - mutingNotificationTypes: profile!.mutingNotificationTypes, - emailNotificationTypes: profile!.emailNotificationTypes, + mutedWords: profile?.mutedWords, + mutedInstances: profile?.mutedInstances, + mutingNotificationTypes: profile?.mutingNotificationTypes, + emailNotificationTypes: profile?.emailNotificationTypes, } : {}), ...(opts.includeSecrets ? { - email: profile!.email, - emailVerified: profile!.emailVerified, - securityKeysList: profile!.twoFactorEnabled + email: profile?.email, + emailVerified: profile?.emailVerified, + securityKeysList: profile?.twoFactorEnabled ? UserSecurityKeys.find({ where: { userId: user.id, diff --git a/packages/backend/src/queue/index.ts b/packages/backend/src/queue/index.ts index f9ca155f..f2482c2b 100644 --- a/packages/backend/src/queue/index.ts +++ b/packages/backend/src/queue/index.ts @@ -3,32 +3,32 @@ import { v4 as uuid } from "uuid"; import config from "@/config/index.js"; import type { DriveFile } from "@/models/entities/drive-file.js"; -import type { IActivity } from "@/remote/activitypub/type.js"; import type { Webhook, webhookEventTypes } from "@/models/entities/webhook.js"; +import type { IActivity } from "@/remote/activitypub/type.js"; import { envOption } from "../env.js"; -import processDeliver from "./processors/deliver.js"; -import processInbox from "./processors/inbox.js"; +import { Note } from "@/models/entities/note.js"; +import { getJobInfo } from "./get-job-info.js"; +import { queueLogger } from "./logger.js"; +import processBackground from "./processors/background/index.js"; import processDb from "./processors/db/index.js"; +import processDeliver from "./processors/deliver.js"; +import { endedPollNotification } from "./processors/ended-poll-notification.js"; +import processInbox from "./processors/inbox.js"; import processObjectStorage from "./processors/object-storage/index.js"; import processSystemQueue from "./processors/system/index.js"; import processWebhookDeliver from "./processors/webhook-deliver.js"; -import processBackground from "./processors/background/index.js"; -import { endedPollNotification } from "./processors/ended-poll-notification.js"; -import { queueLogger } from "./logger.js"; -import { getJobInfo } from "./get-job-info.js"; import { - systemQueue, + backgroundQueue, dbQueue, deliverQueue, + endedPollNotificationQueue, inboxQueue, objectStorageQueue, - endedPollNotificationQueue, + systemQueue, webhookDeliverQueue, - backgroundQueue, } from "./queues.js"; import type { ThinUser } from "./types.js"; -import { Note } from "@/models/entities/note.js"; function renderError(e: Error): any { return { diff --git a/packages/backend/src/queue/initialize.ts b/packages/backend/src/queue/initialize.ts index 16e623d1..359db9e0 100644 --- a/packages/backend/src/queue/initialize.ts +++ b/packages/backend/src/queue/initialize.ts @@ -1,5 +1,5 @@ -import Bull from "bull"; import config from "@/config/index.js"; +import Bull from "bull"; export function initialize(name: string, limitPerSec = -1) { return new Bull(name, { @@ -34,7 +34,7 @@ export function initialize(name: string, limitPerSec = -1) { function apBackoff(attemptsMade: number, err: Error) { const baseDelay = 60 * 1000; // 1min const maxBackoff = 8 * 60 * 60 * 1000; // 8hours - let backoff = (Math.pow(2, attemptsMade) - 1) * baseDelay; + let backoff = (2 ** attemptsMade - 1) * baseDelay; backoff = Math.min(backoff, maxBackoff); backoff += Math.round(backoff * Math.random() * 0.2); return backoff; diff --git a/packages/backend/src/queue/processors/background/index-all-notes.ts b/packages/backend/src/queue/processors/background/index-all-notes.ts index 262724cb..07a7b756 100644 --- a/packages/backend/src/queue/processors/background/index-all-notes.ts +++ b/packages/backend/src/queue/processors/background/index-all-notes.ts @@ -1,12 +1,12 @@ import type Bull from "bull"; import type { DoneCallback } from "bull"; -import { queueLogger } from "../../logger.js"; -import { Notes } from "@/models/index.js"; -import { MoreThan } from "typeorm"; -import { index } from "@/services/note/create.js"; -import { Note } from "@/models/entities/note.js"; import meilisearch from "@/db/meilisearch.js"; +import { Note } from "@/models/entities/note.js"; +import { Notes } from "@/models/index.js"; +import { index } from "@/services/note/create.js"; +import { MoreThan } from "typeorm"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("index-all-notes"); diff --git a/packages/backend/src/queue/processors/db/delete-account.ts b/packages/backend/src/queue/processors/db/delete-account.ts index adb93484..336db433 100644 --- a/packages/backend/src/queue/processors/db/delete-account.ts +++ b/packages/backend/src/queue/processors/db/delete-account.ts @@ -1,13 +1,13 @@ -import type Bull from "bull"; -import { queueLogger } from "../../logger.js"; +import meilisearch from "@/db/meilisearch.js"; +import type { DriveFile } from "@/models/entities/drive-file.js"; +import type { Note } from "@/models/entities/note.js"; import { DriveFiles, Notes, UserProfiles, Users } from "@/models/index.js"; import type { DbUserDeleteJobData } from "@/queue/types.js"; -import type { Note } from "@/models/entities/note.js"; -import type { DriveFile } from "@/models/entities/drive-file.js"; -import { MoreThan } from "typeorm"; import { deleteFileSync } from "@/services/drive/delete-file.js"; import { sendEmail } from "@/services/send-email.js"; -import meilisearch from "@/db/meilisearch.js"; +import type Bull from "bull"; +import { MoreThan } from "typeorm"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("delete-account"); diff --git a/packages/backend/src/queue/processors/db/delete-drive-files.ts b/packages/backend/src/queue/processors/db/delete-drive-files.ts index 28e47713..8bff6382 100644 --- a/packages/backend/src/queue/processors/db/delete-drive-files.ts +++ b/packages/backend/src/queue/processors/db/delete-drive-files.ts @@ -1,10 +1,10 @@ import type Bull from "bull"; -import { queueLogger } from "../../logger.js"; -import { deleteFileSync } from "@/services/drive/delete-file.js"; -import { Users, DriveFiles } from "@/models/index.js"; -import { MoreThan } from "typeorm"; +import { DriveFiles, Users } from "@/models/index.js"; import type { DbUserJobData } from "@/queue/types.js"; +import { deleteFileSync } from "@/services/drive/delete-file.js"; +import { MoreThan } from "typeorm"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("delete-drive-files"); diff --git a/packages/backend/src/queue/processors/db/export-blocking.ts b/packages/backend/src/queue/processors/db/export-blocking.ts index 90da76b8..cb7f09d6 100644 --- a/packages/backend/src/queue/processors/db/export-blocking.ts +++ b/packages/backend/src/queue/processors/db/export-blocking.ts @@ -1,14 +1,14 @@ -import type Bull from "bull"; import * as fs from "node:fs"; +import type Bull from "bull"; -import { queueLogger } from "../../logger.js"; -import { addFile } from "@/services/drive/add-file.js"; -import { format as dateFormat } from "date-fns"; import { getFullApAccount } from "@/misc/convert-host.js"; import { createTemp } from "@/misc/create-temp.js"; -import { Users, Blockings } from "@/models/index.js"; -import { MoreThan } from "typeorm"; +import { Blockings, Users } from "@/models/index.js"; import type { DbUserJobData } from "@/queue/types.js"; +import { addFile } from "@/services/drive/add-file.js"; +import { format as dateFormat } from "date-fns"; +import { MoreThan } from "typeorm"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("export-blocking"); @@ -63,7 +63,7 @@ export async function exportBlocking( const content = getFullApAccount(u.username, u.host); await new Promise((res, rej) => { - stream.write(content + "\n", (err) => { + stream.write(`${content}\n`, (err) => { if (err) { logger.error(err); rej(err); diff --git a/packages/backend/src/queue/processors/db/export-custom-emojis.ts b/packages/backend/src/queue/processors/db/export-custom-emojis.ts index 86de43af..d90dab27 100644 --- a/packages/backend/src/queue/processors/db/export-custom-emojis.ts +++ b/packages/backend/src/queue/processors/db/export-custom-emojis.ts @@ -1,16 +1,16 @@ -import type Bull from "bull"; import * as fs from "node:fs"; +import type Bull from "bull"; -import mime from "mime-types"; -import archiver from "archiver"; -import { queueLogger } from "../../logger.js"; -import { addFile } from "@/services/drive/add-file.js"; -import { format as dateFormat } from "date-fns"; -import { Users, Emojis } from "@/models/index.js"; +import config from "@/config/index.js"; import { createTemp, createTempDir } from "@/misc/create-temp.js"; import { downloadUrl } from "@/misc/download-url.js"; -import config from "@/config/index.js"; +import { Emojis, Users } from "@/models/index.js"; +import { addFile } from "@/services/drive/add-file.js"; +import archiver from "archiver"; +import { format as dateFormat } from "date-fns"; +import mime from "mime-types"; import { IsNull } from "typeorm"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("export-custom-emojis"); @@ -90,7 +90,7 @@ export async function exportCustomEmojis( }); const isFirst = customEmojis.indexOf(emoji) === 0; - await writeMeta(isFirst ? content : ",\n" + content); + await writeMeta(isFirst ? content : `,\n${content}`); } await writeMeta("]}"); diff --git a/packages/backend/src/queue/processors/db/export-following.ts b/packages/backend/src/queue/processors/db/export-following.ts index 80e8e6b9..f8ba4280 100644 --- a/packages/backend/src/queue/processors/db/export-following.ts +++ b/packages/backend/src/queue/processors/db/export-following.ts @@ -1,15 +1,15 @@ -import type Bull from "bull"; import * as fs from "node:fs"; +import type Bull from "bull"; -import { queueLogger } from "../../logger.js"; -import { addFile } from "@/services/drive/add-file.js"; -import { format as dateFormat } from "date-fns"; import { getFullApAccount } from "@/misc/convert-host.js"; import { createTemp } from "@/misc/create-temp.js"; -import { Users, Followings, Mutings } from "@/models/index.js"; -import { In, MoreThan, Not } from "typeorm"; -import type { DbUserJobData } from "@/queue/types.js"; import type { Following } from "@/models/entities/following.js"; +import { Followings, Mutings, Users } from "@/models/index.js"; +import type { DbUserJobData } from "@/queue/types.js"; +import { addFile } from "@/services/drive/add-file.js"; +import { format as dateFormat } from "date-fns"; +import { In, MoreThan, Not } from "typeorm"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("export-following"); @@ -78,7 +78,7 @@ export async function exportFollowing( const content = getFullApAccount(u.username, u.host); await new Promise((res, rej) => { - stream.write(content + "\n", (err) => { + stream.write(`${content}\n`, (err) => { if (err) { logger.error(err); rej(err); diff --git a/packages/backend/src/queue/processors/db/export-mute.ts b/packages/backend/src/queue/processors/db/export-mute.ts index 87b140b7..af1f9bb0 100644 --- a/packages/backend/src/queue/processors/db/export-mute.ts +++ b/packages/backend/src/queue/processors/db/export-mute.ts @@ -1,14 +1,14 @@ -import type Bull from "bull"; import * as fs from "node:fs"; +import type Bull from "bull"; -import { queueLogger } from "../../logger.js"; -import { addFile } from "@/services/drive/add-file.js"; -import { format as dateFormat } from "date-fns"; import { getFullApAccount } from "@/misc/convert-host.js"; import { createTemp } from "@/misc/create-temp.js"; -import { Users, Mutings } from "@/models/index.js"; -import { IsNull, MoreThan } from "typeorm"; +import { Mutings, Users } from "@/models/index.js"; import type { DbUserJobData } from "@/queue/types.js"; +import { addFile } from "@/services/drive/add-file.js"; +import { format as dateFormat } from "date-fns"; +import { IsNull, MoreThan } from "typeorm"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("export-mute"); @@ -64,7 +64,7 @@ export async function exportMute( const content = getFullApAccount(u.username, u.host); await new Promise((res, rej) => { - stream.write(content + "\n", (err) => { + stream.write(`${content}\n`, (err) => { if (err) { logger.error(err); rej(err); diff --git a/packages/backend/src/queue/processors/db/export-notes.ts b/packages/backend/src/queue/processors/db/export-notes.ts index bf53f836..63ae4072 100644 --- a/packages/backend/src/queue/processors/db/export-notes.ts +++ b/packages/backend/src/queue/processors/db/export-notes.ts @@ -1,15 +1,15 @@ -import type Bull from "bull"; import * as fs from "node:fs"; +import type Bull from "bull"; -import { queueLogger } from "../../logger.js"; -import { addFile } from "@/services/drive/add-file.js"; -import { format as dateFormat } from "date-fns"; -import { Users, Notes, Polls, DriveFiles } from "@/models/index.js"; -import { MoreThan } from "typeorm"; +import { createTemp } from "@/misc/create-temp.js"; import type { Note } from "@/models/entities/note.js"; import type { Poll } from "@/models/entities/poll.js"; +import { DriveFiles, Notes, Polls, Users } from "@/models/index.js"; import type { DbUserJobData } from "@/queue/types.js"; -import { createTemp } from "@/misc/create-temp.js"; +import { addFile } from "@/services/drive/add-file.js"; +import { format as dateFormat } from "date-fns"; +import { MoreThan } from "typeorm"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("export-notes"); @@ -77,7 +77,7 @@ export async function exportNotes( } const content = JSON.stringify(await serialize(note, poll)); const isFirst = exportedNotesCount === 0; - await write(isFirst ? content : ",\n" + content); + await write(isFirst ? content : `,\n${content}`); exportedNotesCount++; } diff --git a/packages/backend/src/queue/processors/db/export-user-lists.ts b/packages/backend/src/queue/processors/db/export-user-lists.ts index e0c9cd8f..96d161b4 100644 --- a/packages/backend/src/queue/processors/db/export-user-lists.ts +++ b/packages/backend/src/queue/processors/db/export-user-lists.ts @@ -1,14 +1,14 @@ -import type Bull from "bull"; import * as fs from "node:fs"; +import type Bull from "bull"; -import { queueLogger } from "../../logger.js"; -import { addFile } from "@/services/drive/add-file.js"; -import { format as dateFormat } from "date-fns"; import { getFullApAccount } from "@/misc/convert-host.js"; import { createTemp } from "@/misc/create-temp.js"; -import { Users, UserLists, UserListJoinings } from "@/models/index.js"; -import { In } from "typeorm"; +import { UserListJoinings, UserLists, Users } from "@/models/index.js"; import type { DbUserJobData } from "@/queue/types.js"; +import { addFile } from "@/services/drive/add-file.js"; +import { format as dateFormat } from "date-fns"; +import { In } from "typeorm"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("export-user-lists"); @@ -46,7 +46,7 @@ export async function exportUserLists( const acct = getFullApAccount(u.username, u.host); const content = `${list.name},${acct}`; await new Promise((res, rej) => { - stream.write(content + "\n", (err) => { + stream.write(`${content}\n`, (err) => { if (err) { logger.error(err); rej(err); diff --git a/packages/backend/src/queue/processors/db/import-blocking.ts b/packages/backend/src/queue/processors/db/import-blocking.ts index 290c9dbc..ff07ed12 100644 --- a/packages/backend/src/queue/processors/db/import-blocking.ts +++ b/packages/backend/src/queue/processors/db/import-blocking.ts @@ -1,14 +1,14 @@ import type Bull from "bull"; -import { queueLogger } from "../../logger.js"; import * as Acct from "@/misc/acct.js"; -import { resolveUser } from "@/remote/resolve-user.js"; -import { downloadTextFile } from "@/misc/download-text-file.js"; import { isSelfHost, toPuny } from "@/misc/convert-host.js"; -import { Users, DriveFiles } from "@/models/index.js"; +import { downloadTextFile } from "@/misc/download-text-file.js"; +import { DriveFiles, Users } from "@/models/index.js"; import type { DbUserImportJobData } from "@/queue/types.js"; +import { resolveUser } from "@/remote/resolve-user.js"; import block from "@/services/blocking/create.js"; import { IsNull } from "typeorm"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("import-blocking"); diff --git a/packages/backend/src/queue/processors/db/import-custom-emojis.ts b/packages/backend/src/queue/processors/db/import-custom-emojis.ts index 9e8b3b17..11dafd13 100644 --- a/packages/backend/src/queue/processors/db/import-custom-emojis.ts +++ b/packages/backend/src/queue/processors/db/import-custom-emojis.ts @@ -1,17 +1,17 @@ -import type Bull from "bull"; import * as fs from "node:fs"; import AdmZip from "adm-zip"; +import type Bull from "bull"; -import { queueLogger } from "../../logger.js"; +import * as path from "path"; +import { db } from "@/db/postgre.js"; import { createTempDir } from "@/misc/create-temp.js"; import { downloadUrl } from "@/misc/download-url.js"; +import { genId } from "@/misc/gen-id.js"; import { DriveFiles, Emojis } from "@/models/index.js"; import type { DbUserImportJobData } from "@/queue/types.js"; import { addFile } from "@/services/drive/add-file.js"; -import { genId } from "@/misc/gen-id.js"; -import { db } from "@/db/postgre.js"; import probeImageSize from "probe-image-size"; -import * as path from "path"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("import-custom-emojis"); @@ -92,7 +92,7 @@ export async function importCustomEmojis( } else { logger.info("starting emoji import without metadata"); // Since we lack metadata, we import into a randomized category name instead - let categoryName = genId(); + const categoryName = genId(); let containedEmojis = fs.readdirSync(outputPath); @@ -139,7 +139,7 @@ export async function importCustomEmojis( } } - await db.queryResultCache!.remove(["meta_emojis"]); + await db.queryResultCache?.remove(["meta_emojis"]); cleanup(); diff --git a/packages/backend/src/queue/processors/db/import-firefish-post.ts b/packages/backend/src/queue/processors/db/import-firefish-post.ts index 4ec88d32..8ffc9b15 100644 --- a/packages/backend/src/queue/processors/db/import-firefish-post.ts +++ b/packages/backend/src/queue/processors/db/import-firefish-post.ts @@ -1,15 +1,15 @@ -import * as Post from "@/misc/post.js"; -import create from "@/services/note/create.js"; -import { Users } from "@/models/index.js"; -import type { DbUserImportMastoPostJobData } from "@/queue/types.js"; -import { queueLogger } from "../../logger.js"; -import { uploadFromUrl } from "@/services/drive/upload-from-url.js"; -import type { DriveFile } from "@/models/entities/drive-file.js"; -import type Bull from "bull"; -import { createImportCkPostJob } from "@/queue/index.js"; -import { Notes, NoteEdits } from "@/models/index.js"; -import type { Note } from "@/models/entities/note.js"; import { genId } from "@/misc/gen-id.js"; +import * as Post from "@/misc/post.js"; +import type { DriveFile } from "@/models/entities/drive-file.js"; +import type { Note } from "@/models/entities/note.js"; +import { Users } from "@/models/index.js"; +import { NoteEdits, Notes } from "@/models/index.js"; +import { createImportCkPostJob } from "@/queue/index.js"; +import type { DbUserImportMastoPostJobData } from "@/queue/types.js"; +import { uploadFromUrl } from "@/services/drive/upload-from-url.js"; +import create from "@/services/note/create.js"; +import type Bull from "bull"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("import-firefish-post"); @@ -39,7 +39,7 @@ export async function importCkPost( */ const urls = (post.files || []) .map((x: any) => x.url) - .filter((x: String) => x.startsWith("http")); + .filter((x: string) => x.startsWith("http")); const files: DriveFile[] = []; for (const url of urls) { try { @@ -71,12 +71,12 @@ export async function importCkPost( fileIds: note.fileIds, updatedAt: new Date(), }); - logger.info(`Note file updated`); + logger.info("Note file updated"); } if (!note) { note = await create(user, { createdAt: createdAt, - files: files.length == 0 ? undefined : files, + files: files.length === 0 ? undefined : files, poll: undefined, text: text || undefined, reply: post.replyId ? job.data.parent : null, @@ -90,9 +90,9 @@ export async function importCkPost( apHashtags: undefined, apEmojis: undefined, }); - logger.info(`Create new note`); + logger.info("Create new note"); } else { - logger.info(`Note exist`); + logger.info("Note exist"); } logger.succ("Imported"); if (post.childNotes) { diff --git a/packages/backend/src/queue/processors/db/import-following.ts b/packages/backend/src/queue/processors/db/import-following.ts index b1a7cd2c..1789c8e9 100644 --- a/packages/backend/src/queue/processors/db/import-following.ts +++ b/packages/backend/src/queue/processors/db/import-following.ts @@ -1,14 +1,14 @@ -import { IsNull } from "typeorm"; import follow from "@/services/following/create.js"; +import { IsNull } from "typeorm"; import * as Acct from "@/misc/acct.js"; -import { resolveUser } from "@/remote/resolve-user.js"; -import { downloadTextFile } from "@/misc/download-text-file.js"; import { isSelfHost, toPuny } from "@/misc/convert-host.js"; -import { Users, DriveFiles } from "@/models/index.js"; +import { downloadTextFile } from "@/misc/download-text-file.js"; +import { DriveFiles, Users } from "@/models/index.js"; import type { DbUserImportJobData } from "@/queue/types.js"; -import { queueLogger } from "../../logger.js"; +import { resolveUser } from "@/remote/resolve-user.js"; import type Bull from "bull"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("import-following"); diff --git a/packages/backend/src/queue/processors/db/import-masto-post.ts b/packages/backend/src/queue/processors/db/import-masto-post.ts index c484ac0e..f361a447 100644 --- a/packages/backend/src/queue/processors/db/import-masto-post.ts +++ b/packages/backend/src/queue/processors/db/import-masto-post.ts @@ -1,15 +1,15 @@ -import create from "@/services/note/create.js"; +import { genId } from "@/misc/gen-id.js"; +import type { DriveFile } from "@/models/entities/drive-file.js"; +import type { Note } from "@/models/entities/note.js"; import { Users } from "@/models/index.js"; +import { NoteEdits, Notes } from "@/models/index.js"; import type { DbUserImportMastoPostJobData } from "@/queue/types.js"; -import { queueLogger } from "../../logger.js"; -import type Bull from "bull"; import { htmlToMfm } from "@/remote/activitypub/misc/html-to-mfm.js"; import { resolveNote } from "@/remote/activitypub/models/note.js"; import { uploadFromUrl } from "@/services/drive/upload-from-url.js"; -import type { DriveFile } from "@/models/entities/drive-file.js"; -import { Notes, NoteEdits } from "@/models/index.js"; -import type { Note } from "@/models/entities/note.js"; -import { genId } from "@/misc/gen-id.js"; +import create from "@/services/note/create.js"; +import type Bull from "bull"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("import-masto-post"); @@ -52,10 +52,10 @@ export async function importMastoPost( .map((x: any) => x?.driveFile) .filter((x: any) => x); - if (files.length == 0) { + if (files.length === 0) { const urls = post.object.attachment .map((x: any) => x.url) - .filter((x: String) => x.startsWith("http")); + .filter((x: string) => x.startsWith("http")); files = []; for (const url of urls) { try { @@ -87,12 +87,12 @@ export async function importMastoPost( fileIds: note.fileIds, updatedAt: new Date(), }); - logger.info(`Note file updated`); + logger.info("Note file updated"); } if (!note) { note = await create(user, { createdAt: new Date(post.object.published), - files: files.length == 0 ? undefined : files, + files: files.length === 0 ? undefined : files, poll: undefined, text: text || undefined, reply, @@ -106,9 +106,9 @@ export async function importMastoPost( apHashtags: undefined, apEmojis: undefined, }); - logger.info(`Create new note`); + logger.info("Create new note"); } else { - logger.info(`Note exist`); + logger.info("Note exist"); } job.progress(100); done(); diff --git a/packages/backend/src/queue/processors/db/import-muting.ts b/packages/backend/src/queue/processors/db/import-muting.ts index 80e05673..7ff4fad9 100644 --- a/packages/backend/src/queue/processors/db/import-muting.ts +++ b/packages/backend/src/queue/processors/db/import-muting.ts @@ -1,15 +1,15 @@ import type Bull from "bull"; -import { queueLogger } from "../../logger.js"; import * as Acct from "@/misc/acct.js"; -import { resolveUser } from "@/remote/resolve-user.js"; -import { downloadTextFile } from "@/misc/download-text-file.js"; import { isSelfHost, toPuny } from "@/misc/convert-host.js"; -import { Users, DriveFiles, Mutings } from "@/models/index.js"; -import type { DbUserImportJobData } from "@/queue/types.js"; -import type { User } from "@/models/entities/user.js"; +import { downloadTextFile } from "@/misc/download-text-file.js"; import { genId } from "@/misc/gen-id.js"; +import type { User } from "@/models/entities/user.js"; +import { DriveFiles, Mutings, Users } from "@/models/index.js"; +import type { DbUserImportJobData } from "@/queue/types.js"; +import { resolveUser } from "@/remote/resolve-user.js"; import { IsNull } from "typeorm"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("import-muting"); diff --git a/packages/backend/src/queue/processors/db/import-posts.ts b/packages/backend/src/queue/processors/db/import-posts.ts index 526489c6..7d994803 100644 --- a/packages/backend/src/queue/processors/db/import-posts.ts +++ b/packages/backend/src/queue/processors/db/import-posts.ts @@ -1,13 +1,13 @@ import { downloadTextFile } from "@/misc/download-text-file.js"; import { processMastoNotes } from "@/misc/process-masto-notes.js"; -import { Users, DriveFiles } from "@/models/index.js"; -import type { DbUserImportPostsJobData } from "@/queue/types.js"; -import { queueLogger } from "../../logger.js"; -import type Bull from "bull"; +import { DriveFiles, Users } from "@/models/index.js"; import { createImportCkPostJob, createImportMastoPostJob, } from "@/queue/index.js"; +import type { DbUserImportPostsJobData } from "@/queue/types.js"; +import type Bull from "bull"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("import-posts"); @@ -55,7 +55,7 @@ export async function importPosts( try { const parsed = JSON.parse(json); - if (parsed instanceof Array) { + if (Array.isArray(parsed)) { logger.info("Parsing key style posts"); const arr = recreateChain(parsed); for (const post of arr) { diff --git a/packages/backend/src/queue/processors/db/import-user-lists.ts b/packages/backend/src/queue/processors/db/import-user-lists.ts index 0c23f069..00079605 100644 --- a/packages/backend/src/queue/processors/db/import-user-lists.ts +++ b/packages/backend/src/queue/processors/db/import-user-lists.ts @@ -1,20 +1,20 @@ import type Bull from "bull"; -import { queueLogger } from "../../logger.js"; import * as Acct from "@/misc/acct.js"; -import { resolveUser } from "@/remote/resolve-user.js"; -import { pushUserToUserList } from "@/services/user-list/push.js"; -import { downloadTextFile } from "@/misc/download-text-file.js"; import { isSelfHost, toPuny } from "@/misc/convert-host.js"; +import { downloadTextFile } from "@/misc/download-text-file.js"; +import { genId } from "@/misc/gen-id.js"; import { DriveFiles, - Users, - UserLists, UserListJoinings, + UserLists, + Users, } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; import type { DbUserImportJobData } from "@/queue/types.js"; +import { resolveUser } from "@/remote/resolve-user.js"; +import { pushUserToUserList } from "@/services/user-list/push.js"; import { IsNull } from "typeorm"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("import-user-lists"); @@ -79,7 +79,7 @@ export async function importUserLists( if ( (await UserListJoinings.findOneBy({ - userListId: list!.id, + userListId: list?.id, userId: target.id, })) != null ) diff --git a/packages/backend/src/queue/processors/db/index.ts b/packages/backend/src/queue/processors/db/index.ts index d20fc2c7..1245e08c 100644 --- a/packages/backend/src/queue/processors/db/index.ts +++ b/packages/backend/src/queue/processors/db/index.ts @@ -1,21 +1,21 @@ -import type Bull from "bull"; import type { DbJobData } from "@/queue/types.js"; +import type Bull from "bull"; +import { deleteAccount } from "./delete-account.js"; import { deleteDriveFiles } from "./delete-drive-files.js"; +import { exportBlocking } from "./export-blocking.js"; import { exportCustomEmojis } from "./export-custom-emojis.js"; -import { exportNotes } from "./export-notes.js"; import { exportFollowing } from "./export-following.js"; import { exportMute } from "./export-mute.js"; -import { exportBlocking } from "./export-blocking.js"; +import { exportNotes } from "./export-notes.js"; import { exportUserLists } from "./export-user-lists.js"; -import { importFollowing } from "./import-following.js"; -import { importUserLists } from "./import-user-lists.js"; -import { deleteAccount } from "./delete-account.js"; -import { importMuting } from "./import-muting.js"; -import { importPosts } from "./import-posts.js"; -import { importMastoPost } from "./import-masto-post.js"; -import { importCkPost } from "./import-firefish-post.js"; import { importBlocking } from "./import-blocking.js"; import { importCustomEmojis } from "./import-custom-emojis.js"; +import { importCkPost } from "./import-firefish-post.js"; +import { importFollowing } from "./import-following.js"; +import { importMastoPost } from "./import-masto-post.js"; +import { importMuting } from "./import-muting.js"; +import { importPosts } from "./import-posts.js"; +import { importUserLists } from "./import-user-lists.js"; const jobs = { deleteDriveFiles, diff --git a/packages/backend/src/queue/processors/deliver.ts b/packages/backend/src/queue/processors/deliver.ts index 45c2d3dc..dae1bd21 100644 --- a/packages/backend/src/queue/processors/deliver.ts +++ b/packages/backend/src/queue/processors/deliver.ts @@ -1,13 +1,13 @@ import { URL } from "node:url"; -import request from "@/remote/activitypub/request.js"; -import { registerOrFetchInstanceDoc } from "@/services/register-or-fetch-instance-doc.js"; -import Logger from "@/services/logger.js"; -import { Instances } from "@/models/index.js"; -import { fetchInstanceMetadata } from "@/services/fetch-instance-metadata.js"; import { toPuny } from "@/misc/convert-host.js"; import { StatusError } from "@/misc/fetch.js"; import { shouldSkipInstance } from "@/misc/skipped-instances.js"; +import { Instances } from "@/models/index.js"; import type { DeliverJobData } from "@/queue/types.js"; +import request from "@/remote/activitypub/request.js"; +import { fetchInstanceMetadata } from "@/services/fetch-instance-metadata.js"; +import Logger from "@/services/logger.js"; +import { registerOrFetchInstanceDoc } from "@/services/register-or-fetch-instance-doc.js"; import type Bull from "bull"; const logger = new Logger("deliver"); diff --git a/packages/backend/src/queue/processors/ended-poll-notification.ts b/packages/backend/src/queue/processors/ended-poll-notification.ts index f93b067b..140b315e 100644 --- a/packages/backend/src/queue/processors/ended-poll-notification.ts +++ b/packages/backend/src/queue/processors/ended-poll-notification.ts @@ -1,9 +1,9 @@ -import type Bull from "bull"; import { Notes, PollVotes } from "@/models/index.js"; // import { queueLogger } from "../logger.js"; import type { EndedPollNotificationJobData } from "@/queue/types.js"; import { createNotification } from "@/services/create-notification.js"; import { deliverQuestionUpdate } from "@/services/note/polls/update.js"; +import type Bull from "bull"; // unused // const logger = queueLogger.createSubLogger("ended-poll-notification"); diff --git a/packages/backend/src/queue/processors/inbox.ts b/packages/backend/src/queue/processors/inbox.ts index 15f75af6..74540eb5 100644 --- a/packages/backend/src/queue/processors/inbox.ts +++ b/packages/backend/src/queue/processors/inbox.ts @@ -1,22 +1,22 @@ import { URL } from "node:url"; -import type Bull from "bull"; -import httpSignature from "@peertube/http-signature"; -import perform from "@/remote/activitypub/perform.js"; -import Logger from "@/services/logger.js"; -import { registerOrFetchInstanceDoc } from "@/services/register-or-fetch-instance-doc.js"; -import { Instances } from "@/models/index.js"; +import { extractDbHost, toPuny } from "@/misc/convert-host.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; -import { toPuny, extractDbHost } from "@/misc/convert-host.js"; +import { StatusError } from "@/misc/fetch.js"; +import { shouldBlockInstance } from "@/misc/should-block-instance.js"; +import type { UserPublickey } from "@/models/entities/user-publickey.js"; +import type { CacheableRemoteUser } from "@/models/entities/user.js"; +import { Instances } from "@/models/index.js"; +import DbResolver from "@/remote/activitypub/db-resolver.js"; +import { LdSignature } from "@/remote/activitypub/misc/ld-signature.js"; +import { resolvePerson } from "@/remote/activitypub/models/person.js"; +import perform from "@/remote/activitypub/perform.js"; import { getApId } from "@/remote/activitypub/type.js"; import { fetchInstanceMetadata } from "@/services/fetch-instance-metadata.js"; +import Logger from "@/services/logger.js"; +import { registerOrFetchInstanceDoc } from "@/services/register-or-fetch-instance-doc.js"; +import httpSignature from "@peertube/http-signature"; +import type Bull from "bull"; import type { InboxJobData } from "../types.js"; -import DbResolver from "@/remote/activitypub/db-resolver.js"; -import { resolvePerson } from "@/remote/activitypub/models/person.js"; -import { LdSignature } from "@/remote/activitypub/misc/ld-signature.js"; -import { StatusError } from "@/misc/fetch.js"; -import type { CacheableRemoteUser } from "@/models/entities/user.js"; -import type { UserPublickey } from "@/models/entities/user-publickey.js"; -import { shouldBlockInstance } from "@/misc/should-block-instance.js"; const logger = new Logger("inbox"); diff --git a/packages/backend/src/queue/processors/object-storage/clean-remote-files.ts b/packages/backend/src/queue/processors/object-storage/clean-remote-files.ts index 14ad1b10..6d9ef955 100644 --- a/packages/backend/src/queue/processors/object-storage/clean-remote-files.ts +++ b/packages/backend/src/queue/processors/object-storage/clean-remote-files.ts @@ -1,9 +1,9 @@ import type Bull from "bull"; -import { queueLogger } from "../../logger.js"; -import { deleteFileSync } from "@/services/drive/delete-file.js"; import { DriveFiles } from "@/models/index.js"; -import { MoreThan, Not, IsNull } from "typeorm"; +import { deleteFileSync } from "@/services/drive/delete-file.js"; +import { IsNull, MoreThan, Not } from "typeorm"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("clean-remote-files"); diff --git a/packages/backend/src/queue/processors/object-storage/delete-file.ts b/packages/backend/src/queue/processors/object-storage/delete-file.ts index 174aa190..761c83ca 100644 --- a/packages/backend/src/queue/processors/object-storage/delete-file.ts +++ b/packages/backend/src/queue/processors/object-storage/delete-file.ts @@ -1,6 +1,6 @@ import type { ObjectStorageFileJobData } from "@/queue/types.js"; -import type Bull from "bull"; import { deleteObjectStorageFile } from "@/services/drive/delete-file.js"; +import type Bull from "bull"; export default async (job: Bull.Job) => { const key: string = job.data.key; diff --git a/packages/backend/src/queue/processors/object-storage/index.ts b/packages/backend/src/queue/processors/object-storage/index.ts index 5f90d4cd..255ff9f2 100644 --- a/packages/backend/src/queue/processors/object-storage/index.ts +++ b/packages/backend/src/queue/processors/object-storage/index.ts @@ -1,7 +1,7 @@ -import type Bull from "bull"; import type { ObjectStorageJobData } from "@/queue/types.js"; -import deleteFile from "./delete-file.js"; +import type Bull from "bull"; import cleanRemoteFiles from "./clean-remote-files.js"; +import deleteFile from "./delete-file.js"; const jobs = { deleteFile, diff --git a/packages/backend/src/queue/processors/system/check-expired-mutings.ts b/packages/backend/src/queue/processors/system/check-expired-mutings.ts index a482d021..17715fb4 100644 --- a/packages/backend/src/queue/processors/system/check-expired-mutings.ts +++ b/packages/backend/src/queue/processors/system/check-expired-mutings.ts @@ -1,8 +1,8 @@ +import { Mutings } from "@/models/index.js"; +import { publishUserEvent } from "@/services/stream.js"; import type Bull from "bull"; import { In } from "typeorm"; -import { Mutings } from "@/models/index.js"; import { queueLogger } from "../../logger.js"; -import { publishUserEvent } from "@/services/stream.js"; const logger = queueLogger.createSubLogger("check-expired-mutings"); diff --git a/packages/backend/src/queue/processors/system/clean-charts.ts b/packages/backend/src/queue/processors/system/clean-charts.ts index 893a4d08..2bd10be2 100644 --- a/packages/backend/src/queue/processors/system/clean-charts.ts +++ b/packages/backend/src/queue/processors/system/clean-charts.ts @@ -1,7 +1,7 @@ import type Bull from "bull"; -import { queueLogger } from "../../logger.js"; import { activeUsersChart } from "@/services/chart/index.js"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("clean-charts"); diff --git a/packages/backend/src/queue/processors/system/clean.ts b/packages/backend/src/queue/processors/system/clean.ts index fbd45b0b..8f46c43f 100644 --- a/packages/backend/src/queue/processors/system/clean.ts +++ b/packages/backend/src/queue/processors/system/clean.ts @@ -1,6 +1,6 @@ +import { UserIps } from "@/models/index.js"; import type Bull from "bull"; import { LessThan } from "typeorm"; -import { UserIps } from "@/models/index.js"; import { queueLogger } from "../../logger.js"; diff --git a/packages/backend/src/queue/processors/system/index.ts b/packages/backend/src/queue/processors/system/index.ts index a2a148ab..8ff43838 100644 --- a/packages/backend/src/queue/processors/system/index.ts +++ b/packages/backend/src/queue/processors/system/index.ts @@ -1,6 +1,6 @@ import type Bull from "bull"; -import { cleanCharts } from "./clean-charts.js"; import { checkExpiredMutings } from "./check-expired-mutings.js"; +import { cleanCharts } from "./clean-charts.js"; import { clean } from "./clean.js"; import { setLocalEmojiSizes } from "./local-emoji-size.js"; import { verifyLinks } from "./verify-links.js"; diff --git a/packages/backend/src/queue/processors/system/local-emoji-size.ts b/packages/backend/src/queue/processors/system/local-emoji-size.ts index d696bbd8..94f1693e 100644 --- a/packages/backend/src/queue/processors/system/local-emoji-size.ts +++ b/packages/backend/src/queue/processors/system/local-emoji-size.ts @@ -1,9 +1,9 @@ +import { Emojis } from "@/models/index.js"; import type Bull from "bull"; import { IsNull } from "typeorm"; -import { Emojis } from "@/models/index.js"; -import { queueLogger } from "../../logger.js"; import { getEmojiSize } from "@/misc/emoji-meta.js"; +import { queueLogger } from "../../logger.js"; const logger = queueLogger.createSubLogger("local-emoji-size"); diff --git a/packages/backend/src/queue/processors/system/verify-links.ts b/packages/backend/src/queue/processors/system/verify-links.ts index 4ee88c63..b2c1d65b 100644 --- a/packages/backend/src/queue/processors/system/verify-links.ts +++ b/packages/backend/src/queue/processors/system/verify-links.ts @@ -1,9 +1,9 @@ import type Bull from "bull"; import { UserProfiles } from "@/models/index.js"; +import { verifyLink } from "@/services/fetch-rel-me.js"; import { Not } from "typeorm"; import { queueLogger } from "../../logger.js"; -import { verifyLink } from "@/services/fetch-rel-me.js"; const logger = queueLogger.createSubLogger("verify-links"); diff --git a/packages/backend/src/queue/processors/webhook-deliver.ts b/packages/backend/src/queue/processors/webhook-deliver.ts index 12c9a054..19f0aec3 100644 --- a/packages/backend/src/queue/processors/webhook-deliver.ts +++ b/packages/backend/src/queue/processors/webhook-deliver.ts @@ -1,9 +1,9 @@ -import type Bull from "bull"; -import Logger from "@/services/logger.js"; -import type { WebhookDeliverJobData } from "../types.js"; -import { getResponse, StatusError } from "@/misc/fetch.js"; -import { Webhooks } from "@/models/index.js"; import config from "@/config/index.js"; +import { StatusError, getResponse } from "@/misc/fetch.js"; +import { Webhooks } from "@/models/index.js"; +import Logger from "@/services/logger.js"; +import type Bull from "bull"; +import type { WebhookDeliverJobData } from "../types.js"; const logger = new Logger("webhook"); diff --git a/packages/backend/src/queue/queues.ts b/packages/backend/src/queue/queues.ts index 6b0eb2de..174a67af 100644 --- a/packages/backend/src/queue/queues.ts +++ b/packages/backend/src/queue/queues.ts @@ -1,11 +1,11 @@ import config from "@/config/index.js"; import { initialize as initializeQueue } from "./initialize.js"; import type { - DeliverJobData, - InboxJobData, DbJobData, - ObjectStorageJobData, + DeliverJobData, EndedPollNotificationJobData, + InboxJobData, + ObjectStorageJobData, WebhookDeliverJobData, } from "./types.js"; diff --git a/packages/backend/src/remote/activitypub/audience.ts b/packages/backend/src/remote/activitypub/audience.ts index 9d840bc5..6a45581e 100644 --- a/packages/backend/src/remote/activitypub/audience.ts +++ b/packages/backend/src/remote/activitypub/audience.ts @@ -1,13 +1,13 @@ -import type { ApObject } from "./type.js"; -import { getApIds } from "./type.js"; -import type Resolver from "./resolver.js"; -import { resolvePerson } from "./models/person.js"; -import { unique, concat } from "@/prelude/array.js"; -import promiseLimit from "promise-limit"; import type { CacheableRemoteUser, CacheableUser, } from "@/models/entities/user.js"; +import { concat, unique } from "@/prelude/array.js"; +import promiseLimit from "promise-limit"; +import { resolvePerson } from "./models/person.js"; +import type Resolver from "./resolver.js"; +import type { ApObject } from "./type.js"; +import { getApIds } from "./type.js"; type Visibility = "public" | "home" | "followers" | "specified"; diff --git a/packages/backend/src/remote/activitypub/check-fetch.ts b/packages/backend/src/remote/activitypub/check-fetch.ts index b7fa179a..4da50789 100644 --- a/packages/backend/src/remote/activitypub/check-fetch.ts +++ b/packages/backend/src/remote/activitypub/check-fetch.ts @@ -1,14 +1,14 @@ +import type { IncomingMessage } from "http"; import { URL } from "url"; -import httpSignature from "@peertube/http-signature"; import config from "@/config/index.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; import { toPuny } from "@/misc/convert-host.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; +import { shouldBlockInstance } from "@/misc/should-block-instance.js"; +import type { UserPublickey } from "@/models/entities/user-publickey.js"; +import type { CacheableRemoteUser } from "@/models/entities/user.js"; import DbResolver from "@/remote/activitypub/db-resolver.js"; import { getApId } from "@/remote/activitypub/type.js"; -import { shouldBlockInstance } from "@/misc/should-block-instance.js"; -import type { IncomingMessage } from "http"; -import type { CacheableRemoteUser } from "@/models/entities/user.js"; -import type { UserPublickey } from "@/models/entities/user-publickey.js"; +import httpSignature from "@peertube/http-signature"; export async function hasSignature(req: IncomingMessage): Promise { const meta = await fetchMeta(); diff --git a/packages/backend/src/remote/activitypub/db-resolver.ts b/packages/backend/src/remote/activitypub/db-resolver.ts index a753606a..a25662b6 100644 --- a/packages/backend/src/remote/activitypub/db-resolver.ts +++ b/packages/backend/src/remote/activitypub/db-resolver.ts @@ -1,23 +1,23 @@ -import escapeRegexp from "escape-regexp"; import config from "@/config/index.js"; +import { Cache } from "@/misc/cache.js"; +import type { MessagingMessage } from "@/models/entities/messaging-message.js"; import type { Note } from "@/models/entities/note.js"; +import type { UserPublickey } from "@/models/entities/user-publickey.js"; import type { CacheableRemoteUser, CacheableUser, } from "@/models/entities/user.js"; -import type { UserPublickey } from "@/models/entities/user-publickey.js"; -import type { MessagingMessage } from "@/models/entities/messaging-message.js"; import { - Notes, - Users, - UserPublickeys, MessagingMessages, + Notes, + UserPublickeys, + Users, } from "@/models/index.js"; -import { Cache } from "@/misc/cache.js"; import { uriPersonCache, userByIdCache } from "@/services/user-cache.js"; +import escapeRegexp from "escape-regexp"; +import { resolvePerson, updatePerson } from "./models/person.js"; import type { IObject } from "./type.js"; import { getApId } from "./type.js"; -import { resolvePerson, updatePerson } from "./models/person.js"; const publicKeyCache = new Cache("publicKey", 60 * 30); const publicKeyByUserIdCache = new Cache( diff --git a/packages/backend/src/remote/activitypub/deliver-manager.ts b/packages/backend/src/remote/activitypub/deliver-manager.ts index c97d1c99..023a2774 100644 --- a/packages/backend/src/remote/activitypub/deliver-manager.ts +++ b/packages/backend/src/remote/activitypub/deliver-manager.ts @@ -1,8 +1,8 @@ -import { IsNull, Not } from "typeorm"; -import { Users, Followings } from "@/models/index.js"; -import type { ILocalUser, IRemoteUser, User } from "@/models/entities/user.js"; -import { deliver } from "@/queue/index.js"; import { skippedInstances } from "@/misc/skipped-instances.js"; +import type { ILocalUser, IRemoteUser, User } from "@/models/entities/user.js"; +import { Followings, Users } from "@/models/index.js"; +import { deliver } from "@/queue/index.js"; +import { IsNull, Not } from "typeorm"; //#region types interface IRecipe { diff --git a/packages/backend/src/remote/activitypub/kernel/accept/follow.ts b/packages/backend/src/remote/activitypub/kernel/accept/follow.ts index e430bbf5..fc9a4755 100644 --- a/packages/backend/src/remote/activitypub/kernel/accept/follow.ts +++ b/packages/backend/src/remote/activitypub/kernel/accept/follow.ts @@ -1,8 +1,8 @@ import type { CacheableRemoteUser } from "@/models/entities/user.js"; import accept from "@/services/following/requests/accept.js"; -import type { IFollow } from "../../type.js"; -import DbResolver from "../../db-resolver.js"; import { relayAccepted } from "@/services/relay.js"; +import DbResolver from "../../db-resolver.js"; +import type { IFollow } from "../../type.js"; export default async ( actor: CacheableRemoteUser, diff --git a/packages/backend/src/remote/activitypub/kernel/accept/index.ts b/packages/backend/src/remote/activitypub/kernel/accept/index.ts index 5c73760f..42c4dcb3 100644 --- a/packages/backend/src/remote/activitypub/kernel/accept/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/accept/index.ts @@ -1,9 +1,9 @@ -import Resolver from "../../resolver.js"; import type { CacheableRemoteUser } from "@/models/entities/user.js"; -import acceptFollow from "./follow.js"; -import type { IAccept } from "../../type.js"; -import { isFollow, getApType } from "../../type.js"; import { apLogger } from "../../logger.js"; +import Resolver from "../../resolver.js"; +import type { IAccept } from "../../type.js"; +import { getApType, isFollow } from "../../type.js"; +import acceptFollow from "./follow.js"; const logger = apLogger; diff --git a/packages/backend/src/remote/activitypub/kernel/add/index.ts b/packages/backend/src/remote/activitypub/kernel/add/index.ts index b3606e5d..1ef49ed7 100644 --- a/packages/backend/src/remote/activitypub/kernel/add/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/add/index.ts @@ -1,7 +1,7 @@ import type { CacheableRemoteUser } from "@/models/entities/user.js"; -import type { IAdd } from "../../type.js"; -import { resolveNote } from "../../models/note.js"; import { addPinned } from "@/services/i/pin.js"; +import { resolveNote } from "../../models/note.js"; +import type { IAdd } from "../../type.js"; export default async ( actor: CacheableRemoteUser, diff --git a/packages/backend/src/remote/activitypub/kernel/announce/index.ts b/packages/backend/src/remote/activitypub/kernel/announce/index.ts index 975e070f..f3e85135 100644 --- a/packages/backend/src/remote/activitypub/kernel/announce/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/announce/index.ts @@ -1,9 +1,9 @@ -import Resolver from "../../resolver.js"; import type { CacheableRemoteUser } from "@/models/entities/user.js"; -import announceNote from "./note.js"; +import { apLogger } from "../../logger.js"; +import Resolver from "../../resolver.js"; import type { IAnnounce } from "../../type.js"; import { getApId } from "../../type.js"; -import { apLogger } from "../../logger.js"; +import announceNote from "./note.js"; const logger = apLogger; diff --git a/packages/backend/src/remote/activitypub/kernel/announce/note.ts b/packages/backend/src/remote/activitypub/kernel/announce/note.ts index 50b59932..e62cdd20 100644 --- a/packages/backend/src/remote/activitypub/kernel/announce/note.ts +++ b/packages/backend/src/remote/activitypub/kernel/announce/note.ts @@ -1,16 +1,16 @@ -import type Resolver from "../../resolver.js"; -import post from "@/services/note/create.js"; +import { getApLock } from "@/misc/app-lock.js"; +import { extractDbHost } from "@/misc/convert-host.js"; +import { StatusError } from "@/misc/fetch.js"; +import { shouldBlockInstance } from "@/misc/should-block-instance.js"; import type { CacheableRemoteUser } from "@/models/entities/user.js"; +import { Notes } from "@/models/index.js"; +import post from "@/services/note/create.js"; +import { parseAudience } from "../../audience.js"; +import { apLogger } from "../../logger.js"; +import { fetchNote, resolveNote } from "../../models/note.js"; +import type Resolver from "../../resolver.js"; import type { IAnnounce } from "../../type.js"; import { getApId } from "../../type.js"; -import { fetchNote, resolveNote } from "../../models/note.js"; -import { apLogger } from "../../logger.js"; -import { extractDbHost } from "@/misc/convert-host.js"; -import { getApLock } from "@/misc/app-lock.js"; -import { parseAudience } from "../../audience.js"; -import { StatusError } from "@/misc/fetch.js"; -import { Notes } from "@/models/index.js"; -import { shouldBlockInstance } from "@/misc/should-block-instance.js"; const logger = apLogger; diff --git a/packages/backend/src/remote/activitypub/kernel/block/index.ts b/packages/backend/src/remote/activitypub/kernel/block/index.ts index 4dc868ba..96d11c1a 100644 --- a/packages/backend/src/remote/activitypub/kernel/block/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/block/index.ts @@ -1,8 +1,8 @@ -import type { IBlock } from "../../type.js"; -import block from "@/services/blocking/create.js"; import type { CacheableRemoteUser } from "@/models/entities/user.js"; -import DbResolver from "../../db-resolver.js"; import { Users } from "@/models/index.js"; +import block from "@/services/blocking/create.js"; +import DbResolver from "../../db-resolver.js"; +import type { IBlock } from "../../type.js"; export default async ( actor: CacheableRemoteUser, diff --git a/packages/backend/src/remote/activitypub/kernel/create/index.ts b/packages/backend/src/remote/activitypub/kernel/create/index.ts index 3dcf6482..96dfd676 100644 --- a/packages/backend/src/remote/activitypub/kernel/create/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/create/index.ts @@ -1,10 +1,10 @@ -import Resolver from "../../resolver.js"; import type { CacheableRemoteUser } from "@/models/entities/user.js"; -import createNote from "./note.js"; -import type { ICreate } from "../../type.js"; -import { getApId, isPost, getApType } from "../../type.js"; +import { concat, toArray, unique } from "@/prelude/array.js"; import { apLogger } from "../../logger.js"; -import { toArray, concat, unique } from "@/prelude/array.js"; +import Resolver from "../../resolver.js"; +import type { ICreate } from "../../type.js"; +import { getApId, getApType, isPost } from "../../type.js"; +import createNote from "./note.js"; const logger = apLogger; diff --git a/packages/backend/src/remote/activitypub/kernel/create/note.ts b/packages/backend/src/remote/activitypub/kernel/create/note.ts index 92b0ffb1..f0b3d177 100644 --- a/packages/backend/src/remote/activitypub/kernel/create/note.ts +++ b/packages/backend/src/remote/activitypub/kernel/create/note.ts @@ -1,11 +1,11 @@ -import type Resolver from "../../resolver.js"; -import type { CacheableRemoteUser } from "@/models/entities/user.js"; -import { createNote, fetchNote } from "../../models/note.js"; -import type { IObject, ICreate } from "../../type.js"; -import { getApId } from "../../type.js"; import { getApLock } from "@/misc/app-lock.js"; import { extractDbHost } from "@/misc/convert-host.js"; import { StatusError } from "@/misc/fetch.js"; +import type { CacheableRemoteUser } from "@/models/entities/user.js"; +import { createNote, fetchNote } from "../../models/note.js"; +import type Resolver from "../../resolver.js"; +import type { ICreate, IObject } from "../../type.js"; +import { getApId } from "../../type.js"; /** * Handle post creation activity diff --git a/packages/backend/src/remote/activitypub/kernel/delete/actor.ts b/packages/backend/src/remote/activitypub/kernel/delete/actor.ts index 83c6442d..da896541 100644 --- a/packages/backend/src/remote/activitypub/kernel/delete/actor.ts +++ b/packages/backend/src/remote/activitypub/kernel/delete/actor.ts @@ -1,7 +1,7 @@ -import { apLogger } from "../../logger.js"; -import { createDeleteAccountJob } from "@/queue/index.js"; import type { CacheableRemoteUser } from "@/models/entities/user.js"; import { Users } from "@/models/index.js"; +import { createDeleteAccountJob } from "@/queue/index.js"; +import { apLogger } from "../../logger.js"; const logger = apLogger; diff --git a/packages/backend/src/remote/activitypub/kernel/delete/index.ts b/packages/backend/src/remote/activitypub/kernel/delete/index.ts index f9ad52de..54cc691b 100644 --- a/packages/backend/src/remote/activitypub/kernel/delete/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/delete/index.ts @@ -1,9 +1,9 @@ import type { CacheableRemoteUser } from "@/models/entities/user.js"; import { toSingle } from "@/prelude/array.js"; -import { getApId, isTombstone, validPost, validActor } from "../../type.js"; -import deleteNote from "./note.js"; -import { deleteActor } from "./actor.js"; +import { getApId, isTombstone, validActor, validPost } from "../../type.js"; import type { IDelete, IObject } from "../../type.js"; +import { deleteActor } from "./actor.js"; +import deleteNote from "./note.js"; /** * Handle delete activity diff --git a/packages/backend/src/remote/activitypub/kernel/delete/note.ts b/packages/backend/src/remote/activitypub/kernel/delete/note.ts index 4656480c..273be837 100644 --- a/packages/backend/src/remote/activitypub/kernel/delete/note.ts +++ b/packages/backend/src/remote/activitypub/kernel/delete/note.ts @@ -1,9 +1,9 @@ -import type { CacheableRemoteUser } from "@/models/entities/user.js"; -import deleteNode from "@/services/note/delete.js"; -import { apLogger } from "../../logger.js"; -import DbResolver from "../../db-resolver.js"; import { getApLock } from "@/misc/app-lock.js"; +import type { CacheableRemoteUser } from "@/models/entities/user.js"; import { deleteMessage } from "@/services/messages/delete.js"; +import deleteNode from "@/services/note/delete.js"; +import DbResolver from "../../db-resolver.js"; +import { apLogger } from "../../logger.js"; const logger = apLogger; diff --git a/packages/backend/src/remote/activitypub/kernel/flag/index.ts b/packages/backend/src/remote/activitypub/kernel/flag/index.ts index 39ba8b3f..6e9452d0 100644 --- a/packages/backend/src/remote/activitypub/kernel/flag/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/flag/index.ts @@ -1,10 +1,10 @@ -import type { CacheableRemoteUser } from "@/models/entities/user.js"; import config from "@/config/index.js"; -import type { IFlag } from "../../type.js"; -import { getApIds } from "../../type.js"; +import { genId } from "@/misc/gen-id.js"; +import type { CacheableRemoteUser } from "@/models/entities/user.js"; import { AbuseUserReports, Users } from "@/models/index.js"; import { In } from "typeorm"; -import { genId } from "@/misc/gen-id.js"; +import type { IFlag } from "../../type.js"; +import { getApIds } from "../../type.js"; export default async ( actor: CacheableRemoteUser, diff --git a/packages/backend/src/remote/activitypub/kernel/follow.ts b/packages/backend/src/remote/activitypub/kernel/follow.ts index 1c1ef36c..610608b5 100644 --- a/packages/backend/src/remote/activitypub/kernel/follow.ts +++ b/packages/backend/src/remote/activitypub/kernel/follow.ts @@ -1,7 +1,7 @@ import type { CacheableRemoteUser } from "@/models/entities/user.js"; import follow from "@/services/following/create.js"; -import type { IFollow } from "../type.js"; import DbResolver from "../db-resolver.js"; +import type { IFollow } from "../type.js"; export default async ( actor: CacheableRemoteUser, diff --git a/packages/backend/src/remote/activitypub/kernel/index.ts b/packages/backend/src/remote/activitypub/kernel/index.ts index a90ac023..225c57d4 100644 --- a/packages/backend/src/remote/activitypub/kernel/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/index.ts @@ -1,45 +1,45 @@ -import type { CacheableRemoteUser } from "@/models/entities/user.js"; -import { toArray } from "@/prelude/array.js"; -import { - isCreate, - isDelete, - isUpdate, - isRead, - isFollow, - isAccept, - isReject, - isAdd, - isRemove, - isAnnounce, - isLike, - isUndo, - isBlock, - isCollectionOrOrderedCollection, - isCollection, - isFlag, - isMove, - getApId, -} from "../type.js"; -import { apLogger } from "../logger.js"; -import Resolver from "../resolver.js"; -import create from "./create/index.js"; -import performDeleteActivity from "./delete/index.js"; -import performUpdateActivity from "./update/index.js"; -import { performReadActivity } from "./read.js"; -import follow from "./follow.js"; -import undo from "./undo/index.js"; -import like from "./like.js"; -import announce from "./announce/index.js"; -import accept from "./accept/index.js"; -import reject from "./reject/index.js"; -import add from "./add/index.js"; -import remove from "./remove/index.js"; -import block from "./block/index.js"; -import flag from "./flag/index.js"; -import move from "./move/index.js"; -import type { IObject, IActivity } from "../type.js"; import { extractDbHost } from "@/misc/convert-host.js"; import { shouldBlockInstance } from "@/misc/should-block-instance.js"; +import type { CacheableRemoteUser } from "@/models/entities/user.js"; +import { toArray } from "@/prelude/array.js"; +import { apLogger } from "../logger.js"; +import Resolver from "../resolver.js"; +import { + getApId, + isAccept, + isAdd, + isAnnounce, + isBlock, + isCollection, + isCollectionOrOrderedCollection, + isCreate, + isDelete, + isFlag, + isFollow, + isLike, + isMove, + isRead, + isReject, + isRemove, + isUndo, + isUpdate, +} from "../type.js"; +import type { IActivity, IObject } from "../type.js"; +import accept from "./accept/index.js"; +import add from "./add/index.js"; +import announce from "./announce/index.js"; +import block from "./block/index.js"; +import create from "./create/index.js"; +import performDeleteActivity from "./delete/index.js"; +import flag from "./flag/index.js"; +import follow from "./follow.js"; +import like from "./like.js"; +import move from "./move/index.js"; +import { performReadActivity } from "./read.js"; +import reject from "./reject/index.js"; +import remove from "./remove/index.js"; +import undo from "./undo/index.js"; +import performUpdateActivity from "./update/index.js"; export async function performActivity( actor: CacheableRemoteUser, diff --git a/packages/backend/src/remote/activitypub/kernel/like.ts b/packages/backend/src/remote/activitypub/kernel/like.ts index 7b30d1cd..e4dfe80e 100644 --- a/packages/backend/src/remote/activitypub/kernel/like.ts +++ b/packages/backend/src/remote/activitypub/kernel/like.ts @@ -1,8 +1,8 @@ import type { CacheableRemoteUser } from "@/models/entities/user.js"; +import create from "@/services/note/reaction/create.js"; +import { extractEmojis, fetchNote } from "../models/note.js"; import type { ILike } from "../type.js"; import { getApId } from "../type.js"; -import create from "@/services/note/reaction/create.js"; -import { fetchNote, extractEmojis } from "../models/note.js"; export default async (actor: CacheableRemoteUser, activity: ILike) => { const targetUri = getApId(activity.object); diff --git a/packages/backend/src/remote/activitypub/kernel/read.ts b/packages/backend/src/remote/activitypub/kernel/read.ts index 53fa7fe6..91f3276e 100644 --- a/packages/backend/src/remote/activitypub/kernel/read.ts +++ b/packages/backend/src/remote/activitypub/kernel/read.ts @@ -1,9 +1,9 @@ +import { extractDbHost, isSelfHost } from "@/misc/convert-host.js"; import type { CacheableRemoteUser } from "@/models/entities/user.js"; -import type { IRead } from "../type.js"; -import { getApId } from "../type.js"; -import { isSelfHost, extractDbHost } from "@/misc/convert-host.js"; import { MessagingMessages } from "@/models/index.js"; import { readUserMessagingMessage } from "@/server/api/common/read-messaging-message.js"; +import type { IRead } from "../type.js"; +import { getApId } from "../type.js"; export const performReadActivity = async ( actor: CacheableRemoteUser, diff --git a/packages/backend/src/remote/activitypub/kernel/reject/follow.ts b/packages/backend/src/remote/activitypub/kernel/reject/follow.ts index 670c1556..99438442 100644 --- a/packages/backend/src/remote/activitypub/kernel/reject/follow.ts +++ b/packages/backend/src/remote/activitypub/kernel/reject/follow.ts @@ -1,9 +1,9 @@ import type { CacheableRemoteUser } from "@/models/entities/user.js"; -import { remoteReject } from "@/services/following/reject.js"; -import type { IFollow } from "../../type.js"; -import DbResolver from "../../db-resolver.js"; -import { relayRejected } from "@/services/relay.js"; import { Users } from "@/models/index.js"; +import { remoteReject } from "@/services/following/reject.js"; +import { relayRejected } from "@/services/relay.js"; +import DbResolver from "../../db-resolver.js"; +import type { IFollow } from "../../type.js"; export default async ( actor: CacheableRemoteUser, diff --git a/packages/backend/src/remote/activitypub/kernel/reject/index.ts b/packages/backend/src/remote/activitypub/kernel/reject/index.ts index 10edb0f7..dd5465b0 100644 --- a/packages/backend/src/remote/activitypub/kernel/reject/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/reject/index.ts @@ -1,9 +1,9 @@ -import Resolver from "../../resolver.js"; import type { CacheableRemoteUser } from "@/models/entities/user.js"; -import rejectFollow from "./follow.js"; -import type { IReject } from "../../type.js"; -import { isFollow, getApType } from "../../type.js"; import { apLogger } from "../../logger.js"; +import Resolver from "../../resolver.js"; +import type { IReject } from "../../type.js"; +import { getApType, isFollow } from "../../type.js"; +import rejectFollow from "./follow.js"; const logger = apLogger; diff --git a/packages/backend/src/remote/activitypub/kernel/remove/index.ts b/packages/backend/src/remote/activitypub/kernel/remove/index.ts index 0b4be6b5..f8478b7c 100644 --- a/packages/backend/src/remote/activitypub/kernel/remove/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/remove/index.ts @@ -1,7 +1,7 @@ import type { CacheableRemoteUser } from "@/models/entities/user.js"; -import type { IRemove } from "../../type.js"; -import { resolveNote } from "../../models/note.js"; import { removePinned } from "@/services/i/pin.js"; +import { resolveNote } from "../../models/note.js"; +import type { IRemove } from "../../type.js"; export default async ( actor: CacheableRemoteUser, diff --git a/packages/backend/src/remote/activitypub/kernel/undo/accept.ts b/packages/backend/src/remote/activitypub/kernel/undo/accept.ts index 7cf45704..6e336619 100644 --- a/packages/backend/src/remote/activitypub/kernel/undo/accept.ts +++ b/packages/backend/src/remote/activitypub/kernel/undo/accept.ts @@ -1,8 +1,8 @@ -import unfollow from "@/services/following/delete.js"; -import type { IAccept } from "../../type.js"; import type { CacheableRemoteUser } from "@/models/entities/user.js"; import { Followings } from "@/models/index.js"; +import unfollow from "@/services/following/delete.js"; import DbResolver from "../../db-resolver.js"; +import type { IAccept } from "../../type.js"; export default async ( actor: CacheableRemoteUser, diff --git a/packages/backend/src/remote/activitypub/kernel/undo/announce.ts b/packages/backend/src/remote/activitypub/kernel/undo/announce.ts index a6e9c88c..121e73ce 100644 --- a/packages/backend/src/remote/activitypub/kernel/undo/announce.ts +++ b/packages/backend/src/remote/activitypub/kernel/undo/announce.ts @@ -1,8 +1,8 @@ -import { Notes } from "@/models/index.js"; import type { CacheableRemoteUser } from "@/models/entities/user.js"; +import { Notes } from "@/models/index.js"; +import deleteNote from "@/services/note/delete.js"; import type { IAnnounce } from "../../type.js"; import { getApId } from "../../type.js"; -import deleteNote from "@/services/note/delete.js"; export const undoAnnounce = async ( actor: CacheableRemoteUser, diff --git a/packages/backend/src/remote/activitypub/kernel/undo/block.ts b/packages/backend/src/remote/activitypub/kernel/undo/block.ts index b4e1d8ee..302edbad 100644 --- a/packages/backend/src/remote/activitypub/kernel/undo/block.ts +++ b/packages/backend/src/remote/activitypub/kernel/undo/block.ts @@ -1,8 +1,8 @@ -import type { IBlock } from "../../type.js"; -import unblock from "@/services/blocking/delete.js"; import type { CacheableRemoteUser } from "@/models/entities/user.js"; -import DbResolver from "../../db-resolver.js"; import { Users } from "@/models/index.js"; +import unblock from "@/services/blocking/delete.js"; +import DbResolver from "../../db-resolver.js"; +import type { IBlock } from "../../type.js"; export default async ( actor: CacheableRemoteUser, diff --git a/packages/backend/src/remote/activitypub/kernel/undo/follow.ts b/packages/backend/src/remote/activitypub/kernel/undo/follow.ts index 1c4648cf..9bc77286 100644 --- a/packages/backend/src/remote/activitypub/kernel/undo/follow.ts +++ b/packages/backend/src/remote/activitypub/kernel/undo/follow.ts @@ -1,9 +1,9 @@ -import unfollow from "@/services/following/delete.js"; -import cancelRequest from "@/services/following/requests/cancel.js"; -import type { IFollow } from "../../type.js"; import type { CacheableRemoteUser } from "@/models/entities/user.js"; import { FollowRequests, Followings } from "@/models/index.js"; +import unfollow from "@/services/following/delete.js"; +import cancelRequest from "@/services/following/requests/cancel.js"; import DbResolver from "../../db-resolver.js"; +import type { IFollow } from "../../type.js"; export default async ( actor: CacheableRemoteUser, diff --git a/packages/backend/src/remote/activitypub/kernel/undo/index.ts b/packages/backend/src/remote/activitypub/kernel/undo/index.ts index f0e2316f..b8f1db9b 100644 --- a/packages/backend/src/remote/activitypub/kernel/undo/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/undo/index.ts @@ -1,20 +1,20 @@ import type { CacheableRemoteUser } from "@/models/entities/user.js"; +import { apLogger } from "../../logger.js"; +import Resolver from "../../resolver.js"; import type { IUndo } from "../../type.js"; import { - isFollow, - isBlock, - isLike, - isAnnounce, getApType, isAccept, + isAnnounce, + isBlock, + isFollow, + isLike, } from "../../type.js"; -import unfollow from "./follow.js"; -import unblock from "./block.js"; -import undoLike from "./like.js"; import undoAccept from "./accept.js"; import { undoAnnounce } from "./announce.js"; -import Resolver from "../../resolver.js"; -import { apLogger } from "../../logger.js"; +import unblock from "./block.js"; +import unfollow from "./follow.js"; +import undoLike from "./like.js"; const logger = apLogger; diff --git a/packages/backend/src/remote/activitypub/kernel/undo/like.ts b/packages/backend/src/remote/activitypub/kernel/undo/like.ts index 90220e20..b32983be 100644 --- a/packages/backend/src/remote/activitypub/kernel/undo/like.ts +++ b/packages/backend/src/remote/activitypub/kernel/undo/like.ts @@ -1,8 +1,8 @@ import type { CacheableRemoteUser } from "@/models/entities/user.js"; -import type { ILike } from "../../type.js"; -import { getApId } from "../../type.js"; import deleteReaction from "@/services/note/reaction/delete.js"; import { fetchNote } from "../../models/note.js"; +import type { ILike } from "../../type.js"; +import { getApId } from "../../type.js"; /** * Process Undo.Like activity diff --git a/packages/backend/src/remote/activitypub/kernel/update/index.ts b/packages/backend/src/remote/activitypub/kernel/update/index.ts index 558a20ce..cf1e9627 100644 --- a/packages/backend/src/remote/activitypub/kernel/update/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/update/index.ts @@ -1,10 +1,10 @@ import type { CacheableRemoteUser } from "@/models/entities/user.js"; -import type { IUpdate } from "../../type.js"; -import { getApType, isActor } from "../../type.js"; import { apLogger } from "../../logger.js"; import { updateNote } from "../../models/note.js"; -import Resolver from "../../resolver.js"; import { updatePerson } from "../../models/person.js"; +import Resolver from "../../resolver.js"; +import type { IUpdate } from "../../type.js"; +import { getApType, isActor } from "../../type.js"; /** * Handler for the Update activity @@ -37,12 +37,13 @@ export default async ( case "Note": case "Article": case "Document": - case "Page": + case "Page": { let failed = false; await updateNote(object, resolver).catch((e: Error) => { failed = true; }); return failed ? "skip: Note update failed" : "ok: Note updated"; + } default: return `skip: Unknown type: ${objectType}`; diff --git a/packages/backend/src/remote/activitypub/misc/get-note-html.ts b/packages/backend/src/remote/activitypub/misc/get-note-html.ts index 7521d121..2c04fca9 100644 --- a/packages/backend/src/remote/activitypub/misc/get-note-html.ts +++ b/packages/backend/src/remote/activitypub/misc/get-note-html.ts @@ -1,6 +1,6 @@ -import * as mfm from "mfm-js"; -import type { Note } from "@/models/entities/note.js"; import { toHtml } from "@/mfm/to-html.js"; +import type { Note } from "@/models/entities/note.js"; +import * as mfm from "mfm-js"; export default function (note: Note) { if (!note.text) return ""; diff --git a/packages/backend/src/remote/activitypub/misc/html-to-mfm.ts b/packages/backend/src/remote/activitypub/misc/html-to-mfm.ts index f18958f7..80669fea 100644 --- a/packages/backend/src/remote/activitypub/misc/html-to-mfm.ts +++ b/packages/backend/src/remote/activitypub/misc/html-to-mfm.ts @@ -1,6 +1,6 @@ -import type { IObject } from "../type.js"; -import { extractApHashtagObjects } from "../models/tag.js"; import { fromHtml } from "@/mfm/from-html.js"; +import { extractApHashtagObjects } from "../models/tag.js"; +import type { IObject } from "../type.js"; export function htmlToMfm(html: string, tag?: IObject | IObject[]) { const hashtagNames = extractApHashtagObjects(tag) diff --git a/packages/backend/src/remote/activitypub/misc/ld-signature.ts b/packages/backend/src/remote/activitypub/misc/ld-signature.ts index 62707624..66a8c7d7 100644 --- a/packages/backend/src/remote/activitypub/misc/ld-signature.ts +++ b/packages/backend/src/remote/activitypub/misc/ld-signature.ts @@ -1,8 +1,8 @@ import * as crypto from "node:crypto"; -import jsonld from "jsonld"; -import { CONTEXTS } from "./contexts.js"; -import fetch from "node-fetch"; import { httpAgent, httpsAgent } from "@/misc/fetch.js"; +import jsonld from "jsonld"; +import fetch from "node-fetch"; +import { CONTEXTS } from "./contexts.js"; // RsaSignature2017 based from https://github.com/transmute-industries/RsaSignature2017 @@ -68,13 +68,13 @@ export class LdSignature { ...options, "@context": "https://w3id.org/identity/v1", }; - delete transformedOptions["type"]; - delete transformedOptions["id"]; - delete transformedOptions["signatureValue"]; + transformedOptions.type = undefined; + transformedOptions.id = undefined; + transformedOptions.signatureValue = undefined; const canonizedOptions = await this.normalize(transformedOptions); const optionsHash = this.sha256(canonizedOptions); const transformedData = { ...data }; - delete transformedData["signature"]; + transformedData.signature = undefined; const cannonidedData = await this.normalize(transformedData); if (this.debug) console.debug(`cannonidedData: ${cannonidedData}`); const documentHash = this.sha256(cannonidedData); diff --git a/packages/backend/src/remote/activitypub/models/image.ts b/packages/backend/src/remote/activitypub/models/image.ts index 2cf0c6c1..36eeda36 100644 --- a/packages/backend/src/remote/activitypub/models/image.ts +++ b/packages/backend/src/remote/activitypub/models/image.ts @@ -1,12 +1,12 @@ -import { uploadFromUrl } from "@/services/drive/upload-from-url.js"; -import type { CacheableRemoteUser } from "@/models/entities/user.js"; -import Resolver from "../resolver.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; -import { apLogger } from "../logger.js"; -import type { DriveFile } from "@/models/entities/drive-file.js"; -import { DriveFiles } from "@/models/index.js"; -import { truncate } from "@/misc/truncate.js"; import { DB_MAX_IMAGE_COMMENT_LENGTH } from "@/misc/hard-limits.js"; +import { truncate } from "@/misc/truncate.js"; +import type { DriveFile } from "@/models/entities/drive-file.js"; +import type { CacheableRemoteUser } from "@/models/entities/user.js"; +import { DriveFiles } from "@/models/index.js"; +import { uploadFromUrl } from "@/services/drive/upload-from-url.js"; +import { apLogger } from "../logger.js"; +import Resolver from "../resolver.js"; const logger = apLogger; diff --git a/packages/backend/src/remote/activitypub/models/mention.ts b/packages/backend/src/remote/activitypub/models/mention.ts index e9f80bc4..4f7ff669 100644 --- a/packages/backend/src/remote/activitypub/models/mention.ts +++ b/packages/backend/src/remote/activitypub/models/mention.ts @@ -1,9 +1,9 @@ -import promiseLimit from "promise-limit"; -import { toArray, unique } from "@/prelude/array.js"; import type { CacheableUser } from "@/models/entities/user.js"; -import type { IObject, IApMention } from "../type.js"; -import { isMention } from "../type.js"; +import { toArray, unique } from "@/prelude/array.js"; +import promiseLimit from "promise-limit"; import Resolver from "../resolver.js"; +import type { IApMention, IObject } from "../type.js"; +import { isMention } from "../type.js"; import { resolvePerson } from "./person.js"; export async function extractApMentions( diff --git a/packages/backend/src/remote/activitypub/models/note.ts b/packages/backend/src/remote/activitypub/models/note.ts index d9eedb30..a5fece42 100644 --- a/packages/backend/src/remote/activitypub/models/note.ts +++ b/packages/backend/src/remote/activitypub/models/note.ts @@ -1,55 +1,55 @@ -import promiseLimit from "promise-limit"; -import * as mfm from "mfm-js"; import config from "@/config/index.js"; -import Resolver from "../resolver.js"; +import { getApLock } from "@/misc/app-lock.js"; +import { extractDbHost, toPuny } from "@/misc/convert-host.js"; +import { type Size, getEmojiSize } from "@/misc/emoji-meta.js"; +import { extractHashtags } from "@/misc/extract-hashtags.js"; +import { StatusError } from "@/misc/fetch.js"; +import { genId } from "@/misc/gen-id.js"; +import { DB_MAX_IMAGE_COMMENT_LENGTH } from "@/misc/hard-limits.js"; +import { langmap } from "@/misc/langmap.js"; +import { shouldBlockInstance } from "@/misc/should-block-instance.js"; +import { truncate } from "@/misc/truncate.js"; +import { DriveFile } from "@/models/entities/drive-file.js"; +import type { Emoji } from "@/models/entities/emoji.js"; +import type { IMentionedRemoteUsers, Note } from "@/models/entities/note.js"; +import type { CacheableRemoteUser } from "@/models/entities/user.js"; +import { + DriveFiles, + Emojis, + MessagingMessages, + NoteEdits, + Notes, + Polls, +} from "@/models/index.js"; +import { UserProfiles } from "@/models/index.js"; +import { toArray, toSingle, unique } from "@/prelude/array.js"; +import { createMessage } from "@/services/messages/create.js"; import post from "@/services/note/create.js"; import { extractMentionedUsers } from "@/services/note/create.js"; -import { resolvePerson } from "./person.js"; -import { resolveImage } from "./image.js"; -import type { CacheableRemoteUser } from "@/models/entities/user.js"; -import { htmlToMfm } from "../misc/html-to-mfm.js"; -import { extractApHashtags } from "./tag.js"; -import { unique, toArray, toSingle } from "@/prelude/array.js"; -import { extractPollFromQuestion } from "./question.js"; import vote from "@/services/note/polls/vote.js"; +import { publishNoteStream } from "@/services/stream.js"; +import * as mfm from "mfm-js"; +import promiseLimit from "promise-limit"; +import { In } from "typeorm"; +import { parseAudience } from "../audience.js"; +import DbResolver from "../db-resolver.js"; import { apLogger } from "../logger.js"; -import { DriveFile } from "@/models/entities/drive-file.js"; -import { extractDbHost, toPuny } from "@/misc/convert-host.js"; -import { - Emojis, - Polls, - MessagingMessages, - Notes, - NoteEdits, - DriveFiles, -} from "@/models/index.js"; -import type { IMentionedRemoteUsers, Note } from "@/models/entities/note.js"; +import { htmlToMfm } from "../misc/html-to-mfm.js"; +import Resolver from "../resolver.js"; import type { IObject, IPost } from "../type.js"; import { - getOneApId, getApId, - getOneApHrefNullable, - validPost, - isEmoji, getApType, + getOneApHrefNullable, + getOneApId, + isEmoji, + validPost, } from "../type.js"; -import type { Emoji } from "@/models/entities/emoji.js"; -import { genId } from "@/misc/gen-id.js"; -import { getApLock } from "@/misc/app-lock.js"; -import { createMessage } from "@/services/messages/create.js"; -import { parseAudience } from "../audience.js"; +import { resolveImage } from "./image.js"; import { extractApMentions } from "./mention.js"; -import DbResolver from "../db-resolver.js"; -import { StatusError } from "@/misc/fetch.js"; -import { shouldBlockInstance } from "@/misc/should-block-instance.js"; -import { publishNoteStream } from "@/services/stream.js"; -import { extractHashtags } from "@/misc/extract-hashtags.js"; -import { UserProfiles } from "@/models/index.js"; -import { In } from "typeorm"; -import { DB_MAX_IMAGE_COMMENT_LENGTH } from "@/misc/hard-limits.js"; -import { truncate } from "@/misc/truncate.js"; -import { type Size, getEmojiSize } from "@/misc/emoji-meta.js"; -import { langmap } from "@/misc/langmap.js"; +import { resolvePerson } from "./person.js"; +import { extractPollFromQuestion } from "./question.js"; +import { extractApHashtags } from "./tag.js"; const logger = apLogger; @@ -464,7 +464,7 @@ export async function extractEmojis( return await Promise.all( eomjiTags.map(async (tag) => { - const name = tag.name!.replace(/^:/, "").replace(/:$/, ""); + const name = tag.name?.replace(/^:/, "").replace(/:$/, ""); tag.icon = toSingle(tag.icon); const exists = await Emojis.findOneBy({ @@ -479,12 +479,12 @@ export async function extractEmojis( (tag.updated != null && exists.updatedAt != null && new Date(tag.updated) > exists.updatedAt) || - tag.icon!.url !== exists.originalUrl || + tag.icon?.url !== exists.originalUrl || !(exists.width && exists.height) ) { let size: Size = { width: 0, height: 0 }; try { - size = await getEmojiSize(tag.icon!.url); + size = await getEmojiSize(tag.icon?.url); } catch { /* skip if any error happens */ } @@ -495,8 +495,8 @@ export async function extractEmojis( }, { uri: tag.id, - originalUrl: tag.icon!.url, - publicUrl: tag.icon!.url, + originalUrl: tag.icon?.url, + publicUrl: tag.icon?.url, updatedAt: new Date(), width: size.width || null, height: size.height || null, @@ -516,7 +516,7 @@ export async function extractEmojis( let size: Size = { width: 0, height: 0 }; try { - size = await getEmojiSize(tag.icon!.url); + size = await getEmojiSize(tag.icon?.url); } catch { /* skip if any error happens */ } @@ -525,8 +525,8 @@ export async function extractEmojis( host, name, uri: tag.id, - originalUrl: tag.icon!.url, - publicUrl: tag.icon!.url, + originalUrl: tag.icon?.url, + publicUrl: tag.icon?.url, updatedAt: new Date(), aliases: [], width: size.width || null, diff --git a/packages/backend/src/remote/activitypub/models/person.ts b/packages/backend/src/remote/activitypub/models/person.ts index a5a74700..f6fe04f5 100644 --- a/packages/backend/src/remote/activitypub/models/person.ts +++ b/packages/backend/src/remote/activitypub/models/person.ts @@ -2,50 +2,50 @@ import { URL } from "node:url"; import promiseLimit from "promise-limit"; import config from "@/config/index.js"; -import { registerOrFetchInstanceDoc } from "@/services/register-or-fetch-instance-doc.js"; -import type { Note } from "@/models/entities/note.js"; -import { updateUsertags } from "@/services/update-hashtag.js"; -import { - Users, - Instances, - Followings, - UserProfiles, - UserPublickeys, -} from "@/models/index.js"; -import type { IRemoteUser, CacheableUser } from "@/models/entities/user.js"; -import { User } from "@/models/entities/user.js"; -import type { Emoji } from "@/models/entities/emoji.js"; -import { UserNotePining } from "@/models/entities/user-note-pining.js"; -import { genId } from "@/misc/gen-id.js"; -import { UserPublickey } from "@/models/entities/user-publickey.js"; -import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; +import { db } from "@/db/postgre.js"; +import { fromHtml } from "@/mfm/from-html.js"; import { toPuny } from "@/misc/convert-host.js"; -import { UserProfile } from "@/models/entities/user-profile.js"; -import { toArray } from "@/prelude/array.js"; -import { fetchInstanceMetadata } from "@/services/fetch-instance-metadata.js"; +import { StatusError } from "@/misc/fetch.js"; +import { genId } from "@/misc/gen-id.js"; +import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; import { normalizeForSearch } from "@/misc/normalize-for-search.js"; import { truncate } from "@/misc/truncate.js"; -import { StatusError } from "@/misc/fetch.js"; -import { uriPersonCache } from "@/services/user-cache.js"; +import type { Emoji } from "@/models/entities/emoji.js"; +import type { Note } from "@/models/entities/note.js"; +import { UserNotePining } from "@/models/entities/user-note-pining.js"; +import { UserProfile } from "@/models/entities/user-profile.js"; +import { UserPublickey } from "@/models/entities/user-publickey.js"; +import type { CacheableUser, IRemoteUser } from "@/models/entities/user.js"; +import { User } from "@/models/entities/user.js"; +import { + Followings, + Instances, + UserProfiles, + UserPublickeys, + Users, +} from "@/models/index.js"; +import { toArray } from "@/prelude/array.js"; +import { fetchInstanceMetadata } from "@/services/fetch-instance-metadata.js"; +import { registerOrFetchInstanceDoc } from "@/services/register-or-fetch-instance-doc.js"; import { publishInternalEvent } from "@/services/stream.js"; -import { db } from "@/db/postgre.js"; +import { updateUsertags } from "@/services/update-hashtag.js"; +import { uriPersonCache } from "@/services/user-cache.js"; import { apLogger } from "../logger.js"; import { htmlToMfm } from "../misc/html-to-mfm.js"; -import { fromHtml } from "@/mfm/from-html.js"; +import Resolver from "../resolver.js"; import type { IActor, IObject } from "../type.js"; import { - isCollectionOrOrderedCollection, - isCollection, getApId, - getOneApHrefNullable, - isPropertyValue, getApType, + getOneApHrefNullable, isActor, + isCollection, + isCollectionOrOrderedCollection, + isPropertyValue, } from "../type.js"; -import Resolver from "../resolver.js"; -import { extractApHashtags } from "./tag.js"; -import { resolveNote, extractEmojis } from "./note.js"; import { resolveImage } from "./image.js"; +import { extractEmojis, resolveNote } from "./note.js"; +import { extractApHashtags } from "./tag.js"; const logger = apLogger; @@ -262,7 +262,7 @@ export async function createPerson( alsoKnownAs: person.alsoKnownAs, isExplorable: !!person.discoverable, username: person.preferredUsername, - usernameLower: person.preferredUsername!.toLowerCase(), + usernameLower: person.preferredUsername?.toLowerCase(), host, inbox: person.inbox, sharedInbox: @@ -374,7 +374,7 @@ export async function createPerson( const avatarId = avatar ? avatar.id : null; const bannerId = banner ? banner.id : null; - await Users.update(user!.id, { + await Users.update(user?.id, { avatarId, bannerId, }); @@ -391,12 +391,12 @@ export async function createPerson( const emojiNames = emojis.map((emoji) => emoji.name); - await Users.update(user!.id, { + await Users.update(user?.id, { emojis: emojiNames, }); //#endregion - await updateFeatured(user!.id, resolver).catch((err) => logger.error(err)); + await updateFeatured(user?.id, resolver).catch((err) => logger.error(err)); return user!; } @@ -471,10 +471,10 @@ export async function updatePerson( if (typeof person.followers === "string") { try { - let data = await fetch(person.followers, { + const data = await fetch(person.followers, { headers: { Accept: "application/json" }, }); - let json_data = JSON.parse(await data.text()); + const json_data = JSON.parse(await data.text()); followersCount = json_data.totalItems; } catch { @@ -486,10 +486,10 @@ export async function updatePerson( if (typeof person.following === "string") { try { - let data = await fetch(person.following, { + const data = await fetch(person.following, { headers: { Accept: "application/json" }, }); - let json_data = JSON.parse(await data.text()); + const json_data = JSON.parse(await data.text()); followingCount = json_data.totalItems; } catch { @@ -501,10 +501,10 @@ export async function updatePerson( if (typeof person.outbox === "string") { try { - let data = await fetch(person.outbox, { + const data = await fetch(person.outbox, { headers: { Accept: "application/json" }, }); - let json_data = JSON.parse(await data.text()); + const json_data = JSON.parse(await data.text()); notesCount = json_data.totalItems; } catch (e) { @@ -703,7 +703,7 @@ export async function updateFeatured(userId: User["id"], resolver?: Resolver) { id: genId(new Date(Date.now() + td)), createdAt: new Date(), userId: user.id, - noteId: note!.id, + noteId: note?.id, }); } }); diff --git a/packages/backend/src/remote/activitypub/models/question.ts b/packages/backend/src/remote/activitypub/models/question.ts index f5855c3e..c037bda7 100644 --- a/packages/backend/src/remote/activitypub/models/question.ts +++ b/packages/backend/src/remote/activitypub/models/question.ts @@ -1,10 +1,10 @@ import config from "@/config/index.js"; +import type { IPoll } from "@/models/entities/poll.js"; +import { Notes, Polls } from "@/models/index.js"; +import { apLogger } from "../logger.js"; import Resolver from "../resolver.js"; import type { IObject, IQuestion } from "../type.js"; import { getApId, isQuestion } from "../type.js"; -import { apLogger } from "../logger.js"; -import { Notes, Polls } from "@/models/index.js"; -import type { IPoll } from "@/models/entities/poll.js"; export async function extractPollFromQuestion( source: string | IObject, @@ -29,11 +29,11 @@ export async function extractPollFromQuestion( throw new Error("invalid question"); } - const choices = question[multiple ? "anyOf" : "oneOf"]!.map( + const choices = question[multiple ? "anyOf" : "oneOf"]?.map( (x, i) => x.name!, ); - const votes = question[multiple ? "anyOf" : "oneOf"]!.map( + const votes = question[multiple ? "anyOf" : "oneOf"]?.map( (x, i) => x.replies?.totalItems || x._misskey_votes || 0, ); diff --git a/packages/backend/src/remote/activitypub/models/tag.ts b/packages/backend/src/remote/activitypub/models/tag.ts index 537cdecb..2a8cbef3 100644 --- a/packages/backend/src/remote/activitypub/models/tag.ts +++ b/packages/backend/src/remote/activitypub/models/tag.ts @@ -1,5 +1,5 @@ import { toArray } from "@/prelude/array.js"; -import type { IObject, IApHashtag } from "../type.js"; +import type { IApHashtag, IObject } from "../type.js"; import { isHashtag } from "../type.js"; export function extractApHashtags( diff --git a/packages/backend/src/remote/activitypub/perform.ts b/packages/backend/src/remote/activitypub/perform.ts index 0d2cdb4a..9bb231b9 100644 --- a/packages/backend/src/remote/activitypub/perform.ts +++ b/packages/backend/src/remote/activitypub/perform.ts @@ -1,7 +1,7 @@ -import type { IObject } from "./type.js"; import type { CacheableRemoteUser } from "@/models/entities/user.js"; import { performActivity } from "./kernel/index.js"; import { updatePerson } from "./models/person.js"; +import type { IObject } from "./type.js"; export default async ( actor: CacheableRemoteUser, diff --git a/packages/backend/src/remote/activitypub/renderer/follow-user.ts b/packages/backend/src/remote/activitypub/renderer/follow-user.ts index 22ee429f..e99eb283 100644 --- a/packages/backend/src/remote/activitypub/renderer/follow-user.ts +++ b/packages/backend/src/remote/activitypub/renderer/follow-user.ts @@ -1,6 +1,6 @@ import config from "@/config/index.js"; -import { Users } from "@/models/index.js"; import type { User } from "@/models/entities/user.js"; +import { Users } from "@/models/index.js"; /** * Convert (local|remote)(Follower|Followee)ID to URL diff --git a/packages/backend/src/remote/activitypub/renderer/index.ts b/packages/backend/src/remote/activitypub/renderer/index.ts index c60a1f4c..16d36bb9 100644 --- a/packages/backend/src/remote/activitypub/renderer/index.ts +++ b/packages/backend/src/remote/activitypub/renderer/index.ts @@ -1,7 +1,7 @@ -import { v4 as uuid } from "uuid"; import config from "@/config/index.js"; import { getUserKeypair } from "@/misc/keypair-store.js"; import type { User } from "@/models/entities/user.js"; +import { v4 as uuid } from "uuid"; import { LdSignature } from "../misc/ld-signature.js"; import type { IActivity } from "../type.js"; diff --git a/packages/backend/src/remote/activitypub/renderer/key.ts b/packages/backend/src/remote/activitypub/renderer/key.ts index 084bb536..3a1b4794 100644 --- a/packages/backend/src/remote/activitypub/renderer/key.ts +++ b/packages/backend/src/remote/activitypub/renderer/key.ts @@ -1,7 +1,7 @@ -import config from "@/config/index.js"; -import type { ILocalUser } from "@/models/entities/user.js"; -import type { UserKeypair } from "@/models/entities/user-keypair.js"; import { createPublicKey } from "node:crypto"; +import config from "@/config/index.js"; +import type { UserKeypair } from "@/models/entities/user-keypair.js"; +import type { ILocalUser } from "@/models/entities/user.js"; export default (user: ILocalUser, key: UserKeypair, postfix?: string) => ({ id: `${config.url}/users/${user.id}${postfix || "/publickey"}`, diff --git a/packages/backend/src/remote/activitypub/renderer/like.ts b/packages/backend/src/remote/activitypub/renderer/like.ts index 6f810cd2..7b3acd4d 100644 --- a/packages/backend/src/remote/activitypub/renderer/like.ts +++ b/packages/backend/src/remote/activitypub/renderer/like.ts @@ -1,8 +1,8 @@ -import { IsNull } from "typeorm"; import config from "@/config/index.js"; import type { NoteReaction } from "@/models/entities/note-reaction.js"; import type { Note } from "@/models/entities/note.js"; import { Emojis } from "@/models/index.js"; +import { IsNull } from "typeorm"; import renderEmoji from "./emoji.js"; export const renderLike = async (noteReaction: NoteReaction, note: Note) => { diff --git a/packages/backend/src/remote/activitypub/renderer/mention.ts b/packages/backend/src/remote/activitypub/renderer/mention.ts index e7f0435c..a598b804 100644 --- a/packages/backend/src/remote/activitypub/renderer/mention.ts +++ b/packages/backend/src/remote/activitypub/renderer/mention.ts @@ -1,5 +1,5 @@ import config from "@/config/index.js"; -import type { User, ILocalUser } from "@/models/entities/user.js"; +import type { ILocalUser, User } from "@/models/entities/user.js"; import { Users } from "@/models/index.js"; export default (mention: User) => ({ diff --git a/packages/backend/src/remote/activitypub/renderer/note.ts b/packages/backend/src/remote/activitypub/renderer/note.ts index b840e2d6..2f74d1f8 100644 --- a/packages/backend/src/remote/activitypub/renderer/note.ts +++ b/packages/backend/src/remote/activitypub/renderer/note.ts @@ -1,16 +1,16 @@ -import { In, IsNull } from "typeorm"; import config from "@/config/index.js"; -import type { Note, IMentionedRemoteUsers } from "@/models/entities/note.js"; -import type { DriveFile } from "@/models/entities/drive-file.js"; -import { DriveFiles, Notes, Users, Emojis, Polls } from "@/models/index.js"; -import type { Emoji } from "@/models/entities/emoji.js"; -import type { Poll } from "@/models/entities/poll.js"; -import toHtml from "@/remote/activitypub/misc/get-note-html.js"; import detectLanguage from "@/misc/detect-language.js"; -import renderEmoji from "./emoji.js"; -import renderMention from "./mention.js"; -import renderHashtag from "./hashtag.js"; +import type { DriveFile } from "@/models/entities/drive-file.js"; +import type { Emoji } from "@/models/entities/emoji.js"; +import type { IMentionedRemoteUsers, Note } from "@/models/entities/note.js"; +import type { Poll } from "@/models/entities/poll.js"; +import { DriveFiles, Emojis, Notes, Polls, Users } from "@/models/index.js"; +import toHtml from "@/remote/activitypub/misc/get-note-html.js"; +import { In, IsNull } from "typeorm"; import renderDocument from "./document.js"; +import renderEmoji from "./emoji.js"; +import renderHashtag from "./hashtag.js"; +import renderMention from "./mention.js"; export default async function renderNote( note: Note, @@ -142,7 +142,7 @@ export default async function renderNote( name: text, replies: { type: "Collection", - totalItems: poll!.votes[i], + totalItems: poll?.votes[i], }, })), } diff --git a/packages/backend/src/remote/activitypub/renderer/person.ts b/packages/backend/src/remote/activitypub/renderer/person.ts index db176a0d..637693e0 100644 --- a/packages/backend/src/remote/activitypub/renderer/person.ts +++ b/packages/backend/src/remote/activitypub/renderer/person.ts @@ -1,16 +1,16 @@ import { URL } from "node:url"; -import * as mfm from "mfm-js"; import config from "@/config/index.js"; +import { getUserKeypair } from "@/misc/keypair-store.js"; import type { ILocalUser } from "@/models/entities/user.js"; import { DriveFiles, UserProfiles } from "@/models/index.js"; -import { getUserKeypair } from "@/misc/keypair-store.js"; +import * as mfm from "mfm-js"; import { toHtml } from "../../../mfm/to-html.js"; +import type { IIdentifier } from "../models/identifier.js"; +import renderEmoji from "./emoji.js"; +import renderHashtag from "./hashtag.js"; import renderImage from "./image.js"; import renderKey from "./key.js"; import { getEmojis } from "./note.js"; -import renderEmoji from "./emoji.js"; -import renderHashtag from "./hashtag.js"; -import type { IIdentifier } from "../models/identifier.js"; export async function renderPerson(user: ILocalUser) { const id = `${config.url}/users/${user.id}`; diff --git a/packages/backend/src/remote/activitypub/renderer/question.ts b/packages/backend/src/remote/activitypub/renderer/question.ts index cb89aa75..7ca99587 100644 --- a/packages/backend/src/remote/activitypub/renderer/question.ts +++ b/packages/backend/src/remote/activitypub/renderer/question.ts @@ -1,7 +1,7 @@ import config from "@/config/index.js"; -import type { User } from "@/models/entities/user.js"; import type { Note } from "@/models/entities/note.js"; import type { Poll } from "@/models/entities/poll.js"; +import type { User } from "@/models/entities/user.js"; export default async function renderQuestion( user: { id: User["id"] }, diff --git a/packages/backend/src/remote/activitypub/renderer/read.ts b/packages/backend/src/remote/activitypub/renderer/read.ts index 212e7e8d..cc90ecc7 100644 --- a/packages/backend/src/remote/activitypub/renderer/read.ts +++ b/packages/backend/src/remote/activitypub/renderer/read.ts @@ -1,6 +1,6 @@ import config from "@/config/index.js"; -import type { User } from "@/models/entities/user.js"; import type { MessagingMessage } from "@/models/entities/messaging-message.js"; +import type { User } from "@/models/entities/user.js"; export const renderReadActivity = ( user: { id: User["id"] }, diff --git a/packages/backend/src/remote/activitypub/renderer/vote.ts b/packages/backend/src/remote/activitypub/renderer/vote.ts index 21234a11..491a8ffa 100644 --- a/packages/backend/src/remote/activitypub/renderer/vote.ts +++ b/packages/backend/src/remote/activitypub/renderer/vote.ts @@ -1,8 +1,8 @@ import config from "@/config/index.js"; import type { Note } from "@/models/entities/note.js"; -import type { IRemoteUser, User } from "@/models/entities/user.js"; import type { PollVote } from "@/models/entities/poll-vote.js"; import type { Poll } from "@/models/entities/poll.js"; +import type { IRemoteUser, User } from "@/models/entities/user.js"; export default async function renderVote( user: { id: User["id"] }, diff --git a/packages/backend/src/remote/activitypub/request.ts b/packages/backend/src/remote/activitypub/request.ts index 69c97a44..0dce4a21 100644 --- a/packages/backend/src/remote/activitypub/request.ts +++ b/packages/backend/src/remote/activitypub/request.ts @@ -1,9 +1,9 @@ import config from "@/config/index.js"; import { getUserKeypair } from "@/misc/keypair-store.js"; import type { User } from "@/models/entities/user.js"; -import { getResponse } from "../../misc/fetch.js"; -import { createSignedPost, createSignedGet } from "./ap-request.js"; import { apLogger } from "@/remote/activitypub/logger.js"; +import { getResponse } from "../../misc/fetch.js"; +import { createSignedGet, createSignedPost } from "./ap-request.js"; export default async (user: { id: User["id"] }, url: string, object: any) => { const body = JSON.stringify(object); diff --git a/packages/backend/src/remote/activitypub/resolver.ts b/packages/backend/src/remote/activitypub/resolver.ts index c4bee109..e487f5ff 100644 --- a/packages/backend/src/remote/activitypub/resolver.ts +++ b/packages/backend/src/remote/activitypub/resolver.ts @@ -1,23 +1,23 @@ import config from "@/config/index.js"; -import { getJson } from "@/misc/fetch.js"; -import type { ILocalUser } from "@/models/entities/user.js"; -import { getInstanceActor } from "@/services/instance-actor.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; import { extractDbHost, isSelfHost } from "@/misc/convert-host.js"; -import { signedGet } from "./request.js"; -import type { IObject, ICollection, IOrderedCollection } from "./type.js"; -import { isCollectionOrOrderedCollection, getApId } from "./type.js"; -import { Notes, NoteReactions, Polls, Users } from "@/models/index.js"; -import { parseUri } from "./db-resolver.js"; -import renderNote from "@/remote/activitypub/renderer/note.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; +import { getJson } from "@/misc/fetch.js"; +import { shouldBlockInstance } from "@/misc/should-block-instance.js"; +import type { ILocalUser } from "@/models/entities/user.js"; +import { NoteReactions, Notes, Polls, Users } from "@/models/index.js"; +import { apLogger } from "@/remote/activitypub/logger.js"; +import renderCreate from "@/remote/activitypub/renderer/create.js"; +import renderFollow from "@/remote/activitypub/renderer/follow.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import { renderLike } from "@/remote/activitypub/renderer/like.js"; +import renderNote from "@/remote/activitypub/renderer/note.js"; import { renderPerson } from "@/remote/activitypub/renderer/person.js"; import renderQuestion from "@/remote/activitypub/renderer/question.js"; -import renderCreate from "@/remote/activitypub/renderer/create.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import renderFollow from "@/remote/activitypub/renderer/follow.js"; -import { shouldBlockInstance } from "@/misc/should-block-instance.js"; -import { apLogger } from "@/remote/activitypub/logger.js"; +import { getInstanceActor } from "@/services/instance-actor.js"; +import { parseUri } from "./db-resolver.js"; +import { signedGet } from "./request.js"; +import type { ICollection, IObject, IOrderedCollection } from "./type.js"; +import { getApId, isCollectionOrOrderedCollection } from "./type.js"; export default class Resolver { private history: Set; diff --git a/packages/backend/src/remote/resolve-user.ts b/packages/backend/src/remote/resolve-user.ts index a6c1e399..4d74418c 100644 --- a/packages/backend/src/remote/resolve-user.ts +++ b/packages/backend/src/remote/resolve-user.ts @@ -1,13 +1,13 @@ import { URL } from "node:url"; +import config from "@/config/index.js"; +import { toPuny } from "@/misc/convert-host.js"; +import type { IRemoteUser, User } from "@/models/entities/user.js"; +import { Users } from "@/models/index.js"; import chalk from "chalk"; import { IsNull } from "typeorm"; -import config from "@/config/index.js"; -import type { User, IRemoteUser } from "@/models/entities/user.js"; -import { Users } from "@/models/index.js"; -import { toPuny } from "@/misc/convert-host.js"; -import webFinger from "./webfinger.js"; import { createPerson, updatePerson } from "./activitypub/models/person.js"; import { remoteLogger } from "./logger.js"; +import webFinger from "./webfinger.js"; const logger = remoteLogger.createSubLogger("resolve-user"); diff --git a/packages/backend/src/server/activitypub.ts b/packages/backend/src/server/activitypub.ts index 337db599..a0b05d02 100644 --- a/packages/backend/src/server/activitypub.ts +++ b/packages/backend/src/server/activitypub.ts @@ -1,35 +1,35 @@ import Router from "@koa/router"; -import json from "koa-json-body"; import httpSignature from "@peertube/http-signature"; +import json from "koa-json-body"; -import { In, IsNull, Not } from "typeorm"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import renderNote from "@/remote/activitypub/renderer/note.js"; -import renderKey from "@/remote/activitypub/renderer/key.js"; -import { renderPerson } from "@/remote/activitypub/renderer/person.js"; -import renderEmoji from "@/remote/activitypub/renderer/emoji.js"; -import { inbox as processInbox } from "@/queue/index.js"; import { isSelfHost } from "@/misc/convert-host.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; +import { getUserKeypair } from "@/misc/keypair-store.js"; +import type { ILocalUser, User } from "@/models/entities/user.js"; import { + Emojis, + FollowRequests, + NoteReactions, Notes, Users, - Emojis, - NoteReactions, - FollowRequests, } from "@/models/index.js"; -import type { ILocalUser, User } from "@/models/entities/user.js"; -import { renderLike } from "@/remote/activitypub/renderer/like.js"; -import { getUserKeypair } from "@/misc/keypair-store.js"; +import { inbox as processInbox } from "@/queue/index.js"; import { checkFetch, getSignatureUser, } from "@/remote/activitypub/check-fetch.js"; -import { getInstanceActor } from "@/services/instance-actor.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import renderEmoji from "@/remote/activitypub/renderer/emoji.js"; import renderFollow from "@/remote/activitypub/renderer/follow.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import renderKey from "@/remote/activitypub/renderer/key.js"; +import { renderLike } from "@/remote/activitypub/renderer/like.js"; +import renderNote from "@/remote/activitypub/renderer/note.js"; +import { renderPerson } from "@/remote/activitypub/renderer/person.js"; +import { getInstanceActor } from "@/services/instance-actor.js"; +import { In, IsNull, Not } from "typeorm"; import Featured from "./activitypub/featured.js"; -import Following from "./activitypub/following.js"; import Followers from "./activitypub/followers.js"; +import Following from "./activitypub/following.js"; import Outbox, { packActivity } from "./activitypub/outbox.js"; import { serverLogger } from "./index.js"; diff --git a/packages/backend/src/server/activitypub/featured.ts b/packages/backend/src/server/activitypub/featured.ts index 82bb19fa..a5131777 100644 --- a/packages/backend/src/server/activitypub/featured.ts +++ b/packages/backend/src/server/activitypub/featured.ts @@ -1,13 +1,13 @@ -import { IsNull } from "typeorm"; import config from "@/config/index.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import renderOrderedCollection from "@/remote/activitypub/renderer/ordered-collection.js"; -import renderNote from "@/remote/activitypub/renderer/note.js"; -import { Users, Notes, UserNotePinings } from "@/models/index.js"; -import { checkFetch } from "@/remote/activitypub/check-fetch.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; -import { setResponseType } from "../activitypub.js"; +import { Notes, UserNotePinings, Users } from "@/models/index.js"; +import { checkFetch } from "@/remote/activitypub/check-fetch.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import renderNote from "@/remote/activitypub/renderer/note.js"; +import renderOrderedCollection from "@/remote/activitypub/renderer/ordered-collection.js"; import type Router from "@koa/router"; +import { IsNull } from "typeorm"; +import { setResponseType } from "../activitypub.js"; export default async (ctx: Router.RouterContext) => { const verify = await checkFetch(ctx.req); diff --git a/packages/backend/src/server/activitypub/followers.ts b/packages/backend/src/server/activitypub/followers.ts index 146ca519..ff5106ef 100644 --- a/packages/backend/src/server/activitypub/followers.ts +++ b/packages/backend/src/server/activitypub/followers.ts @@ -1,17 +1,17 @@ -import { IsNull, LessThan } from "typeorm"; import config from "@/config/index.js"; -import * as url from "@/prelude/url.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import renderOrderedCollection from "@/remote/activitypub/renderer/ordered-collection.js"; -import renderOrderedCollectionPage from "@/remote/activitypub/renderer/ordered-collection-page.js"; -import renderFollowUser from "@/remote/activitypub/renderer/follow-user.js"; -import { Users, Followings, UserProfiles } from "@/models/index.js"; -import type { Following } from "@/models/entities/following.js"; -import { checkFetch } from "@/remote/activitypub/check-fetch.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; -import { setResponseType } from "../activitypub.js"; -import type { FindOptionsWhere } from "typeorm"; +import type { Following } from "@/models/entities/following.js"; +import { Followings, UserProfiles, Users } from "@/models/index.js"; +import * as url from "@/prelude/url.js"; +import { checkFetch } from "@/remote/activitypub/check-fetch.js"; +import renderFollowUser from "@/remote/activitypub/renderer/follow-user.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import renderOrderedCollectionPage from "@/remote/activitypub/renderer/ordered-collection-page.js"; +import renderOrderedCollection from "@/remote/activitypub/renderer/ordered-collection.js"; import type Router from "@koa/router"; +import { IsNull, LessThan } from "typeorm"; +import type { FindOptionsWhere } from "typeorm"; +import { setResponseType } from "../activitypub.js"; export default async (ctx: Router.RouterContext) => { const verify = await checkFetch(ctx.req); diff --git a/packages/backend/src/server/activitypub/following.ts b/packages/backend/src/server/activitypub/following.ts index eab513ce..542925d6 100644 --- a/packages/backend/src/server/activitypub/following.ts +++ b/packages/backend/src/server/activitypub/following.ts @@ -1,17 +1,17 @@ -import { LessThan, IsNull } from "typeorm"; import config from "@/config/index.js"; -import * as url from "@/prelude/url.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import renderOrderedCollection from "@/remote/activitypub/renderer/ordered-collection.js"; -import renderOrderedCollectionPage from "@/remote/activitypub/renderer/ordered-collection-page.js"; -import renderFollowUser from "@/remote/activitypub/renderer/follow-user.js"; -import { Users, Followings, UserProfiles } from "@/models/index.js"; -import type { Following } from "@/models/entities/following.js"; -import { checkFetch } from "@/remote/activitypub/check-fetch.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; -import { setResponseType } from "../activitypub.js"; -import type { FindOptionsWhere } from "typeorm"; +import type { Following } from "@/models/entities/following.js"; +import { Followings, UserProfiles, Users } from "@/models/index.js"; +import * as url from "@/prelude/url.js"; +import { checkFetch } from "@/remote/activitypub/check-fetch.js"; +import renderFollowUser from "@/remote/activitypub/renderer/follow-user.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import renderOrderedCollectionPage from "@/remote/activitypub/renderer/ordered-collection-page.js"; +import renderOrderedCollection from "@/remote/activitypub/renderer/ordered-collection.js"; import type Router from "@koa/router"; +import { IsNull, LessThan } from "typeorm"; +import type { FindOptionsWhere } from "typeorm"; +import { setResponseType } from "../activitypub.js"; export default async (ctx: Router.RouterContext) => { const verify = await checkFetch(ctx.req); diff --git a/packages/backend/src/server/activitypub/outbox.ts b/packages/backend/src/server/activitypub/outbox.ts index e0a380ff..a0262e61 100644 --- a/packages/backend/src/server/activitypub/outbox.ts +++ b/packages/backend/src/server/activitypub/outbox.ts @@ -1,20 +1,20 @@ -import { Brackets, IsNull } from "typeorm"; import config from "@/config/index.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import renderOrderedCollection from "@/remote/activitypub/renderer/ordered-collection.js"; -import renderOrderedCollectionPage from "@/remote/activitypub/renderer/ordered-collection-page.js"; -import renderNote from "@/remote/activitypub/renderer/note.js"; -import renderCreate from "@/remote/activitypub/renderer/create.js"; -import renderAnnounce from "@/remote/activitypub/renderer/announce.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; +import type { Note } from "@/models/entities/note.js"; +import { Notes, Users } from "@/models/index.js"; import { countIf } from "@/prelude/array.js"; import * as url from "@/prelude/url.js"; -import { Users, Notes } from "@/models/index.js"; -import type { Note } from "@/models/entities/note.js"; import { checkFetch } from "@/remote/activitypub/check-fetch.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; -import { makePaginationQuery } from "../api/common/make-pagination-query.js"; -import { setResponseType } from "../activitypub.js"; +import renderAnnounce from "@/remote/activitypub/renderer/announce.js"; +import renderCreate from "@/remote/activitypub/renderer/create.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import renderNote from "@/remote/activitypub/renderer/note.js"; +import renderOrderedCollectionPage from "@/remote/activitypub/renderer/ordered-collection-page.js"; +import renderOrderedCollection from "@/remote/activitypub/renderer/ordered-collection.js"; import type Router from "@koa/router"; +import { Brackets, IsNull } from "typeorm"; +import { setResponseType } from "../activitypub.js"; +import { makePaginationQuery } from "../api/common/make-pagination-query.js"; export default async (ctx: Router.RouterContext) => { const verify = await checkFetch(ctx.req); diff --git a/packages/backend/src/server/api/2fa.ts b/packages/backend/src/server/api/2fa.ts index 7318f0f4..2fd2148c 100644 --- a/packages/backend/src/server/api/2fa.ts +++ b/packages/backend/src/server/api/2fa.ts @@ -1,6 +1,6 @@ import * as crypto from "node:crypto"; -import * as jsrsasign from "jsrsasign"; import config from "@/config/index.js"; +import * as jsrsasign from "jsrsasign"; const ECC_PRELUDE = Buffer.from([0x04]); const NULL_BYTE = Buffer.from([0]); diff --git a/packages/backend/src/server/api/api-handler.ts b/packages/backend/src/server/api/api-handler.ts index 48a33dfc..0f19b733 100644 --- a/packages/backend/src/server/api/api-handler.ts +++ b/packages/backend/src/server/api/api-handler.ts @@ -1,11 +1,11 @@ import type Koa from "koa"; +import { fetchMeta } from "@/misc/fetch-meta.js"; import type { User } from "@/models/entities/user.js"; import { UserIps } from "@/models/index.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; -import type { IEndpoint } from "./endpoints.js"; import authenticate, { AuthenticationError } from "./authenticate.js"; import call from "./call.js"; +import type { IEndpoint } from "./endpoints.js"; import { ApiError } from "./error.js"; const userIpHistories = new Map>(); @@ -29,12 +29,12 @@ export default (endpoint: IEndpoint, ctx: Koa.Context) => ctx.status = x; ctx.body = { error: { - message: y!.message, - code: y!.code, - id: y!.id, - kind: y!.kind, - ...(y!.info && process.env.NODE_ENV !== "production" - ? { info: y!.info } + message: y?.message, + code: y?.code, + id: y?.id, + kind: y?.kind, + ...(y?.info && process.env.NODE_ENV !== "production" + ? { info: y?.info } : {}), }, }; @@ -49,7 +49,7 @@ export default (endpoint: IEndpoint, ctx: Koa.Context) => // for GET requests, do not even pass on the body parameter as it is considered unsafe authenticate( ctx.headers.authorization, - ctx.method === "GET" ? null : body["i"], + ctx.method === "GET" ? null : body.i, ) .then(([user, app]) => { // API invoking @@ -58,7 +58,7 @@ export default (endpoint: IEndpoint, ctx: Koa.Context) => if ( ctx.method === "GET" && endpoint.meta.cacheSec && - !body["i"] && + !body.i && !user ) { ctx.set( diff --git a/packages/backend/src/server/api/authenticate.ts b/packages/backend/src/server/api/authenticate.ts index 460a0ce8..4267755c 100644 --- a/packages/backend/src/server/api/authenticate.ts +++ b/packages/backend/src/server/api/authenticate.ts @@ -1,13 +1,13 @@ -import isNativeToken from "./common/is-native-token.js"; -import type { CacheableLocalUser, ILocalUser } from "@/models/entities/user.js"; -import { Users, AccessTokens, Apps } from "@/models/index.js"; -import type { AccessToken } from "@/models/entities/access-token.js"; import { Cache } from "@/misc/cache.js"; +import type { AccessToken } from "@/models/entities/access-token.js"; import type { App } from "@/models/entities/app.js"; +import type { CacheableLocalUser, ILocalUser } from "@/models/entities/user.js"; +import { AccessTokens, Apps, Users } from "@/models/index.js"; import { localUserByIdCache, localUserByNativeTokenCache, } from "@/services/user-cache.js"; +import isNativeToken from "./common/is-native-token.js"; const appCache = new Cache("app", 60 * 30); diff --git a/packages/backend/src/server/api/call.ts b/packages/backend/src/server/api/call.ts index 2132edd0..4535bba2 100644 --- a/packages/backend/src/server/api/call.ts +++ b/packages/backend/src/server/api/call.ts @@ -1,15 +1,15 @@ -import { performance } from "perf_hooks"; -import type Koa from "koa"; -import type { CacheableLocalUser } from "@/models/entities/user.js"; -import type { AccessToken } from "@/models/entities/access-token.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; import { getIpHash } from "@/misc/get-ip-hash.js"; -import { limiter } from "./limiter.js"; +import type { AccessToken } from "@/models/entities/access-token.js"; +import type { CacheableLocalUser } from "@/models/entities/user.js"; +import type Koa from "koa"; +import { performance } from "perf_hooks"; +import compatibility from "./compatibility.js"; import type { IEndpointMeta } from "./endpoints.js"; import endpoints from "./endpoints.js"; -import compatibility from "./compatibility.js"; import { ApiError } from "./error.js"; +import { limiter } from "./limiter.js"; import { apiLogger } from "./logger.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; const accessDenied = { message: "Access denied.", @@ -50,7 +50,7 @@ export default async ( if (user) { limitActor = user.id; } else { - limitActor = getIpHash(ctx!.ip); + limitActor = getIpHash(ctx?.ip); } const limit = Object.assign({}, ep.meta.limit); @@ -85,7 +85,7 @@ export default async ( }); } - if (ep.meta.requireCredential && user!.isSuspended) { + if (ep.meta.requireCredential && user?.isSuspended) { throw new ApiError({ message: "Your account has been suspended.", code: "YOUR_ACCOUNT_SUSPENDED", @@ -94,7 +94,7 @@ export default async ( }); } - if (ep.meta.requireAdmin && !user!.isAdmin) { + if (ep.meta.requireAdmin && !user?.isAdmin) { throw new ApiError(accessDenied, { reason: "You are not an admin." }); } @@ -133,7 +133,7 @@ export default async ( // Cast non JSON input if ((ep.meta.requireFile || ctx?.method === "GET") && ep.params.properties) { for (const k of Object.keys(ep.params.properties)) { - const param = ep.params.properties![k]; + const param = ep.params.properties?.[k]; if ( ["boolean", "number", "integer"].includes(param.type ?? "") && typeof data[k] === "string" diff --git a/packages/backend/src/server/api/common/generate-muted-user-query.ts b/packages/backend/src/server/api/common/generate-muted-user-query.ts index 3538fbf0..78db2078 100644 --- a/packages/backend/src/server/api/common/generate-muted-user-query.ts +++ b/packages/backend/src/server/api/common/generate-muted-user-query.ts @@ -1,7 +1,7 @@ -import type { SelectQueryBuilder } from "typeorm"; -import { Brackets } from "typeorm"; import type { User } from "@/models/entities/user.js"; import { Mutings, UserProfiles } from "@/models/index.js"; +import type { SelectQueryBuilder } from "typeorm"; +import { Brackets } from "typeorm"; export function generateMutedUserQuery( q: SelectQueryBuilder, diff --git a/packages/backend/src/server/api/common/generated-muted-renote-query.ts b/packages/backend/src/server/api/common/generated-muted-renote-query.ts index 3fcd9b28..3e26d4fa 100644 --- a/packages/backend/src/server/api/common/generated-muted-renote-query.ts +++ b/packages/backend/src/server/api/common/generated-muted-renote-query.ts @@ -1,6 +1,6 @@ -import { Brackets, SelectQueryBuilder } from "typeorm"; import { User } from "@/models/entities/user.js"; import { RenoteMutings } from "@/models/index.js"; +import { Brackets, SelectQueryBuilder } from "typeorm"; export function generateMutedUserRenotesQueryForNotes( q: SelectQueryBuilder, diff --git a/packages/backend/src/server/api/common/getters.ts b/packages/backend/src/server/api/common/getters.ts index fd758077..9849f783 100644 --- a/packages/backend/src/server/api/common/getters.ts +++ b/packages/backend/src/server/api/common/getters.ts @@ -1,6 +1,6 @@ import { IdentifiableError } from "@/misc/identifiable-error.js"; -import type { User } from "@/models/entities/user.js"; import type { Note } from "@/models/entities/note.js"; +import type { User } from "@/models/entities/user.js"; import { Notes, Users } from "@/models/index.js"; import { generateVisibilityQuery } from "./generate-visibility-query.js"; diff --git a/packages/backend/src/server/api/common/inject-featured.ts b/packages/backend/src/server/api/common/inject-featured.ts index 30ba3eca..3d5b08ad 100644 --- a/packages/backend/src/server/api/common/inject-featured.ts +++ b/packages/backend/src/server/api/common/inject-featured.ts @@ -1,9 +1,9 @@ -import rndstr from "rndstr"; import type { Note } from "@/models/entities/note.js"; import type { User } from "@/models/entities/user.js"; -import { Notes, UserProfiles, NoteReactions } from "@/models/index.js"; -import { generateMutedUserQuery } from "./generate-muted-user-query.js"; +import { NoteReactions, Notes, UserProfiles } from "@/models/index.js"; +import rndstr from "rndstr"; import { generateBlockedUserQuery } from "./generate-block-query.js"; +import { generateMutedUserQuery } from "./generate-muted-user-query.js"; // TODO: リアクション、Renote、返信などをしたノートは除外する diff --git a/packages/backend/src/server/api/common/inject-promo.ts b/packages/backend/src/server/api/common/inject-promo.ts index dcc4e5f3..774542b9 100644 --- a/packages/backend/src/server/api/common/inject-promo.ts +++ b/packages/backend/src/server/api/common/inject-promo.ts @@ -1,7 +1,7 @@ -import rndstr from "rndstr"; import type { Note } from "@/models/entities/note.js"; import type { User } from "@/models/entities/user.js"; -import { PromoReads, PromoNotes, Notes, Users } from "@/models/index.js"; +import { Notes, PromoNotes, PromoReads, Users } from "@/models/index.js"; +import rndstr from "rndstr"; export async function injectPromo(timeline: Note[], user?: User | null) { if (timeline.length < 5) return; diff --git a/packages/backend/src/server/api/common/read-messaging-message.ts b/packages/backend/src/server/api/common/read-messaging-message.ts index fc22c843..47391867 100644 --- a/packages/backend/src/server/api/common/read-messaging-message.ts +++ b/packages/backend/src/server/api/common/read-messaging-message.ts @@ -1,21 +1,21 @@ +import { IdentifiableError } from "@/misc/identifiable-error.js"; +import type { MessagingMessage } from "@/models/entities/messaging-message.js"; +import type { UserGroup } from "@/models/entities/user-group.js"; +import type { IRemoteUser, User } from "@/models/entities/user.js"; +import { MessagingMessages, UserGroupJoinings, Users } from "@/models/index.js"; +import { toArray } from "@/prelude/array.js"; +import { deliver } from "@/queue/index.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import orderedCollection from "@/remote/activitypub/renderer/ordered-collection.js"; +import { renderReadActivity } from "@/remote/activitypub/renderer/read.js"; +import { pushNotification } from "@/services/push-notification.js"; import { - publishMainStream, publishGroupMessagingStream, + publishMainStream, } from "@/services/stream.js"; import { publishMessagingStream } from "@/services/stream.js"; import { publishMessagingIndexStream } from "@/services/stream.js"; -import { pushNotification } from "@/services/push-notification.js"; -import type { User, IRemoteUser } from "@/models/entities/user.js"; -import type { MessagingMessage } from "@/models/entities/messaging-message.js"; -import { MessagingMessages, UserGroupJoinings, Users } from "@/models/index.js"; import { In } from "typeorm"; -import { IdentifiableError } from "@/misc/identifiable-error.js"; -import type { UserGroup } from "@/models/entities/user-group.js"; -import { toArray } from "@/prelude/array.js"; -import { renderReadActivity } from "@/remote/activitypub/renderer/read.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import { deliver } from "@/queue/index.js"; -import orderedCollection from "@/remote/activitypub/renderer/ordered-collection.js"; /** * Mark messages as read diff --git a/packages/backend/src/server/api/common/read-notification.ts b/packages/backend/src/server/api/common/read-notification.ts index 1fb1d642..ab30c5bb 100644 --- a/packages/backend/src/server/api/common/read-notification.ts +++ b/packages/backend/src/server/api/common/read-notification.ts @@ -1,9 +1,9 @@ -import { In } from "typeorm"; -import { publishMainStream } from "@/services/stream.js"; -import { pushNotification } from "@/services/push-notification.js"; -import type { User } from "@/models/entities/user.js"; import type { Notification } from "@/models/entities/notification.js"; +import type { User } from "@/models/entities/user.js"; import { Notifications, Users } from "@/models/index.js"; +import { pushNotification } from "@/services/push-notification.js"; +import { publishMainStream } from "@/services/stream.js"; +import { In } from "typeorm"; export async function readNotification( userId: User["id"], diff --git a/packages/backend/src/server/api/common/signin.ts b/packages/backend/src/server/api/common/signin.ts index a8a43584..478407de 100644 --- a/packages/backend/src/server/api/common/signin.ts +++ b/packages/backend/src/server/api/common/signin.ts @@ -1,9 +1,9 @@ import type Koa from "koa"; import config from "@/config/index.js"; +import { genId } from "@/misc/gen-id.js"; import type { ILocalUser } from "@/models/entities/user.js"; import { Signins } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; import { publishMainStream } from "@/services/stream.js"; export default function (ctx: Koa.Context, user: ILocalUser, redirect = false) { diff --git a/packages/backend/src/server/api/common/signup.ts b/packages/backend/src/server/api/common/signup.ts index dc76c264..0d6c4a78 100644 --- a/packages/backend/src/server/api/common/signup.ts +++ b/packages/backend/src/server/api/common/signup.ts @@ -1,16 +1,16 @@ import { generateKeyPair } from "node:crypto"; -import generateUserToken from "./generate-native-user-token.js"; -import { User } from "@/models/entities/user.js"; -import { Users, UsedUsernames } from "@/models/index.js"; -import { UserProfile } from "@/models/entities/user-profile.js"; -import { IsNull } from "typeorm"; -import { genId } from "@/misc/gen-id.js"; -import { toPunyNullable } from "@/misc/convert-host.js"; -import { UserKeypair } from "@/models/entities/user-keypair.js"; -import { UsedUsername } from "@/models/entities/used-username.js"; -import { db } from "@/db/postgre.js"; import config from "@/config/index.js"; +import { db } from "@/db/postgre.js"; +import { toPunyNullable } from "@/misc/convert-host.js"; +import { genId } from "@/misc/gen-id.js"; import { hashPassword } from "@/misc/password.js"; +import { UsedUsername } from "@/models/entities/used-username.js"; +import { UserKeypair } from "@/models/entities/user-keypair.js"; +import { UserProfile } from "@/models/entities/user-profile.js"; +import { User } from "@/models/entities/user.js"; +import { UsedUsernames, Users } from "@/models/index.js"; +import { IsNull } from "typeorm"; +import generateUserToken from "./generate-native-user-token.js"; export async function signup(opts: { username: User["username"]; diff --git a/packages/backend/src/server/api/define.ts b/packages/backend/src/server/api/define.ts index 946f86a6..584393c5 100644 --- a/packages/backend/src/server/api/define.ts +++ b/packages/backend/src/server/api/define.ts @@ -1,8 +1,8 @@ import * as fs from "node:fs"; -import Ajv from "ajv"; -import type { CacheableLocalUser } from "@/models/entities/user.js"; import type { Schema, SchemaType } from "@/misc/schema.js"; import type { AccessToken } from "@/models/entities/access-token.js"; +import type { CacheableLocalUser } from "@/models/entities/user.js"; +import Ajv from "ajv"; import type { IEndpointMeta } from "./endpoints.js"; import { ApiError } from "./error.js"; @@ -74,7 +74,7 @@ export default function ( const valid = validate(params); if (!valid) { - if (file) cleanup!(); + if (file) cleanup?.(); const errors = validate.errors!; const err = new ApiError( diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index 621b92fe..ec65cbc5 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -1,6 +1,5 @@ import type { Schema } from "@/misc/schema.js"; -import * as ep___admin_meta from "./endpoints/admin/meta.js"; import * as ep___admin_abuseUserReports from "./endpoints/admin/abuse-user-reports.js"; import * as ep___admin_accounts_create from "./endpoints/admin/accounts/create.js"; import * as ep___admin_accounts_delete from "./endpoints/admin/accounts/delete.js"; @@ -13,7 +12,11 @@ import * as ep___admin_announcements_create from "./endpoints/admin/announcement import * as ep___admin_announcements_delete from "./endpoints/admin/announcements/delete.js"; import * as ep___admin_announcements_list from "./endpoints/admin/announcements/list.js"; import * as ep___admin_announcements_update from "./endpoints/admin/announcements/update.js"; +import * as ep___admin_delete2fa from "./endpoints/admin/delete-2fa.js"; +import * as ep___admin_deleteAccount from "./endpoints/admin/delete-account.js"; import * as ep___admin_deleteAllFilesOfAUser from "./endpoints/admin/delete-all-files-of-a-user.js"; +import * as ep___admin_deletePasskeys from "./endpoints/admin/delete-passkeys.js"; +import * as ep___admin_driveCapOverride from "./endpoints/admin/drive-capacity-override.js"; import * as ep___admin_drive_cleanRemoteFiles from "./endpoints/admin/drive/clean-remote-files.js"; import * as ep___admin_drive_cleanup from "./endpoints/admin/drive/cleanup.js"; import * as ep___admin_drive_files from "./endpoints/admin/drive/files.js"; @@ -39,6 +42,7 @@ import * as ep___admin_getIndexStats from "./endpoints/admin/get-index-stats.js" import * as ep___admin_getTableStats from "./endpoints/admin/get-table-stats.js"; import * as ep___admin_getUserIps from "./endpoints/admin/get-user-ips.js"; import * as ep___admin_invite from "./endpoints/admin/invite.js"; +import * as ep___admin_meta from "./endpoints/admin/meta.js"; import * as ep___admin_moderators_add from "./endpoints/admin/moderators/add.js"; import * as ep___admin_moderators_remove from "./endpoints/admin/moderators/remove.js"; import * as ep___admin_promo_create from "./endpoints/admin/promo/create.js"; @@ -64,11 +68,8 @@ import * as ep___admin_suspendUser from "./endpoints/admin/suspend-user.js"; import * as ep___admin_unsilenceUser from "./endpoints/admin/unsilence-user.js"; import * as ep___admin_unsuspendUser from "./endpoints/admin/unsuspend-user.js"; import * as ep___admin_updateMeta from "./endpoints/admin/update-meta.js"; -import * as ep___admin_vacuum from "./endpoints/admin/vacuum.js"; -import * as ep___admin_deleteAccount from "./endpoints/admin/delete-account.js"; -import * as ep___admin_delete2fa from "./endpoints/admin/delete-2fa.js"; -import * as ep___admin_deletePasskeys from "./endpoints/admin/delete-passkeys.js"; import * as ep___admin_updateUserNote from "./endpoints/admin/update-user-note.js"; +import * as ep___admin_vacuum from "./endpoints/admin/vacuum.js"; import * as ep___announcements from "./endpoints/announcements.js"; import * as ep___antennas_create from "./endpoints/antennas/create.js"; import * as ep___antennas_delete from "./endpoints/antennas/delete.js"; @@ -111,18 +112,20 @@ import * as ep___charts_user_notes from "./endpoints/charts/user/notes.js"; import * as ep___charts_user_reactions from "./endpoints/charts/user/reactions.js"; import * as ep___charts_users from "./endpoints/charts/users.js"; import * as ep___clips_addNote from "./endpoints/clips/add-note.js"; -import * as ep___clips_removeNote from "./endpoints/clips/remove-note.js"; import * as ep___clips_create from "./endpoints/clips/create.js"; import * as ep___clips_delete from "./endpoints/clips/delete.js"; import * as ep___clips_list from "./endpoints/clips/list.js"; import * as ep___clips_notes from "./endpoints/clips/notes.js"; +import * as ep___clips_removeNote from "./endpoints/clips/remove-note.js"; import * as ep___clips_show from "./endpoints/clips/show.js"; import * as ep___clips_update from "./endpoints/clips/update.js"; +import * as ep___customMOTD from "./endpoints/custom-motd.js"; +import * as ep___customSplashIcons from "./endpoints/custom-splash-icons.js"; import * as ep___drive from "./endpoints/drive.js"; import * as ep___drive_files from "./endpoints/drive/files.js"; import * as ep___drive_files_attachedNotes from "./endpoints/drive/files/attached-notes.js"; -import * as ep___drive_files_checkExistence from "./endpoints/drive/files/check-existence.js"; import * as ep___drive_files_captionImage from "./endpoints/drive/files/caption-image.js"; +import * as ep___drive_files_checkExistence from "./endpoints/drive/files/check-existence.js"; import * as ep___drive_files_create from "./endpoints/drive/files/create.js"; import * as ep___drive_files_delete from "./endpoints/drive/files/delete.js"; import * as ep___drive_files_findByHash from "./endpoints/drive/files/find-by-hash.js"; @@ -146,9 +149,10 @@ import * as ep___federation_followers from "./endpoints/federation/followers.js" import * as ep___federation_following from "./endpoints/federation/following.js"; import * as ep___federation_instances from "./endpoints/federation/instances.js"; import * as ep___federation_showInstance from "./endpoints/federation/show-instance.js"; +import * as ep___federation_stats from "./endpoints/federation/stats.js"; import * as ep___federation_updateRemoteUser from "./endpoints/federation/update-remote-user.js"; import * as ep___federation_users from "./endpoints/federation/users.js"; -import * as ep___federation_stats from "./endpoints/federation/stats.js"; +import * as ep___fetchRss from "./endpoints/fetch-rss.js"; import * as ep___following_create from "./endpoints/following/create.js"; import * as ep___following_delete from "./endpoints/following/delete.js"; import * as ep___following_invalidate from "./endpoints/following/invalidate.js"; @@ -166,6 +170,7 @@ import * as ep___gallery_posts_show from "./endpoints/gallery/posts/show.js"; import * as ep___gallery_posts_unlike from "./endpoints/gallery/posts/unlike.js"; import * as ep___gallery_posts_update from "./endpoints/gallery/posts/update.js"; import * as ep___getOnlineUsersCount from "./endpoints/get-online-users-count.js"; +import * as ep___sounds from "./endpoints/get-sounds.js"; import * as ep___hashtags_list from "./endpoints/hashtags/list.js"; import * as ep___hashtags_search from "./endpoints/hashtags/search.js"; import * as ep___hashtags_show from "./endpoints/hashtags/show.js"; @@ -177,9 +182,9 @@ import * as ep___i_2fa_keyDone from "./endpoints/i/2fa/key-done.js"; import * as ep___i_2fa_passwordLess from "./endpoints/i/2fa/password-less.js"; import * as ep___i_2fa_registerKey from "./endpoints/i/2fa/register-key.js"; import * as ep___i_2fa_register from "./endpoints/i/2fa/register.js"; -import * as ep___i_2fa_updateKey from "./endpoints/i/2fa/update-key.js"; import * as ep___i_2fa_removeKey from "./endpoints/i/2fa/remove-key.js"; import * as ep___i_2fa_unregister from "./endpoints/i/2fa/unregister.js"; +import * as ep___i_2fa_updateKey from "./endpoints/i/2fa/update-key.js"; import * as ep___i_apps from "./endpoints/i/apps.js"; import * as ep___i_authorizedApps from "./endpoints/i/authorized-apps.js"; import * as ep___i_changePassword from "./endpoints/i/change-password.js"; @@ -188,7 +193,6 @@ import * as ep___i_exportBlocking from "./endpoints/i/export-blocking.js"; import * as ep___i_exportFollowing from "./endpoints/i/export-following.js"; import * as ep___i_exportMute from "./endpoints/i/export-mute.js"; import * as ep___i_exportNotes from "./endpoints/i/export-notes.js"; -import * as ep___i_importPosts from "./endpoints/i/import-posts.js"; import * as ep___i_exportUserLists from "./endpoints/i/export-user-lists.js"; import * as ep___i_favorites from "./endpoints/i/favorites.js"; import * as ep___i_gallery_likes from "./endpoints/i/gallery/likes.js"; @@ -197,6 +201,7 @@ import * as ep___i_getWordMutedNotesCount from "./endpoints/i/get-word-muted-not import * as ep___i_importBlocking from "./endpoints/i/import-blocking.js"; import * as ep___i_importFollowing from "./endpoints/i/import-following.js"; import * as ep___i_importMuting from "./endpoints/i/import-muting.js"; +import * as ep___i_importPosts from "./endpoints/i/import-posts.js"; import * as ep___i_importUserLists from "./endpoints/i/import-user-lists.js"; import * as ep___i_notifications from "./endpoints/i/notifications.js"; import * as ep___i_pageLikes from "./endpoints/i/page-likes.js"; @@ -222,24 +227,21 @@ import * as ep___i_updateEmail from "./endpoints/i/update-email.js"; import * as ep___i_update from "./endpoints/i/update.js"; import * as ep___i_userGroupInvites from "./endpoints/i/user-group-invites.js"; import * as ep___i_webhooks_create from "./endpoints/i/webhooks/create.js"; -import * as ep___i_webhooks_show from "./endpoints/i/webhooks/show.js"; -import * as ep___i_webhooks_list from "./endpoints/i/webhooks/list.js"; -import * as ep___i_webhooks_update from "./endpoints/i/webhooks/update.js"; import * as ep___i_webhooks_delete from "./endpoints/i/webhooks/delete.js"; +import * as ep___i_webhooks_list from "./endpoints/i/webhooks/list.js"; +import * as ep___i_webhooks_show from "./endpoints/i/webhooks/show.js"; +import * as ep___i_webhooks_update from "./endpoints/i/webhooks/update.js"; +import * as ep___latestVersion from "./endpoints/latest-version.js"; import * as ep___messaging_history from "./endpoints/messaging/history.js"; import * as ep___messaging_messages from "./endpoints/messaging/messages.js"; import * as ep___messaging_messages_create from "./endpoints/messaging/messages/create.js"; import * as ep___messaging_messages_delete from "./endpoints/messaging/messages/delete.js"; import * as ep___messaging_messages_read from "./endpoints/messaging/messages/read.js"; import * as ep___meta from "./endpoints/meta.js"; -import * as ep___sounds from "./endpoints/get-sounds.js"; import * as ep___miauth_genToken from "./endpoints/miauth/gen-token.js"; import * as ep___mute_create from "./endpoints/mute/create.js"; import * as ep___mute_delete from "./endpoints/mute/delete.js"; import * as ep___mute_list from "./endpoints/mute/list.js"; -import * as ep___renote_mute_create from "./endpoints/renote-mute/create.js"; -import * as ep___renote_mute_delete from "./endpoints/renote-mute/delete.js"; -import * as ep___renote_mute_list from "./endpoints/renote-mute/list.js"; import * as ep___my_apps from "./endpoints/my/apps.js"; import * as ep___notes from "./endpoints/notes.js"; import * as ep___notes_children from "./endpoints/notes/children.js"; @@ -254,7 +256,6 @@ import * as ep___notes_featured from "./endpoints/notes/featured.js"; import * as ep___notes_globalTimeline from "./endpoints/notes/global-timeline.js"; import * as ep___notes_hybridTimeline from "./endpoints/notes/hybrid-timeline.js"; import * as ep___notes_localTimeline from "./endpoints/notes/local-timeline.js"; -import * as ep___notes_recommendedTimeline from "./endpoints/notes/recommended-timeline.js"; import * as ep___notes_makePrivate from "./endpoints/notes/make-private.js"; import * as ep___notes_mentions from "./endpoints/notes/mentions.js"; import * as ep___notes_polls_recommendation from "./endpoints/notes/polls/recommendation.js"; @@ -262,6 +263,7 @@ import * as ep___notes_polls_vote from "./endpoints/notes/polls/vote.js"; import * as ep___notes_reactions from "./endpoints/notes/reactions.js"; import * as ep___notes_reactions_create from "./endpoints/notes/reactions/create.js"; import * as ep___notes_reactions_delete from "./endpoints/notes/reactions/delete.js"; +import * as ep___notes_recommendedTimeline from "./endpoints/notes/recommended-timeline.js"; import * as ep___notes_renotes from "./endpoints/notes/renotes.js"; import * as ep___notes_replies from "./endpoints/notes/replies.js"; import * as ep___notes_searchByTag from "./endpoints/notes/search-by-tag.js"; @@ -287,24 +289,24 @@ import * as ep___pages_like from "./endpoints/pages/like.js"; import * as ep___pages_show from "./endpoints/pages/show.js"; import * as ep___pages_unlike from "./endpoints/pages/unlike.js"; import * as ep___pages_update from "./endpoints/pages/update.js"; -import * as ep___ping from "./endpoints/ping.js"; -import * as ep___recommendedInstances from "./endpoints/recommended-instances.js"; -import * as ep___pinnedUsers from "./endpoints/pinned-users.js"; -import * as ep___customMOTD from "./endpoints/custom-motd.js"; -import * as ep___customSplashIcons from "./endpoints/custom-splash-icons.js"; -import * as ep___latestVersion from "./endpoints/latest-version.js"; import * as ep___patrons from "./endpoints/patrons.js"; -import * as ep___release from "./endpoints/release.js"; +import * as ep___ping from "./endpoints/ping.js"; +import * as ep___pinnedUsers from "./endpoints/pinned-users.js"; import * as ep___promo_read from "./endpoints/promo/read.js"; +import * as ep___recommendedInstances from "./endpoints/recommended-instances.js"; +import * as ep___release from "./endpoints/release.js"; +import * as ep___renote_mute_create from "./endpoints/renote-mute/create.js"; +import * as ep___renote_mute_delete from "./endpoints/renote-mute/delete.js"; +import * as ep___renote_mute_list from "./endpoints/renote-mute/list.js"; import * as ep___requestResetPassword from "./endpoints/request-reset-password.js"; import * as ep___resetDb from "./endpoints/reset-db.js"; import * as ep___resetPassword from "./endpoints/reset-password.js"; import * as ep___serverInfo from "./endpoints/server-info.js"; import * as ep___stats from "./endpoints/stats.js"; -import * as ep___sw_show_registration from "./endpoints/sw/show-registration.js"; -import * as ep___sw_update_registration from "./endpoints/sw/update-registration.js"; import * as ep___sw_register from "./endpoints/sw/register.js"; +import * as ep___sw_show_registration from "./endpoints/sw/show-registration.js"; import * as ep___sw_unregister from "./endpoints/sw/unregister.js"; +import * as ep___sw_update_registration from "./endpoints/sw/update-registration.js"; import * as ep___test from "./endpoints/test.js"; import * as ep___username_available from "./endpoints/username/available.js"; import * as ep___users from "./endpoints/users.js"; @@ -326,8 +328,8 @@ import * as ep___users_groups_show from "./endpoints/users/groups/show.js"; import * as ep___users_groups_transfer from "./endpoints/users/groups/transfer.js"; import * as ep___users_groups_update from "./endpoints/users/groups/update.js"; import * as ep___users_lists_create from "./endpoints/users/lists/create.js"; -import * as ep___users_lists_delete from "./endpoints/users/lists/delete.js"; import * as ep___users_lists_delete_all from "./endpoints/users/lists/delete-all.js"; +import * as ep___users_lists_delete from "./endpoints/users/lists/delete.js"; import * as ep___users_lists_list from "./endpoints/users/lists/list.js"; import * as ep___users_lists_pull from "./endpoints/users/lists/pull.js"; import * as ep___users_lists_push from "./endpoints/users/lists/push.js"; @@ -343,12 +345,10 @@ import * as ep___users_searchByUsernameAndHost from "./endpoints/users/search-by import * as ep___users_search from "./endpoints/users/search.js"; import * as ep___users_show from "./endpoints/users/show.js"; import * as ep___users_stats from "./endpoints/users/stats.js"; -import * as ep___fetchRss from "./endpoints/fetch-rss.js"; -import * as ep___admin_driveCapOverride from "./endpoints/admin/drive-capacity-override.js"; +import * as ep___i_known_as from "./endpoints/i/known-as.js"; //Firefish Move import * as ep___i_move from "./endpoints/i/move.js"; -import * as ep___i_known_as from "./endpoints/i/known-as.js"; const eps = [ ["admin/meta", ep___admin_meta], diff --git a/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts b/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts index 78034917..c2ff716c 100644 --- a/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts +++ b/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; import { AbuseUserReports } from "@/models/index.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/accounts/create.ts b/packages/backend/src/server/api/endpoints/admin/accounts/create.ts index e5972173..a75c9b5f 100644 --- a/packages/backend/src/server/api/endpoints/admin/accounts/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/accounts/create.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; import { Users } from "@/models/index.js"; import { signup } from "@/server/api/common/signup.js"; +import define from "@/server/api/define.js"; import { IsNull } from "typeorm"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts b/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts index 42351808..b912ad6a 100644 --- a/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts +++ b/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts @@ -1,8 +1,8 @@ -import define from "@/server/api/define.js"; import { Users } from "@/models/index.js"; -import { doPostSuspend } from "@/services/suspend-user.js"; -import { publishUserEvent } from "@/services/stream.js"; import { createDeleteAccountJob } from "@/queue/index.js"; +import define from "@/server/api/define.js"; +import { publishUserEvent } from "@/services/stream.js"; +import { doPostSuspend } from "@/services/suspend-user.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/accounts/hosted.ts b/packages/backend/src/server/api/endpoints/admin/accounts/hosted.ts index 601cd950..f6987886 100644 --- a/packages/backend/src/server/api/endpoints/admin/accounts/hosted.ts +++ b/packages/backend/src/server/api/endpoints/admin/accounts/hosted.ts @@ -1,8 +1,8 @@ import config from "@/config/index.js"; -import { Meta } from "@/models/entities/meta.js"; -import { insertModerationLog } from "@/services/insert-moderation-log.js"; import { db } from "@/db/postgre.js"; +import { Meta } from "@/models/entities/meta.js"; import define from "@/server/api/define.js"; +import { insertModerationLog } from "@/services/insert-moderation-log.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/ad/create.ts b/packages/backend/src/server/api/endpoints/admin/ad/create.ts index bfe4d544..cd23afd8 100644 --- a/packages/backend/src/server/api/endpoints/admin/ad/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/ad/create.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; -import { Ads } from "@/models/index.js"; import { genId } from "@/misc/gen-id.js"; +import { Ads } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/ad/delete.ts b/packages/backend/src/server/api/endpoints/admin/ad/delete.ts index 802eb5ef..3ebb8804 100644 --- a/packages/backend/src/server/api/endpoints/admin/ad/delete.ts +++ b/packages/backend/src/server/api/endpoints/admin/ad/delete.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { Ads } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/admin/ad/list.ts b/packages/backend/src/server/api/endpoints/admin/ad/list.ts index 1f39e73e..14c3f6ce 100644 --- a/packages/backend/src/server/api/endpoints/admin/ad/list.ts +++ b/packages/backend/src/server/api/endpoints/admin/ad/list.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; import { Ads } from "@/models/index.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/ad/update.ts b/packages/backend/src/server/api/endpoints/admin/ad/update.ts index 52f31a3c..d1c5bb3b 100644 --- a/packages/backend/src/server/api/endpoints/admin/ad/update.ts +++ b/packages/backend/src/server/api/endpoints/admin/ad/update.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { Ads } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/admin/announcements/create.ts b/packages/backend/src/server/api/endpoints/admin/announcements/create.ts index 8af77848..611f7de6 100644 --- a/packages/backend/src/server/api/endpoints/admin/announcements/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/announcements/create.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; -import { Announcements } from "@/models/index.js"; import { genId } from "@/misc/gen-id.js"; +import { Announcements } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/announcements/delete.ts b/packages/backend/src/server/api/endpoints/admin/announcements/delete.ts index 8b2326cd..b847c246 100644 --- a/packages/backend/src/server/api/endpoints/admin/announcements/delete.ts +++ b/packages/backend/src/server/api/endpoints/admin/announcements/delete.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { Announcements } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/admin/announcements/list.ts b/packages/backend/src/server/api/endpoints/admin/announcements/list.ts index a13fabd6..f1da1a30 100644 --- a/packages/backend/src/server/api/endpoints/admin/announcements/list.ts +++ b/packages/backend/src/server/api/endpoints/admin/announcements/list.ts @@ -1,7 +1,7 @@ -import { Announcements, AnnouncementReads } from "@/models/index.js"; import type { Announcement } from "@/models/entities/announcement.js"; -import define from "@/server/api/define.js"; +import { AnnouncementReads, Announcements } from "@/models/index.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/announcements/update.ts b/packages/backend/src/server/api/endpoints/admin/announcements/update.ts index 03af4147..32cef004 100644 --- a/packages/backend/src/server/api/endpoints/admin/announcements/update.ts +++ b/packages/backend/src/server/api/endpoints/admin/announcements/update.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { Announcements } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/admin/delete-2fa.ts b/packages/backend/src/server/api/endpoints/admin/delete-2fa.ts index 1cf60d9c..38e8f0dc 100644 --- a/packages/backend/src/server/api/endpoints/admin/delete-2fa.ts +++ b/packages/backend/src/server/api/endpoints/admin/delete-2fa.ts @@ -1,6 +1,6 @@ -import { Users, UserProfiles } from "@/models/index.js"; -import { publishMainStream } from "@/services/stream.js"; +import { UserProfiles, Users } from "@/models/index.js"; import define from "@/server/api/define.js"; +import { publishMainStream } from "@/services/stream.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/delete-account.ts b/packages/backend/src/server/api/endpoints/admin/delete-account.ts index 1b6dc31a..2decb30d 100644 --- a/packages/backend/src/server/api/endpoints/admin/delete-account.ts +++ b/packages/backend/src/server/api/endpoints/admin/delete-account.ts @@ -1,6 +1,6 @@ import { Users } from "@/models/index.js"; -import { deleteAccount } from "@/services/delete-account.js"; import define from "@/server/api/define.js"; +import { deleteAccount } from "@/services/delete-account.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/delete-all-files-of-a-user.ts b/packages/backend/src/server/api/endpoints/admin/delete-all-files-of-a-user.ts index b52f6098..0dd52068 100644 --- a/packages/backend/src/server/api/endpoints/admin/delete-all-files-of-a-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/delete-all-files-of-a-user.ts @@ -1,6 +1,6 @@ +import { DriveFiles } from "@/models/index.js"; import define from "@/server/api/define.js"; import { deleteFile } from "@/services/drive/delete-file.js"; -import { DriveFiles } from "@/models/index.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/delete-passkeys.ts b/packages/backend/src/server/api/endpoints/admin/delete-passkeys.ts index 7a54f5d9..773aa698 100644 --- a/packages/backend/src/server/api/endpoints/admin/delete-passkeys.ts +++ b/packages/backend/src/server/api/endpoints/admin/delete-passkeys.ts @@ -1,6 +1,6 @@ -import { Users, UserProfiles, UserSecurityKeys } from "@/models/index.js"; -import { publishMainStream } from "@/services/stream.js"; +import { UserProfiles, UserSecurityKeys, Users } from "@/models/index.js"; import define from "@/server/api/define.js"; +import { publishMainStream } from "@/services/stream.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/drive-capacity-override.ts b/packages/backend/src/server/api/endpoints/admin/drive-capacity-override.ts index d4bb3045..2f7e2db0 100644 --- a/packages/backend/src/server/api/endpoints/admin/drive-capacity-override.ts +++ b/packages/backend/src/server/api/endpoints/admin/drive-capacity-override.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { Users } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { insertModerationLog } from "@/services/insert-moderation-log.js"; import { publishInternalEvent } from "@/services/stream.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/admin/drive/clean-remote-files.ts b/packages/backend/src/server/api/endpoints/admin/drive/clean-remote-files.ts index 84c04793..11fce08f 100644 --- a/packages/backend/src/server/api/endpoints/admin/drive/clean-remote-files.ts +++ b/packages/backend/src/server/api/endpoints/admin/drive/clean-remote-files.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { createCleanRemoteFilesJob } from "@/queue/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/drive/cleanup.ts b/packages/backend/src/server/api/endpoints/admin/drive/cleanup.ts index e56c027f..8ba8ae29 100644 --- a/packages/backend/src/server/api/endpoints/admin/drive/cleanup.ts +++ b/packages/backend/src/server/api/endpoints/admin/drive/cleanup.ts @@ -1,7 +1,7 @@ -import { IsNull } from "typeorm"; +import { DriveFiles } from "@/models/index.js"; import define from "@/server/api/define.js"; import { deleteFile } from "@/services/drive/delete-file.js"; -import { DriveFiles } from "@/models/index.js"; +import { IsNull } from "typeorm"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/drive/files.ts b/packages/backend/src/server/api/endpoints/admin/drive/files.ts index e068f1dc..861c7bc9 100644 --- a/packages/backend/src/server/api/endpoints/admin/drive/files.ts +++ b/packages/backend/src/server/api/endpoints/admin/drive/files.ts @@ -1,6 +1,6 @@ import { DriveFiles } from "@/models/index.js"; -import define from "@/server/api/define.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/add-aliases-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/add-aliases-bulk.ts index 9153a644..96591289 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/add-aliases-bulk.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/add-aliases-bulk.ts @@ -1,7 +1,7 @@ -import define from "@/server/api/define.js"; -import { Emojis } from "@/models/index.js"; -import { In } from "typeorm"; import { db } from "@/db/postgre.js"; +import { Emojis } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { In } from "typeorm"; export const meta = { tags: ["admin", "emoji"], @@ -60,5 +60,5 @@ export default define(meta, paramDef, async (ps, me) => { }); } - await db.queryResultCache!.remove(["meta_emojis"]); + await db.queryResultCache?.remove(["meta_emojis"]); }); diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/add.ts b/packages/backend/src/server/api/endpoints/admin/emoji/add.ts index d2bb420a..aee2aa42 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/add.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/add.ts @@ -1,12 +1,12 @@ -import define from "@/server/api/define.js"; -import { Emojis, DriveFiles } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; -import { insertModerationLog } from "@/services/insert-moderation-log.js"; -import { ApiError } from "@/server/api/error.js"; -import rndstr from "rndstr"; -import { publishBroadcastStream } from "@/services/stream.js"; import { db } from "@/db/postgre.js"; import { getEmojiSize } from "@/misc/emoji-meta.js"; +import { genId } from "@/misc/gen-id.js"; +import { DriveFiles, Emojis } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; +import { insertModerationLog } from "@/services/insert-moderation-log.js"; +import { publishBroadcastStream } from "@/services/stream.js"; +import rndstr from "rndstr"; export const meta = { tags: ["admin", "emoji"], @@ -66,7 +66,7 @@ export default define(meta, paramDef, async (ps, me) => { height: size.height || null, }).then((x) => Emojis.findOneByOrFail(x.identifiers[0])); - await db.queryResultCache!.remove(["meta_emojis"]); + await db.queryResultCache?.remove(["meta_emojis"]); publishBroadcastStream("emojiAdded", { emoji: await Emojis.pack(emoji.id), diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts b/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts index c4e32ff4..bd09dd4b 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts @@ -1,12 +1,12 @@ -import define from "@/server/api/define.js"; -import { Emojis } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; -import { ApiError } from "@/server/api/error.js"; -import type { DriveFile } from "@/models/entities/drive-file.js"; -import { uploadFromUrl } from "@/services/drive/upload-from-url.js"; -import { publishBroadcastStream } from "@/services/stream.js"; import { db } from "@/db/postgre.js"; import { getEmojiSize } from "@/misc/emoji-meta.js"; +import { genId } from "@/misc/gen-id.js"; +import type { DriveFile } from "@/models/entities/drive-file.js"; +import { Emojis } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; +import { uploadFromUrl } from "@/services/drive/upload-from-url.js"; +import { publishBroadcastStream } from "@/services/stream.js"; export const meta = { tags: ["admin", "emoji"], @@ -92,7 +92,7 @@ export default define(meta, paramDef, async (ps, me) => { height: size.height || null, }).then((x) => Emojis.findOneByOrFail(x.identifiers[0])); - await db.queryResultCache!.remove(["meta_emojis"]); + await db.queryResultCache?.remove(["meta_emojis"]); publishBroadcastStream("emojiAdded", { emoji: await Emojis.pack(copied.id), diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts index 59dadb14..483b3edb 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts @@ -1,8 +1,8 @@ -import define from "@/server/api/define.js"; -import { Emojis } from "@/models/index.js"; -import { In } from "typeorm"; -import { insertModerationLog } from "@/services/insert-moderation-log.js"; import { db } from "@/db/postgre.js"; +import { Emojis } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { insertModerationLog } from "@/services/insert-moderation-log.js"; +import { In } from "typeorm"; export const meta = { tags: ["admin", "emoji"], @@ -45,7 +45,7 @@ export default define(meta, paramDef, async (ps, me) => { for (const emoji of emojis) { await Emojis.delete(emoji.id); - await db.queryResultCache!.remove(["meta_emojis"]); + await db.queryResultCache?.remove(["meta_emojis"]); insertModerationLog(me, "deleteEmoji", { emoji: emoji, diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts b/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts index 0dfe9603..87e846d5 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts @@ -1,8 +1,8 @@ -import define from "@/server/api/define.js"; -import { Emojis } from "@/models/index.js"; -import { insertModerationLog } from "@/services/insert-moderation-log.js"; -import { ApiError } from "@/server/api/error.js"; import { db } from "@/db/postgre.js"; +import { Emojis } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; +import { insertModerationLog } from "@/services/insert-moderation-log.js"; export const meta = { tags: ["admin", "emoji"], @@ -43,7 +43,7 @@ export default define(meta, paramDef, async (ps, me) => { await Emojis.delete(emoji.id); - await db.queryResultCache!.remove(["meta_emojis"]); + await db.queryResultCache?.remove(["meta_emojis"]); insertModerationLog(me, "deleteEmoji", { emoji: emoji, diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts b/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts index 7e65203a..0bd97190 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { createImportCustomEmojisJob } from "@/queue/index.js"; +import define from "@/server/api/define.js"; import { ApiError } from "../../../error.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts b/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts index 85cc8c1a..07760e9e 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts @@ -1,8 +1,8 @@ -import define from "@/server/api/define.js"; -import { Emojis } from "@/models/index.js"; import { toPuny } from "@/misc/convert-host.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; import { sqlLikeEscape } from "@/misc/sql-like-escape.js"; +import { Emojis } from "@/models/index.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; import { ApiError } from "../../../error.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/list.ts b/packages/backend/src/server/api/endpoints/admin/emoji/list.ts index 206a2809..9895d00c 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/list.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/list.ts @@ -1,7 +1,7 @@ -import define from "@/server/api/define.js"; -import { Emojis } from "@/models/index.js"; -import { makePaginationQuery } from "../../../common/make-pagination-query.js"; import type { Emoji } from "@/models/entities/emoji.js"; +import { Emojis } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { makePaginationQuery } from "../../../common/make-pagination-query.js"; //import { sqlLikeEscape } from "@/misc/sql-like-escape.js"; import { ApiError } from "../../../error.js"; diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/remove-aliases-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/remove-aliases-bulk.ts index 980e7ca1..986b0aec 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/remove-aliases-bulk.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/remove-aliases-bulk.ts @@ -1,7 +1,7 @@ -import define from "@/server/api/define.js"; -import { Emojis } from "@/models/index.js"; -import { In } from "typeorm"; import { db } from "@/db/postgre.js"; +import { Emojis } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { In } from "typeorm"; export const meta = { tags: ["admin"], @@ -56,5 +56,5 @@ export default define(meta, paramDef, async (ps, me) => { }); } - await db.queryResultCache!.remove(["meta_emojis"]); + await db.queryResultCache?.remove(["meta_emojis"]); }); diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/set-aliases-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/set-aliases-bulk.ts index d5dbb573..5cff14bc 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/set-aliases-bulk.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/set-aliases-bulk.ts @@ -1,7 +1,7 @@ -import define from "@/server/api/define.js"; -import { Emojis } from "@/models/index.js"; -import { In } from "typeorm"; import { db } from "@/db/postgre.js"; +import { Emojis } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { In } from "typeorm"; export const meta = { tags: ["admin", "emoji"], @@ -63,5 +63,5 @@ export default define(meta, paramDef, async (ps, me) => { }, ); - await db.queryResultCache!.remove(["meta_emojis"]); + await db.queryResultCache?.remove(["meta_emojis"]); }); diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/set-category-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/set-category-bulk.ts index 9b087009..8d473147 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/set-category-bulk.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/set-category-bulk.ts @@ -1,7 +1,7 @@ -import define from "@/server/api/define.js"; -import { Emojis } from "@/models/index.js"; -import { In } from "typeorm"; import { db } from "@/db/postgre.js"; +import { Emojis } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { In } from "typeorm"; export const meta = { tags: ["admin", "emoji"], @@ -61,5 +61,5 @@ export default define(meta, paramDef, async (ps, me) => { }, ); - await db.queryResultCache!.remove(["meta_emojis"]); + await db.queryResultCache?.remove(["meta_emojis"]); }); diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/set-license-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/set-license-bulk.ts index c8be42ff..fac36d09 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/set-license-bulk.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/set-license-bulk.ts @@ -1,7 +1,7 @@ -import define from "@/server/api/define.js"; -import { Emojis } from "@/models/index.js"; -import { In } from "typeorm"; import { db } from "@/db/postgre.js"; +import { Emojis } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { In } from "typeorm"; export const meta = { tags: ["admin", "emoji"], @@ -61,5 +61,5 @@ export default define(meta, paramDef, async (ps, me) => { }, ); - await db.queryResultCache!.remove(["meta_emojis"]); + await db.queryResultCache?.remove(["meta_emojis"]); }); diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/update.ts b/packages/backend/src/server/api/endpoints/admin/emoji/update.ts index 25e6b111..e9c78a96 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/update.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/update.ts @@ -1,7 +1,7 @@ -import define from "@/server/api/define.js"; -import { Emojis } from "@/models/index.js"; -import { ApiError } from "@/server/api/error.js"; import { db } from "@/db/postgre.js"; +import { Emojis } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; export const meta = { tags: ["admin", "emoji"], @@ -72,5 +72,5 @@ export default define(meta, paramDef, async (ps, me) => { license: ps.license, }); - await db.queryResultCache!.remove(["meta_emojis"]); + await db.queryResultCache?.remove(["meta_emojis"]); }); diff --git a/packages/backend/src/server/api/endpoints/admin/federation/delete-all-files.ts b/packages/backend/src/server/api/endpoints/admin/federation/delete-all-files.ts index d1a7fb69..714cbc46 100644 --- a/packages/backend/src/server/api/endpoints/admin/federation/delete-all-files.ts +++ b/packages/backend/src/server/api/endpoints/admin/federation/delete-all-files.ts @@ -1,6 +1,6 @@ +import { DriveFiles } from "@/models/index.js"; import define from "@/server/api/define.js"; import { deleteFile } from "@/services/drive/delete-file.js"; -import { DriveFiles } from "@/models/index.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/federation/refresh-remote-instance-metadata.ts b/packages/backend/src/server/api/endpoints/admin/federation/refresh-remote-instance-metadata.ts index bf71cd25..9127df49 100644 --- a/packages/backend/src/server/api/endpoints/admin/federation/refresh-remote-instance-metadata.ts +++ b/packages/backend/src/server/api/endpoints/admin/federation/refresh-remote-instance-metadata.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; -import { Instances } from "@/models/index.js"; import { toPuny } from "@/misc/convert-host.js"; +import { Instances } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { fetchInstanceMetadata } from "@/services/fetch-instance-metadata.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts b/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts index a2ce44bd..ffd8ec67 100644 --- a/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts +++ b/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts @@ -1,6 +1,6 @@ +import { Followings, Users } from "@/models/index.js"; import define from "@/server/api/define.js"; import deleteFollowing from "@/services/following/delete.js"; -import { Followings, Users } from "@/models/index.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/federation/update-instance.ts b/packages/backend/src/server/api/endpoints/admin/federation/update-instance.ts index 653d187c..7893cb40 100644 --- a/packages/backend/src/server/api/endpoints/admin/federation/update-instance.ts +++ b/packages/backend/src/server/api/endpoints/admin/federation/update-instance.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; -import { Instances } from "@/models/index.js"; import { toPuny } from "@/misc/convert-host.js"; +import { Instances } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts b/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts index 98f1f024..f50697a4 100644 --- a/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts +++ b/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { db } from "@/db/postgre.js"; +import define from "@/server/api/define.js"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/admin/invite.ts b/packages/backend/src/server/api/endpoints/admin/invite.ts index ebc523d4..ce543719 100644 --- a/packages/backend/src/server/api/endpoints/admin/invite.ts +++ b/packages/backend/src/server/api/endpoints/admin/invite.ts @@ -1,7 +1,7 @@ -import rndstr from "rndstr"; -import define from "@/server/api/define.js"; -import { RegistrationTickets } from "@/models/index.js"; import { genId } from "@/misc/gen-id.js"; +import { RegistrationTickets } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import rndstr from "rndstr"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/meta.ts b/packages/backend/src/server/api/endpoints/admin/meta.ts index 6f23ef18..64fd38ee 100644 --- a/packages/backend/src/server/api/endpoints/admin/meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/meta.ts @@ -1,6 +1,6 @@ import config from "@/config/index.js"; +import { MAX_CAPTION_TEXT_LENGTH, MAX_NOTE_TEXT_LENGTH } from "@/const.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; -import { MAX_NOTE_TEXT_LENGTH, MAX_CAPTION_TEXT_LENGTH } from "@/const.js"; import define from "@/server/api/define.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/admin/moderators/add.ts b/packages/backend/src/server/api/endpoints/admin/moderators/add.ts index c8b53088..a4b90cac 100644 --- a/packages/backend/src/server/api/endpoints/admin/moderators/add.ts +++ b/packages/backend/src/server/api/endpoints/admin/moderators/add.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { Users } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { publishInternalEvent } from "@/services/stream.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/admin/moderators/remove.ts b/packages/backend/src/server/api/endpoints/admin/moderators/remove.ts index e2af1ca3..6e4dadb9 100644 --- a/packages/backend/src/server/api/endpoints/admin/moderators/remove.ts +++ b/packages/backend/src/server/api/endpoints/admin/moderators/remove.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { Users } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { publishInternalEvent } from "@/services/stream.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/admin/promo/create.ts b/packages/backend/src/server/api/endpoints/admin/promo/create.ts index 55038fc8..e93c6659 100644 --- a/packages/backend/src/server/api/endpoints/admin/promo/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/promo/create.ts @@ -1,7 +1,7 @@ +import { PromoNotes } from "@/models/index.js"; +import { getNote } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getNote } from "@/server/api/common/getters.js"; -import { PromoNotes } from "@/models/index.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/queue/clear.ts b/packages/backend/src/server/api/endpoints/admin/queue/clear.ts index 9895f34b..9d83eda4 100644 --- a/packages/backend/src/server/api/endpoints/admin/queue/clear.ts +++ b/packages/backend/src/server/api/endpoints/admin/queue/clear.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { destroy } from "@/queue/index.js"; +import define from "@/server/api/define.js"; import { insertModerationLog } from "@/services/insert-moderation-log.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/admin/queue/deliver-delayed.ts b/packages/backend/src/server/api/endpoints/admin/queue/deliver-delayed.ts index ea8c5056..8222b067 100644 --- a/packages/backend/src/server/api/endpoints/admin/queue/deliver-delayed.ts +++ b/packages/backend/src/server/api/endpoints/admin/queue/deliver-delayed.ts @@ -1,5 +1,5 @@ -import { deliverQueue } from "@/queue/queues.js"; import { URL } from "node:url"; +import { deliverQueue } from "@/queue/queues.js"; import define from "@/server/api/define.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/admin/queue/inbox-delayed.ts b/packages/backend/src/server/api/endpoints/admin/queue/inbox-delayed.ts index d4f44e30..bfa2bb08 100644 --- a/packages/backend/src/server/api/endpoints/admin/queue/inbox-delayed.ts +++ b/packages/backend/src/server/api/endpoints/admin/queue/inbox-delayed.ts @@ -1,6 +1,6 @@ import { URL } from "node:url"; -import define from "@/server/api/define.js"; import { inboxQueue } from "@/queue/queues.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/queue/stats.ts b/packages/backend/src/server/api/endpoints/admin/queue/stats.ts index f51c1e6d..c8459d80 100644 --- a/packages/backend/src/server/api/endpoints/admin/queue/stats.ts +++ b/packages/backend/src/server/api/endpoints/admin/queue/stats.ts @@ -1,9 +1,9 @@ import { + backgroundQueue, + dbQueue, deliverQueue, inboxQueue, - dbQueue, objectStorageQueue, - backgroundQueue, } from "@/queue/queues.js"; import define from "@/server/api/define.js"; diff --git a/packages/backend/src/server/api/endpoints/admin/relays/add.ts b/packages/backend/src/server/api/endpoints/admin/relays/add.ts index ac008486..16272e4a 100644 --- a/packages/backend/src/server/api/endpoints/admin/relays/add.ts +++ b/packages/backend/src/server/api/endpoints/admin/relays/add.ts @@ -1,7 +1,7 @@ import { URL } from "node:url"; import define from "@/server/api/define.js"; -import { addRelay } from "@/services/relay.js"; import { ApiError } from "@/server/api/error.js"; +import { addRelay } from "@/services/relay.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/reset-password.ts b/packages/backend/src/server/api/endpoints/admin/reset-password.ts index 5fbed130..245945dd 100644 --- a/packages/backend/src/server/api/endpoints/admin/reset-password.ts +++ b/packages/backend/src/server/api/endpoints/admin/reset-password.ts @@ -1,8 +1,8 @@ +import { hashPassword } from "@/misc/password.js"; +import { UserProfiles, Users } from "@/models/index.js"; import define from "@/server/api/define.js"; // import bcrypt from "bcryptjs"; import rndstr from "rndstr"; -import { Users, UserProfiles } from "@/models/index.js"; -import { hashPassword } from "@/misc/password.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts b/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts index a94687cf..ae2b5c95 100644 --- a/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts +++ b/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts @@ -1,9 +1,9 @@ -import define from "@/server/api/define.js"; import { AbuseUserReports, Users } from "@/models/index.js"; -import { getInstanceActor } from "@/services/instance-actor.js"; import { deliver } from "@/queue/index.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import { renderFlag } from "@/remote/activitypub/renderer/flag.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import define from "@/server/api/define.js"; +import { getInstanceActor } from "@/services/instance-actor.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/search/index-all.ts b/packages/backend/src/server/api/endpoints/admin/search/index-all.ts index 53142884..065fa04b 100644 --- a/packages/backend/src/server/api/endpoints/admin/search/index-all.ts +++ b/packages/backend/src/server/api/endpoints/admin/search/index-all.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { createIndexAllNotesJob } from "@/queue/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/send-mod-mail.ts b/packages/backend/src/server/api/endpoints/admin/send-mod-mail.ts index 5dcbaf2e..2c532af4 100644 --- a/packages/backend/src/server/api/endpoints/admin/send-mod-mail.ts +++ b/packages/backend/src/server/api/endpoints/admin/send-mod-mail.ts @@ -1,9 +1,9 @@ -import sanitizeHtml from "sanitize-html"; +import { UserProfiles, Users } from "@/models/index.js"; import define from "@/server/api/define.js"; -import { Users, UserProfiles } from "@/models/index.js"; import { ApiError } from "@/server/api/error.js"; -import { sendEmail } from "@/services/send-email.js"; import { createNotification } from "@/services/create-notification.js"; +import { sendEmail } from "@/services/send-email.js"; +import sanitizeHtml from "sanitize-html"; export const meta = { tags: ["users"], diff --git a/packages/backend/src/server/api/endpoints/admin/server-info.ts b/packages/backend/src/server/api/endpoints/admin/server-info.ts index ff469196..002d590d 100644 --- a/packages/backend/src/server/api/endpoints/admin/server-info.ts +++ b/packages/backend/src/server/api/endpoints/admin/server-info.ts @@ -1,8 +1,8 @@ import * as os from "node:os"; -import si from "systeminformation"; -import define from "@/server/api/define.js"; -import { redisClient } from "@/db/redis.js"; import { db } from "@/db/postgre.js"; +import { redisClient } from "@/db/redis.js"; +import define from "@/server/api/define.js"; +import si from "systeminformation"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/admin/set-emoji-moderator.ts b/packages/backend/src/server/api/endpoints/admin/set-emoji-moderator.ts index f821a54f..0bc79c03 100644 --- a/packages/backend/src/server/api/endpoints/admin/set-emoji-moderator.ts +++ b/packages/backend/src/server/api/endpoints/admin/set-emoji-moderator.ts @@ -1,6 +1,6 @@ -import define from "../../define.js"; import { Users } from "@/models/index.js"; import { publishInternalEvent } from "@/services/stream.js"; +import define from "../../define.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts b/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts index adceda41..ed8c6761 100644 --- a/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts +++ b/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; import { ModerationLogs } from "@/models/index.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/show-users.ts b/packages/backend/src/server/api/endpoints/admin/show-users.ts index 1e6ebeda..9997db04 100644 --- a/packages/backend/src/server/api/endpoints/admin/show-users.ts +++ b/packages/backend/src/server/api/endpoints/admin/show-users.ts @@ -1,6 +1,6 @@ +import { sqlLikeEscape } from "@/misc/sql-like-escape.js"; import { Users } from "@/models/index.js"; import define from "@/server/api/define.js"; -import { sqlLikeEscape } from "@/misc/sql-like-escape.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/silence-user.ts b/packages/backend/src/server/api/endpoints/admin/silence-user.ts index 8d9dcac6..758fa803 100644 --- a/packages/backend/src/server/api/endpoints/admin/silence-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/silence-user.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { Users } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { insertModerationLog } from "@/services/insert-moderation-log.js"; import { publishInternalEvent } from "@/services/stream.js"; diff --git a/packages/backend/src/server/api/endpoints/admin/suspend-user.ts b/packages/backend/src/server/api/endpoints/admin/suspend-user.ts index c6d6f47b..600fe085 100644 --- a/packages/backend/src/server/api/endpoints/admin/suspend-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/suspend-user.ts @@ -1,10 +1,10 @@ +import type { User } from "@/models/entities/user.js"; +import { Followings, Notifications, Users } from "@/models/index.js"; import define from "@/server/api/define.js"; import deleteFollowing from "@/services/following/delete.js"; -import { Users, Followings, Notifications } from "@/models/index.js"; -import type { User } from "@/models/entities/user.js"; import { insertModerationLog } from "@/services/insert-moderation-log.js"; -import { doPostSuspend } from "@/services/suspend-user.js"; import { publishUserEvent } from "@/services/stream.js"; +import { doPostSuspend } from "@/services/suspend-user.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/unsilence-user.ts b/packages/backend/src/server/api/endpoints/admin/unsilence-user.ts index 6592bf44..0e6ea19f 100644 --- a/packages/backend/src/server/api/endpoints/admin/unsilence-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/unsilence-user.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { Users } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { insertModerationLog } from "@/services/insert-moderation-log.js"; import { publishInternalEvent } from "@/services/stream.js"; diff --git a/packages/backend/src/server/api/endpoints/admin/unsuspend-user.ts b/packages/backend/src/server/api/endpoints/admin/unsuspend-user.ts index 3289fb57..bf0a709a 100644 --- a/packages/backend/src/server/api/endpoints/admin/unsuspend-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/unsuspend-user.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { Users } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { insertModerationLog } from "@/services/insert-moderation-log.js"; import { doPostUnsuspend } from "@/services/unsuspend-user.js"; diff --git a/packages/backend/src/server/api/endpoints/admin/update-meta.ts b/packages/backend/src/server/api/endpoints/admin/update-meta.ts index 422cf49f..47786bae 100644 --- a/packages/backend/src/server/api/endpoints/admin/update-meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/update-meta.ts @@ -1,7 +1,7 @@ -import { Meta } from "@/models/entities/meta.js"; -import { insertModerationLog } from "@/services/insert-moderation-log.js"; import { db } from "@/db/postgre.js"; +import { Meta } from "@/models/entities/meta.js"; import define from "@/server/api/define.js"; +import { insertModerationLog } from "@/services/insert-moderation-log.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/admin/vacuum.ts b/packages/backend/src/server/api/endpoints/admin/vacuum.ts index d5b086bb..3a3ba352 100644 --- a/packages/backend/src/server/api/endpoints/admin/vacuum.ts +++ b/packages/backend/src/server/api/endpoints/admin/vacuum.ts @@ -1,6 +1,6 @@ +import { db } from "@/db/postgre.js"; import define from "@/server/api/define.js"; import { insertModerationLog } from "@/services/insert-moderation-log.js"; -import { db } from "@/db/postgre.js"; export const meta = { tags: ["admin"], diff --git a/packages/backend/src/server/api/endpoints/announcements.ts b/packages/backend/src/server/api/endpoints/announcements.ts index 504eb30e..bc2f197b 100644 --- a/packages/backend/src/server/api/endpoints/announcements.ts +++ b/packages/backend/src/server/api/endpoints/announcements.ts @@ -1,6 +1,6 @@ -import { Announcements, AnnouncementReads } from "@/models/index.js"; -import define from "@/server/api/define.js"; +import { AnnouncementReads, Announcements } from "@/models/index.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["meta"], diff --git a/packages/backend/src/server/api/endpoints/antennas/create.ts b/packages/backend/src/server/api/endpoints/antennas/create.ts index 46df3aa8..52ed6282 100644 --- a/packages/backend/src/server/api/endpoints/antennas/create.ts +++ b/packages/backend/src/server/api/endpoints/antennas/create.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; import { genId } from "@/misc/gen-id.js"; -import { Antennas, UserLists, UserGroupJoinings } from "@/models/index.js"; +import { Antennas, UserGroupJoinings, UserLists } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; import { publishInternalEvent } from "@/services/stream.js"; diff --git a/packages/backend/src/server/api/endpoints/antennas/delete.ts b/packages/backend/src/server/api/endpoints/antennas/delete.ts index e5a372f1..e2380f23 100644 --- a/packages/backend/src/server/api/endpoints/antennas/delete.ts +++ b/packages/backend/src/server/api/endpoints/antennas/delete.ts @@ -1,6 +1,6 @@ +import { Antennas } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Antennas } from "@/models/index.js"; import { publishInternalEvent } from "@/services/stream.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/antennas/list.ts b/packages/backend/src/server/api/endpoints/antennas/list.ts index 2726ecc8..91ef9942 100644 --- a/packages/backend/src/server/api/endpoints/antennas/list.ts +++ b/packages/backend/src/server/api/endpoints/antennas/list.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { Antennas } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["antennas", "account"], diff --git a/packages/backend/src/server/api/endpoints/antennas/markread.ts b/packages/backend/src/server/api/endpoints/antennas/markread.ts index bb5b5b77..f552f345 100644 --- a/packages/backend/src/server/api/endpoints/antennas/markread.ts +++ b/packages/backend/src/server/api/endpoints/antennas/markread.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { Antennas } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["antennas", "account"], diff --git a/packages/backend/src/server/api/endpoints/antennas/notes.ts b/packages/backend/src/server/api/endpoints/antennas/notes.ts index cbe03185..ac3217b7 100644 --- a/packages/backend/src/server/api/endpoints/antennas/notes.ts +++ b/packages/backend/src/server/api/endpoints/antennas/notes.ts @@ -1,13 +1,13 @@ -import define from "@/server/api/define.js"; -import readNote from "@/services/note/read.js"; -import { Antennas, Notes } from "@/models/index.js"; import { redisClient } from "@/db/redis.js"; import { getTimestamp } from "@/misc/gen-id.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; -import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; -import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; -import { ApiError } from "@/server/api/error.js"; +import { Antennas, Notes } from "@/models/index.js"; import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; +import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; +import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; +import readNote from "@/services/note/read.js"; export const meta = { tags: ["antennas", "account", "notes"], diff --git a/packages/backend/src/server/api/endpoints/antennas/show.ts b/packages/backend/src/server/api/endpoints/antennas/show.ts index 3700052f..c7f8e99c 100644 --- a/packages/backend/src/server/api/endpoints/antennas/show.ts +++ b/packages/backend/src/server/api/endpoints/antennas/show.ts @@ -1,6 +1,6 @@ +import { Antennas } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Antennas } from "@/models/index.js"; export const meta = { tags: ["antennas", "account"], diff --git a/packages/backend/src/server/api/endpoints/antennas/update.ts b/packages/backend/src/server/api/endpoints/antennas/update.ts index 9a71a8f9..a9460761 100644 --- a/packages/backend/src/server/api/endpoints/antennas/update.ts +++ b/packages/backend/src/server/api/endpoints/antennas/update.ts @@ -1,6 +1,6 @@ +import { Antennas, UserGroupJoinings, UserLists } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Antennas, UserLists, UserGroupJoinings } from "@/models/index.js"; import { publishInternalEvent } from "@/services/stream.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/ap/get.ts b/packages/backend/src/server/api/endpoints/ap/get.ts index 5159ce3b..3d2cceb4 100644 --- a/packages/backend/src/server/api/endpoints/ap/get.ts +++ b/packages/backend/src/server/api/endpoints/ap/get.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; -import Resolver from "@/remote/activitypub/resolver.js"; import { HOUR } from "@/const.js"; +import Resolver from "@/remote/activitypub/resolver.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["federation"], diff --git a/packages/backend/src/server/api/endpoints/ap/show.ts b/packages/backend/src/server/api/endpoints/ap/show.ts index 50eb7e9c..e3ffc7fa 100644 --- a/packages/backend/src/server/api/endpoints/ap/show.ts +++ b/packages/backend/src/server/api/endpoints/ap/show.ts @@ -1,20 +1,20 @@ -import define from "@/server/api/define.js"; -import { createPerson } from "@/remote/activitypub/models/person.js"; -import { createNote } from "@/remote/activitypub/models/note.js"; -import DbResolver from "@/remote/activitypub/db-resolver.js"; -import Resolver from "@/remote/activitypub/resolver.js"; -import { ApiError } from "@/server/api/error.js"; +import { MINUTE } from "@/const.js"; +import { redisClient } from "@/db/redis.js"; import { extractDbHost } from "@/misc/convert-host.js"; -import { Users, Notes } from "@/models/index.js"; +import type { SchemaType } from "@/misc/schema.js"; +import { shouldBlockInstance } from "@/misc/should-block-instance.js"; import type { Note } from "@/models/entities/note.js"; import type { CacheableLocalUser, User } from "@/models/entities/user.js"; -import { isActor, isPost, getApId } from "@/remote/activitypub/type.js"; -import type { SchemaType } from "@/misc/schema.js"; -import { MINUTE } from "@/const.js"; -import { shouldBlockInstance } from "@/misc/should-block-instance.js"; -import { updateQuestion } from "@/remote/activitypub/models/question.js"; +import { Notes, Users } from "@/models/index.js"; import { populatePoll } from "@/models/repositories/note.js"; -import { redisClient } from "@/db/redis.js"; +import DbResolver from "@/remote/activitypub/db-resolver.js"; +import { createNote } from "@/remote/activitypub/models/note.js"; +import { createPerson } from "@/remote/activitypub/models/person.js"; +import { updateQuestion } from "@/remote/activitypub/models/question.js"; +import Resolver from "@/remote/activitypub/resolver.js"; +import { getApId, isActor, isPost } from "@/remote/activitypub/type.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; export const meta = { tags: ["federation"], diff --git a/packages/backend/src/server/api/endpoints/app/create.ts b/packages/backend/src/server/api/endpoints/app/create.ts index e32edf12..82e03754 100644 --- a/packages/backend/src/server/api/endpoints/app/create.ts +++ b/packages/backend/src/server/api/endpoints/app/create.ts @@ -1,8 +1,8 @@ -import define from "@/server/api/define.js"; -import { Apps } from "@/models/index.js"; import { genId } from "@/misc/gen-id.js"; -import { unique } from "@/prelude/array.js"; import { secureRndstr } from "@/misc/secure-rndstr.js"; +import { Apps } from "@/models/index.js"; +import { unique } from "@/prelude/array.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["app"], diff --git a/packages/backend/src/server/api/endpoints/app/show.ts b/packages/backend/src/server/api/endpoints/app/show.ts index d6f38428..4a09f270 100644 --- a/packages/backend/src/server/api/endpoints/app/show.ts +++ b/packages/backend/src/server/api/endpoints/app/show.ts @@ -1,6 +1,6 @@ +import { Apps } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Apps } from "@/models/index.js"; export const meta = { tags: ["app"], @@ -41,6 +41,6 @@ export default define(meta, paramDef, async (ps, user, token) => { return await Apps.pack(ap, user, { detail: true, - includeSecret: isSecure && ap.userId === user!.id, + includeSecret: isSecure && ap.userId === user?.id, }); }); diff --git a/packages/backend/src/server/api/endpoints/auth/accept.ts b/packages/backend/src/server/api/endpoints/auth/accept.ts index 088de786..40b9841a 100644 --- a/packages/backend/src/server/api/endpoints/auth/accept.ts +++ b/packages/backend/src/server/api/endpoints/auth/accept.ts @@ -1,9 +1,9 @@ import * as crypto from "node:crypto"; -import define from "@/server/api/define.js"; -import { ApiError } from "@/server/api/error.js"; -import { AuthSessions, AccessTokens, Apps } from "@/models/index.js"; import { genId } from "@/misc/gen-id.js"; import { secureRndstr } from "@/misc/secure-rndstr.js"; +import { AccessTokens, Apps, AuthSessions } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; export const meta = { tags: ["auth"], diff --git a/packages/backend/src/server/api/endpoints/auth/session/generate.ts b/packages/backend/src/server/api/endpoints/auth/session/generate.ts index bd172110..b95256eb 100644 --- a/packages/backend/src/server/api/endpoints/auth/session/generate.ts +++ b/packages/backend/src/server/api/endpoints/auth/session/generate.ts @@ -1,9 +1,9 @@ -import { v4 as uuid } from "uuid"; import config from "@/config/index.js"; +import { genId } from "@/misc/gen-id.js"; +import { Apps, AuthSessions } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Apps, AuthSessions } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; +import { v4 as uuid } from "uuid"; export const meta = { tags: ["auth"], diff --git a/packages/backend/src/server/api/endpoints/auth/session/show.ts b/packages/backend/src/server/api/endpoints/auth/session/show.ts index 70c6d54c..4e511d50 100644 --- a/packages/backend/src/server/api/endpoints/auth/session/show.ts +++ b/packages/backend/src/server/api/endpoints/auth/session/show.ts @@ -1,6 +1,6 @@ +import { AuthSessions } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { AuthSessions } from "@/models/index.js"; export const meta = { tags: ["auth"], diff --git a/packages/backend/src/server/api/endpoints/auth/session/userkey.ts b/packages/backend/src/server/api/endpoints/auth/session/userkey.ts index 39468151..ab17f782 100644 --- a/packages/backend/src/server/api/endpoints/auth/session/userkey.ts +++ b/packages/backend/src/server/api/endpoints/auth/session/userkey.ts @@ -1,6 +1,6 @@ +import { AccessTokens, Apps, AuthSessions, Users } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Apps, AuthSessions, AccessTokens, Users } from "@/models/index.js"; export const meta = { tags: ["auth"], diff --git a/packages/backend/src/server/api/endpoints/blocking/create.ts b/packages/backend/src/server/api/endpoints/blocking/create.ts index 50154dd6..bbf941ae 100644 --- a/packages/backend/src/server/api/endpoints/blocking/create.ts +++ b/packages/backend/src/server/api/endpoints/blocking/create.ts @@ -1,9 +1,9 @@ -import create from "@/services/blocking/create.js"; +import { HOUR } from "@/const.js"; +import { Blockings, NoteWatchings, Users } from "@/models/index.js"; +import { getUser } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; -import { Blockings, NoteWatchings, Users } from "@/models/index.js"; -import { HOUR } from "@/const.js"; +import create from "@/services/blocking/create.js"; export const meta = { tags: ["account"], diff --git a/packages/backend/src/server/api/endpoints/blocking/delete.ts b/packages/backend/src/server/api/endpoints/blocking/delete.ts index addf4bbd..6f23bba2 100644 --- a/packages/backend/src/server/api/endpoints/blocking/delete.ts +++ b/packages/backend/src/server/api/endpoints/blocking/delete.ts @@ -1,9 +1,9 @@ -import deleteBlocking from "@/services/blocking/delete.js"; +import { HOUR } from "@/const.js"; +import { Blockings, Users } from "@/models/index.js"; +import { getUser } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; -import { Blockings, Users } from "@/models/index.js"; -import { HOUR } from "@/const.js"; +import deleteBlocking from "@/services/blocking/delete.js"; export const meta = { tags: ["account"], diff --git a/packages/backend/src/server/api/endpoints/blocking/list.ts b/packages/backend/src/server/api/endpoints/blocking/list.ts index 6f51a645..cd04b20e 100644 --- a/packages/backend/src/server/api/endpoints/blocking/list.ts +++ b/packages/backend/src/server/api/endpoints/blocking/list.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; import { Blockings } from "@/models/index.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["account"], diff --git a/packages/backend/src/server/api/endpoints/channels/create.ts b/packages/backend/src/server/api/endpoints/channels/create.ts index 177492ed..18630846 100644 --- a/packages/backend/src/server/api/endpoints/channels/create.ts +++ b/packages/backend/src/server/api/endpoints/channels/create.ts @@ -1,8 +1,8 @@ +import { genId } from "@/misc/gen-id.js"; +import type { Channel } from "@/models/entities/channel.js"; +import { Channels, DriveFiles } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Channels, DriveFiles } from "@/models/index.js"; -import type { Channel } from "@/models/entities/channel.js"; -import { genId } from "@/misc/gen-id.js"; export const meta = { tags: ["channels"], diff --git a/packages/backend/src/server/api/endpoints/channels/featured.ts b/packages/backend/src/server/api/endpoints/channels/featured.ts index e0575af2..b5fb5e20 100644 --- a/packages/backend/src/server/api/endpoints/channels/featured.ts +++ b/packages/backend/src/server/api/endpoints/channels/featured.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { Channels } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["channels"], diff --git a/packages/backend/src/server/api/endpoints/channels/follow.ts b/packages/backend/src/server/api/endpoints/channels/follow.ts index 87833982..4debfb08 100644 --- a/packages/backend/src/server/api/endpoints/channels/follow.ts +++ b/packages/backend/src/server/api/endpoints/channels/follow.ts @@ -1,7 +1,7 @@ +import { genId } from "@/misc/gen-id.js"; +import { ChannelFollowings, Channels } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Channels, ChannelFollowings } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; import { publishUserEvent } from "@/services/stream.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/channels/followed.ts b/packages/backend/src/server/api/endpoints/channels/followed.ts index 94374f6b..524952c6 100644 --- a/packages/backend/src/server/api/endpoints/channels/followed.ts +++ b/packages/backend/src/server/api/endpoints/channels/followed.ts @@ -1,5 +1,5 @@ +import { ChannelFollowings, Channels } from "@/models/index.js"; import define from "@/server/api/define.js"; -import { Channels, ChannelFollowings } from "@/models/index.js"; export const meta = { tags: ["channels", "account"], diff --git a/packages/backend/src/server/api/endpoints/channels/owned.ts b/packages/backend/src/server/api/endpoints/channels/owned.ts index 23607b02..c1e969df 100644 --- a/packages/backend/src/server/api/endpoints/channels/owned.ts +++ b/packages/backend/src/server/api/endpoints/channels/owned.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; import { Channels } from "@/models/index.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["channels", "account"], diff --git a/packages/backend/src/server/api/endpoints/channels/search.ts b/packages/backend/src/server/api/endpoints/channels/search.ts index b2fab701..f6e0f4d2 100644 --- a/packages/backend/src/server/api/endpoints/channels/search.ts +++ b/packages/backend/src/server/api/endpoints/channels/search.ts @@ -1,8 +1,8 @@ +import { sqlLikeEscape } from "@/misc/sql-like-escape.js"; +import { Channels } from "@/models/index.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; import define from "@/server/api/define.js"; import { Brackets } from "typeorm"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; -import { Channels } from "@/models/index.js"; -import { sqlLikeEscape } from "@/misc/sql-like-escape.js"; export const meta = { tags: ["channels"], diff --git a/packages/backend/src/server/api/endpoints/channels/show.ts b/packages/backend/src/server/api/endpoints/channels/show.ts index c5c1b657..cf1d32ad 100644 --- a/packages/backend/src/server/api/endpoints/channels/show.ts +++ b/packages/backend/src/server/api/endpoints/channels/show.ts @@ -1,6 +1,6 @@ +import { Channels } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Channels } from "@/models/index.js"; export const meta = { tags: ["channels"], diff --git a/packages/backend/src/server/api/endpoints/channels/timeline.ts b/packages/backend/src/server/api/endpoints/channels/timeline.ts index f061acab..93c28be2 100644 --- a/packages/backend/src/server/api/endpoints/channels/timeline.ts +++ b/packages/backend/src/server/api/endpoints/channels/timeline.ts @@ -1,7 +1,7 @@ +import { Channels, Notes } from "@/models/index.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Notes, Channels } from "@/models/index.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; import { activeUsersChart } from "@/services/chart/index.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/channels/unfollow.ts b/packages/backend/src/server/api/endpoints/channels/unfollow.ts index 33710003..4a7a8f07 100644 --- a/packages/backend/src/server/api/endpoints/channels/unfollow.ts +++ b/packages/backend/src/server/api/endpoints/channels/unfollow.ts @@ -1,6 +1,6 @@ +import { ChannelFollowings, Channels } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Channels, ChannelFollowings } from "@/models/index.js"; import { publishUserEvent } from "@/services/stream.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/channels/update.ts b/packages/backend/src/server/api/endpoints/channels/update.ts index 0de7a837..bdd29488 100644 --- a/packages/backend/src/server/api/endpoints/channels/update.ts +++ b/packages/backend/src/server/api/endpoints/channels/update.ts @@ -1,6 +1,6 @@ +import { Channels, DriveFiles } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Channels, DriveFiles } from "@/models/index.js"; export const meta = { tags: ["channels"], diff --git a/packages/backend/src/server/api/endpoints/charts/active-users.ts b/packages/backend/src/server/api/endpoints/charts/active-users.ts index d5c3c4eb..7e705d24 100644 --- a/packages/backend/src/server/api/endpoints/charts/active-users.ts +++ b/packages/backend/src/server/api/endpoints/charts/active-users.ts @@ -1,6 +1,6 @@ +import define from "@/server/api/define.js"; import { getJsonSchema } from "@/services/chart/core.js"; import { activeUsersChart } from "@/services/chart/index.js"; -import define from "@/server/api/define.js"; export const meta = { tags: ["charts", "users"], diff --git a/packages/backend/src/server/api/endpoints/clips/add-note.ts b/packages/backend/src/server/api/endpoints/clips/add-note.ts index 887c8af0..22d40bca 100644 --- a/packages/backend/src/server/api/endpoints/clips/add-note.ts +++ b/packages/backend/src/server/api/endpoints/clips/add-note.ts @@ -1,8 +1,8 @@ -import define from "@/server/api/define.js"; -import { ClipNotes, Clips } from "@/models/index.js"; -import { ApiError } from "@/server/api/error.js"; import { genId } from "@/misc/gen-id.js"; +import { ClipNotes, Clips } from "@/models/index.js"; import { getNote } from "@/server/api/common/getters.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; export const meta = { tags: ["account", "notes", "clips"], diff --git a/packages/backend/src/server/api/endpoints/clips/create.ts b/packages/backend/src/server/api/endpoints/clips/create.ts index df03b87b..92860944 100644 --- a/packages/backend/src/server/api/endpoints/clips/create.ts +++ b/packages/backend/src/server/api/endpoints/clips/create.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; import { genId } from "@/misc/gen-id.js"; import { Clips } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["clips"], diff --git a/packages/backend/src/server/api/endpoints/clips/delete.ts b/packages/backend/src/server/api/endpoints/clips/delete.ts index 02d95b31..7455a236 100644 --- a/packages/backend/src/server/api/endpoints/clips/delete.ts +++ b/packages/backend/src/server/api/endpoints/clips/delete.ts @@ -1,6 +1,6 @@ +import { Clips } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Clips } from "@/models/index.js"; export const meta = { tags: ["clips"], diff --git a/packages/backend/src/server/api/endpoints/clips/list.ts b/packages/backend/src/server/api/endpoints/clips/list.ts index d2762243..f77b5061 100644 --- a/packages/backend/src/server/api/endpoints/clips/list.ts +++ b/packages/backend/src/server/api/endpoints/clips/list.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { Clips } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["clips", "account"], diff --git a/packages/backend/src/server/api/endpoints/clips/notes.ts b/packages/backend/src/server/api/endpoints/clips/notes.ts index 13d8310e..741c89ed 100644 --- a/packages/backend/src/server/api/endpoints/clips/notes.ts +++ b/packages/backend/src/server/api/endpoints/clips/notes.ts @@ -1,10 +1,10 @@ -import define from "@/server/api/define.js"; import { ClipNotes, Clips, Notes } from "@/models/index.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; -import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; -import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; -import { ApiError } from "@/server/api/error.js"; import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; +import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; +import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; export const meta = { tags: ["account", "notes", "clips"], diff --git a/packages/backend/src/server/api/endpoints/clips/remove-note.ts b/packages/backend/src/server/api/endpoints/clips/remove-note.ts index c081a87a..70eb23b7 100644 --- a/packages/backend/src/server/api/endpoints/clips/remove-note.ts +++ b/packages/backend/src/server/api/endpoints/clips/remove-note.ts @@ -1,7 +1,7 @@ -import define from "@/server/api/define.js"; import { ClipNotes, Clips } from "@/models/index.js"; -import { ApiError } from "@/server/api/error.js"; import { getNote } from "@/server/api/common/getters.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; export const meta = { tags: ["account", "notes", "clips"], diff --git a/packages/backend/src/server/api/endpoints/clips/show.ts b/packages/backend/src/server/api/endpoints/clips/show.ts index 8218a4fb..51ed8b81 100644 --- a/packages/backend/src/server/api/endpoints/clips/show.ts +++ b/packages/backend/src/server/api/endpoints/clips/show.ts @@ -1,6 +1,6 @@ +import { Clips } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Clips } from "@/models/index.js"; export const meta = { tags: ["clips", "account"], diff --git a/packages/backend/src/server/api/endpoints/clips/update.ts b/packages/backend/src/server/api/endpoints/clips/update.ts index fc88548b..f2666a42 100644 --- a/packages/backend/src/server/api/endpoints/clips/update.ts +++ b/packages/backend/src/server/api/endpoints/clips/update.ts @@ -1,6 +1,6 @@ +import { Clips } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Clips } from "@/models/index.js"; export const meta = { tags: ["clips"], diff --git a/packages/backend/src/server/api/endpoints/compatibility/custom-emojis.ts b/packages/backend/src/server/api/endpoints/compatibility/custom-emojis.ts index f6c5573a..62fa8429 100644 --- a/packages/backend/src/server/api/endpoints/compatibility/custom-emojis.ts +++ b/packages/backend/src/server/api/endpoints/compatibility/custom-emojis.ts @@ -1,8 +1,8 @@ -import { Emojis } from "@/models/index.js"; -import type { Emoji } from "@/models/entities/emoji.js"; -import { IsNull, In } from "typeorm"; import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; +import type { Emoji } from "@/models/entities/emoji.js"; +import { Emojis } from "@/models/index.js"; import define from "@/server/api/define.js"; +import { In, IsNull } from "typeorm"; export const meta = { requireCredential: false, diff --git a/packages/backend/src/server/api/endpoints/drive/files.ts b/packages/backend/src/server/api/endpoints/drive/files.ts index d5dae876..aa318faf 100644 --- a/packages/backend/src/server/api/endpoints/drive/files.ts +++ b/packages/backend/src/server/api/endpoints/drive/files.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; import { DriveFiles } from "@/models/index.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["drive"], diff --git a/packages/backend/src/server/api/endpoints/drive/files/attached-notes.ts b/packages/backend/src/server/api/endpoints/drive/files/attached-notes.ts index 5f821fa7..8c15e558 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/attached-notes.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/attached-notes.ts @@ -1,6 +1,6 @@ +import { DriveFiles, Notes } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { DriveFiles, Notes } from "@/models/index.js"; export const meta = { tags: ["drive", "notes"], diff --git a/packages/backend/src/server/api/endpoints/drive/files/check-existence.ts b/packages/backend/src/server/api/endpoints/drive/files/check-existence.ts index 2ce9fa47..0711ade0 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/check-existence.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/check-existence.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { DriveFiles } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["drive"], diff --git a/packages/backend/src/server/api/endpoints/drive/files/create.ts b/packages/backend/src/server/api/endpoints/drive/files/create.ts index 54ca5f8d..0e20ab63 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/create.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/create.ts @@ -1,12 +1,12 @@ -import { addFile } from "@/services/drive/add-file.js"; -import { DriveFiles } from "@/models/index.js"; +import { MINUTE } from "@/const.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; import { DB_MAX_IMAGE_COMMENT_LENGTH } from "@/misc/hard-limits.js"; import { IdentifiableError } from "@/misc/identifiable-error.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; -import { MINUTE } from "@/const.js"; +import { DriveFiles } from "@/models/index.js"; import define from "@/server/api/define.js"; -import { apiLogger } from "@/server/api/logger.js"; import { ApiError } from "@/server/api/error.js"; +import { apiLogger } from "@/server/api/logger.js"; +import { addFile } from "@/services/drive/add-file.js"; export const meta = { tags: ["drive"], diff --git a/packages/backend/src/server/api/endpoints/drive/files/delete.ts b/packages/backend/src/server/api/endpoints/drive/files/delete.ts index 062b69b9..245c380e 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/delete.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/delete.ts @@ -1,8 +1,8 @@ -import { deleteFile } from "@/services/drive/delete-file.js"; -import { publishDriveStream } from "@/services/stream.js"; +import { DriveFiles } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { DriveFiles } from "@/models/index.js"; +import { deleteFile } from "@/services/drive/delete-file.js"; +import { publishDriveStream } from "@/services/stream.js"; export const meta = { tags: ["drive"], diff --git a/packages/backend/src/server/api/endpoints/drive/files/find.ts b/packages/backend/src/server/api/endpoints/drive/files/find.ts index 5a243de8..80b2f6ad 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/find.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/find.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { DriveFiles } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { IsNull } from "typeorm"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/drive/files/update.ts b/packages/backend/src/server/api/endpoints/drive/files/update.ts index bde81e00..1a14cc53 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/update.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/update.ts @@ -1,8 +1,8 @@ -import { publishDriveStream } from "@/services/stream.js"; -import { DriveFiles, DriveFolders, Users } from "@/models/index.js"; import { DB_MAX_IMAGE_COMMENT_LENGTH } from "@/misc/hard-limits.js"; +import { DriveFiles, DriveFolders, Users } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; +import { publishDriveStream } from "@/services/stream.js"; export const meta = { tags: ["drive"], diff --git a/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts b/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts index cdfcb030..172182f1 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts @@ -1,8 +1,8 @@ -import { uploadFromUrl } from "@/services/drive/upload-from-url.js"; -import define from "@/server/api/define.js"; -import { DriveFiles } from "@/models/index.js"; -import { publishMainStream } from "@/services/stream.js"; import { HOUR } from "@/const.js"; +import { DriveFiles } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { uploadFromUrl } from "@/services/drive/upload-from-url.js"; +import { publishMainStream } from "@/services/stream.js"; export const meta = { tags: ["drive"], diff --git a/packages/backend/src/server/api/endpoints/drive/folders.ts b/packages/backend/src/server/api/endpoints/drive/folders.ts index d02b4fac..c587f804 100644 --- a/packages/backend/src/server/api/endpoints/drive/folders.ts +++ b/packages/backend/src/server/api/endpoints/drive/folders.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; import { DriveFolders } from "@/models/index.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["drive"], diff --git a/packages/backend/src/server/api/endpoints/drive/folders/create.ts b/packages/backend/src/server/api/endpoints/drive/folders/create.ts index 554e61ec..0df87deb 100644 --- a/packages/backend/src/server/api/endpoints/drive/folders/create.ts +++ b/packages/backend/src/server/api/endpoints/drive/folders/create.ts @@ -1,8 +1,8 @@ -import { publishDriveStream } from "@/services/stream.js"; +import { genId } from "@/misc/gen-id.js"; +import { DriveFolders } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { DriveFolders } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; +import { publishDriveStream } from "@/services/stream.js"; export const meta = { tags: ["drive"], diff --git a/packages/backend/src/server/api/endpoints/drive/folders/delete.ts b/packages/backend/src/server/api/endpoints/drive/folders/delete.ts index 1954b433..e5372bb5 100644 --- a/packages/backend/src/server/api/endpoints/drive/folders/delete.ts +++ b/packages/backend/src/server/api/endpoints/drive/folders/delete.ts @@ -1,7 +1,7 @@ +import { DriveFiles, DriveFolders } from "@/models/index.js"; import define from "@/server/api/define.js"; -import { publishDriveStream } from "@/services/stream.js"; import { ApiError } from "@/server/api/error.js"; -import { DriveFolders, DriveFiles } from "@/models/index.js"; +import { publishDriveStream } from "@/services/stream.js"; export const meta = { tags: ["drive"], diff --git a/packages/backend/src/server/api/endpoints/drive/folders/find.ts b/packages/backend/src/server/api/endpoints/drive/folders/find.ts index d29015e7..46f741d9 100644 --- a/packages/backend/src/server/api/endpoints/drive/folders/find.ts +++ b/packages/backend/src/server/api/endpoints/drive/folders/find.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { DriveFolders } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { IsNull } from "typeorm"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/drive/folders/show.ts b/packages/backend/src/server/api/endpoints/drive/folders/show.ts index 611724ae..2968e61d 100644 --- a/packages/backend/src/server/api/endpoints/drive/folders/show.ts +++ b/packages/backend/src/server/api/endpoints/drive/folders/show.ts @@ -1,6 +1,6 @@ +import { DriveFolders } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { DriveFolders } from "@/models/index.js"; export const meta = { tags: ["drive"], diff --git a/packages/backend/src/server/api/endpoints/drive/folders/update.ts b/packages/backend/src/server/api/endpoints/drive/folders/update.ts index 5bd880da..e9cab4f2 100644 --- a/packages/backend/src/server/api/endpoints/drive/folders/update.ts +++ b/packages/backend/src/server/api/endpoints/drive/folders/update.ts @@ -1,7 +1,7 @@ -import { publishDriveStream } from "@/services/stream.js"; +import { DriveFolders } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { DriveFolders } from "@/models/index.js"; +import { publishDriveStream } from "@/services/stream.js"; export const meta = { tags: ["drive"], @@ -84,10 +84,10 @@ export default define(meta, paramDef, async (ps, user) => { id: folderId, }); - if (folder2!.id === folder!.id) { + if (folder2?.id === folder?.id) { return true; - } else if (folder2!.parentId) { - return await checkCircle(folder2!.parentId); + } else if (folder2?.parentId) { + return await checkCircle(folder2?.parentId); } else { return false; } diff --git a/packages/backend/src/server/api/endpoints/drive/stream.ts b/packages/backend/src/server/api/endpoints/drive/stream.ts index cbd78601..1c92e30c 100644 --- a/packages/backend/src/server/api/endpoints/drive/stream.ts +++ b/packages/backend/src/server/api/endpoints/drive/stream.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; import { DriveFiles } from "@/models/index.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["drive"], diff --git a/packages/backend/src/server/api/endpoints/emoji.ts b/packages/backend/src/server/api/endpoints/emoji.ts index 2675ba7b..384c3845 100644 --- a/packages/backend/src/server/api/endpoints/emoji.ts +++ b/packages/backend/src/server/api/endpoints/emoji.ts @@ -1,7 +1,7 @@ -import { IsNull } from "typeorm"; import { Emojis } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; +import { IsNull } from "typeorm"; export const meta = { tags: ["meta"], diff --git a/packages/backend/src/server/api/endpoints/export-custom-emojis.ts b/packages/backend/src/server/api/endpoints/export-custom-emojis.ts index ca013314..d1e1d9dc 100644 --- a/packages/backend/src/server/api/endpoints/export-custom-emojis.ts +++ b/packages/backend/src/server/api/endpoints/export-custom-emojis.ts @@ -1,6 +1,6 @@ +import { HOUR } from "@/const.js"; import { createExportCustomEmojisJob } from "@/queue/index.js"; import define from "@/server/api/define.js"; -import { HOUR } from "@/const.js"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/federation/followers.ts b/packages/backend/src/server/api/endpoints/federation/followers.ts index 2a88d27a..e7117349 100644 --- a/packages/backend/src/server/api/endpoints/federation/followers.ts +++ b/packages/backend/src/server/api/endpoints/federation/followers.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; import { Followings } from "@/models/index.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["federation"], diff --git a/packages/backend/src/server/api/endpoints/federation/following.ts b/packages/backend/src/server/api/endpoints/federation/following.ts index c13ee8b1..3d177b92 100644 --- a/packages/backend/src/server/api/endpoints/federation/following.ts +++ b/packages/backend/src/server/api/endpoints/federation/following.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; import { Followings } from "@/models/index.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["federation"], diff --git a/packages/backend/src/server/api/endpoints/federation/instances.ts b/packages/backend/src/server/api/endpoints/federation/instances.ts index 27a6dabb..6f9b6c9b 100644 --- a/packages/backend/src/server/api/endpoints/federation/instances.ts +++ b/packages/backend/src/server/api/endpoints/federation/instances.ts @@ -1,7 +1,7 @@ -import define from "@/server/api/define.js"; -import { Instances } from "@/models/index.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; import { sqlLikeEscape } from "@/misc/sql-like-escape.js"; +import { Instances } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["federation"], diff --git a/packages/backend/src/server/api/endpoints/federation/show-instance.ts b/packages/backend/src/server/api/endpoints/federation/show-instance.ts index c4a6304d..7d90a4f5 100644 --- a/packages/backend/src/server/api/endpoints/federation/show-instance.ts +++ b/packages/backend/src/server/api/endpoints/federation/show-instance.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; -import { Instances } from "@/models/index.js"; import { toPuny } from "@/misc/convert-host.js"; +import { Instances } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["federation"], diff --git a/packages/backend/src/server/api/endpoints/federation/stats.ts b/packages/backend/src/server/api/endpoints/federation/stats.ts index 6702eeff..9d9b86b4 100644 --- a/packages/backend/src/server/api/endpoints/federation/stats.ts +++ b/packages/backend/src/server/api/endpoints/federation/stats.ts @@ -1,7 +1,7 @@ -import { IsNull, MoreThan, Not } from "typeorm"; import { Followings, Instances } from "@/models/index.js"; import { awaitAll } from "@/prelude/await-all.js"; import define from "@/server/api/define.js"; +import { IsNull, MoreThan, Not } from "typeorm"; export const meta = { tags: ["federation"], diff --git a/packages/backend/src/server/api/endpoints/federation/update-remote-user.ts b/packages/backend/src/server/api/endpoints/federation/update-remote-user.ts index e8ada9e6..cecd1109 100644 --- a/packages/backend/src/server/api/endpoints/federation/update-remote-user.ts +++ b/packages/backend/src/server/api/endpoints/federation/update-remote-user.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; -import { getRemoteUser } from "@/server/api/common/getters.js"; import { updatePerson } from "@/remote/activitypub/models/person.js"; +import { getRemoteUser } from "@/server/api/common/getters.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["federation"], diff --git a/packages/backend/src/server/api/endpoints/federation/users.ts b/packages/backend/src/server/api/endpoints/federation/users.ts index 4e925a29..7960f4dd 100644 --- a/packages/backend/src/server/api/endpoints/federation/users.ts +++ b/packages/backend/src/server/api/endpoints/federation/users.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; import { Users } from "@/models/index.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["federation"], diff --git a/packages/backend/src/server/api/endpoints/fetch-rss.ts b/packages/backend/src/server/api/endpoints/fetch-rss.ts index bda3c455..0e7f9a37 100644 --- a/packages/backend/src/server/api/endpoints/fetch-rss.ts +++ b/packages/backend/src/server/api/endpoints/fetch-rss.ts @@ -1,7 +1,7 @@ -import Parser from "rss-parser"; -import { getResponse } from "@/misc/fetch.js"; import config from "@/config/index.js"; +import { getResponse } from "@/misc/fetch.js"; import define from "@/server/api/define.js"; +import Parser from "rss-parser"; const rssParser = new Parser(); diff --git a/packages/backend/src/server/api/endpoints/following/create.ts b/packages/backend/src/server/api/endpoints/following/create.ts index f6e341ad..76433106 100644 --- a/packages/backend/src/server/api/endpoints/following/create.ts +++ b/packages/backend/src/server/api/endpoints/following/create.ts @@ -1,10 +1,10 @@ -import create from "@/services/following/create.js"; +import { HOUR } from "@/const.js"; +import { IdentifiableError } from "@/misc/identifiable-error.js"; +import { Followings, Users } from "@/models/index.js"; +import { getUser } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; -import { Followings, Users } from "@/models/index.js"; -import { IdentifiableError } from "@/misc/identifiable-error.js"; -import { HOUR } from "@/const.js"; +import create from "@/services/following/create.js"; export const meta = { tags: ["following", "users"], diff --git a/packages/backend/src/server/api/endpoints/following/delete.ts b/packages/backend/src/server/api/endpoints/following/delete.ts index 3ef031eb..d382f1a9 100644 --- a/packages/backend/src/server/api/endpoints/following/delete.ts +++ b/packages/backend/src/server/api/endpoints/following/delete.ts @@ -1,9 +1,9 @@ -import deleteFollowing from "@/services/following/delete.js"; +import { HOUR } from "@/const.js"; +import { Followings, Users } from "@/models/index.js"; +import { getUser } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; -import { Followings, Users } from "@/models/index.js"; -import { HOUR } from "@/const.js"; +import deleteFollowing from "@/services/following/delete.js"; export const meta = { tags: ["following", "users"], diff --git a/packages/backend/src/server/api/endpoints/following/invalidate.ts b/packages/backend/src/server/api/endpoints/following/invalidate.ts index 7559062c..63d55e8b 100644 --- a/packages/backend/src/server/api/endpoints/following/invalidate.ts +++ b/packages/backend/src/server/api/endpoints/following/invalidate.ts @@ -1,9 +1,9 @@ -import deleteFollowing from "@/services/following/delete.js"; +import { HOUR } from "@/const.js"; +import { Followings, Users } from "@/models/index.js"; +import { getUser } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; -import { Followings, Users } from "@/models/index.js"; -import { HOUR } from "@/const.js"; +import deleteFollowing from "@/services/following/delete.js"; export const meta = { tags: ["following", "users"], diff --git a/packages/backend/src/server/api/endpoints/following/requests/accept.ts b/packages/backend/src/server/api/endpoints/following/requests/accept.ts index cb6b0107..1296384d 100644 --- a/packages/backend/src/server/api/endpoints/following/requests/accept.ts +++ b/packages/backend/src/server/api/endpoints/following/requests/accept.ts @@ -1,7 +1,7 @@ -import acceptFollowRequest from "@/services/following/requests/accept.js"; +import { getUser } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; +import acceptFollowRequest from "@/services/following/requests/accept.js"; export const meta = { tags: ["following", "account"], diff --git a/packages/backend/src/server/api/endpoints/following/requests/cancel.ts b/packages/backend/src/server/api/endpoints/following/requests/cancel.ts index 7acb0f94..b3e46948 100644 --- a/packages/backend/src/server/api/endpoints/following/requests/cancel.ts +++ b/packages/backend/src/server/api/endpoints/following/requests/cancel.ts @@ -1,9 +1,9 @@ -import cancelFollowRequest from "@/services/following/requests/cancel.js"; +import { IdentifiableError } from "@/misc/identifiable-error.js"; +import { Users } from "@/models/index.js"; +import { getUser } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; -import { Users } from "@/models/index.js"; -import { IdentifiableError } from "@/misc/identifiable-error.js"; +import cancelFollowRequest from "@/services/following/requests/cancel.js"; export const meta = { tags: ["following", "account"], diff --git a/packages/backend/src/server/api/endpoints/following/requests/list.ts b/packages/backend/src/server/api/endpoints/following/requests/list.ts index 97f52d4a..c6021caf 100644 --- a/packages/backend/src/server/api/endpoints/following/requests/list.ts +++ b/packages/backend/src/server/api/endpoints/following/requests/list.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { FollowRequests } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["following", "account"], diff --git a/packages/backend/src/server/api/endpoints/following/requests/reject.ts b/packages/backend/src/server/api/endpoints/following/requests/reject.ts index 37e7bc0a..f374c932 100644 --- a/packages/backend/src/server/api/endpoints/following/requests/reject.ts +++ b/packages/backend/src/server/api/endpoints/following/requests/reject.ts @@ -1,7 +1,7 @@ -import { rejectFollowRequest } from "@/services/following/reject.js"; +import { getUser } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; +import { rejectFollowRequest } from "@/services/following/reject.js"; export const meta = { tags: ["following", "account"], diff --git a/packages/backend/src/server/api/endpoints/gallery/featured.ts b/packages/backend/src/server/api/endpoints/gallery/featured.ts index e20e4ab2..6fb70649 100644 --- a/packages/backend/src/server/api/endpoints/gallery/featured.ts +++ b/packages/backend/src/server/api/endpoints/gallery/featured.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { GalleryPosts } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["gallery"], diff --git a/packages/backend/src/server/api/endpoints/gallery/popular.ts b/packages/backend/src/server/api/endpoints/gallery/popular.ts index 805307e4..69333e8d 100644 --- a/packages/backend/src/server/api/endpoints/gallery/popular.ts +++ b/packages/backend/src/server/api/endpoints/gallery/popular.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { GalleryPosts } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["gallery"], diff --git a/packages/backend/src/server/api/endpoints/gallery/posts.ts b/packages/backend/src/server/api/endpoints/gallery/posts.ts index 0dd02b93..69f9929d 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; import { GalleryPosts } from "@/models/index.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["gallery"], diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/create.ts b/packages/backend/src/server/api/endpoints/gallery/posts/create.ts index a74f2165..dad880cf 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/create.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/create.ts @@ -1,9 +1,9 @@ -import define from "@/server/api/define.js"; +import { HOUR } from "@/const.js"; +import type { DriveFile } from "@/models/entities/drive-file.js"; +import { GalleryPost } from "@/models/entities/gallery-post.js"; import { DriveFiles, GalleryPosts } from "@/models/index.js"; import { genId } from "@/server/api/../../misc/gen-id.js"; -import { GalleryPost } from "@/models/entities/gallery-post.js"; -import type { DriveFile } from "@/models/entities/drive-file.js"; -import { HOUR } from "@/const.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["gallery"], diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/delete.ts b/packages/backend/src/server/api/endpoints/gallery/posts/delete.ts index 360ca8c5..89690828 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/delete.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/delete.ts @@ -1,6 +1,6 @@ +import { GalleryPosts } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { GalleryPosts } from "@/models/index.js"; export const meta = { tags: ["gallery"], diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/like.ts b/packages/backend/src/server/api/endpoints/gallery/posts/like.ts index f5ccc5bc..d3d0add7 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/like.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/like.ts @@ -1,7 +1,7 @@ +import { genId } from "@/misc/gen-id.js"; +import { GalleryLikes, GalleryPosts } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { GalleryPosts, GalleryLikes } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; export const meta = { tags: ["gallery"], diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/show.ts b/packages/backend/src/server/api/endpoints/gallery/posts/show.ts index 7e172da4..00c0bdd5 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/show.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/show.ts @@ -1,6 +1,6 @@ +import { GalleryPosts } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { GalleryPosts } from "@/models/index.js"; export const meta = { tags: ["gallery"], diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/unlike.ts b/packages/backend/src/server/api/endpoints/gallery/posts/unlike.ts index f37456a6..bfc4432e 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/unlike.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/unlike.ts @@ -1,6 +1,6 @@ +import { GalleryLikes, GalleryPosts } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { GalleryPosts, GalleryLikes } from "@/models/index.js"; export const meta = { tags: ["gallery"], diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/update.ts b/packages/backend/src/server/api/endpoints/gallery/posts/update.ts index 16c62970..0493d02d 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/update.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/update.ts @@ -1,7 +1,7 @@ -import define from "@/server/api/define.js"; -import { DriveFiles, GalleryPosts } from "@/models/index.js"; -import type { DriveFile } from "@/models/entities/drive-file.js"; import { HOUR } from "@/const.js"; +import type { DriveFile } from "@/models/entities/drive-file.js"; +import { DriveFiles, GalleryPosts } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["gallery"], diff --git a/packages/backend/src/server/api/endpoints/get-online-users-count.ts b/packages/backend/src/server/api/endpoints/get-online-users-count.ts index 633e7533..030ca141 100644 --- a/packages/backend/src/server/api/endpoints/get-online-users-count.ts +++ b/packages/backend/src/server/api/endpoints/get-online-users-count.ts @@ -1,7 +1,7 @@ -import { MoreThan } from "typeorm"; import { USER_ONLINE_THRESHOLD } from "@/const.js"; import { Users } from "@/models/index.js"; import define from "@/server/api/define.js"; +import { MoreThan } from "typeorm"; export const meta = { tags: ["meta"], diff --git a/packages/backend/src/server/api/endpoints/get-sounds.ts b/packages/backend/src/server/api/endpoints/get-sounds.ts index 4fd1498b..119ca167 100644 --- a/packages/backend/src/server/api/endpoints/get-sounds.ts +++ b/packages/backend/src/server/api/endpoints/get-sounds.ts @@ -1,5 +1,5 @@ -import { readdir } from "fs/promises"; import define from "@/server/api/define.js"; +import { readdir } from "fs/promises"; export const meta = { tags: ["meta"], diff --git a/packages/backend/src/server/api/endpoints/hashtags/list.ts b/packages/backend/src/server/api/endpoints/hashtags/list.ts index 6e8016f6..a19ccfa1 100644 --- a/packages/backend/src/server/api/endpoints/hashtags/list.ts +++ b/packages/backend/src/server/api/endpoints/hashtags/list.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { Hashtags } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["hashtags"], diff --git a/packages/backend/src/server/api/endpoints/hashtags/search.ts b/packages/backend/src/server/api/endpoints/hashtags/search.ts index 1dc1fb49..4709ccc7 100644 --- a/packages/backend/src/server/api/endpoints/hashtags/search.ts +++ b/packages/backend/src/server/api/endpoints/hashtags/search.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; -import { Hashtags } from "@/models/index.js"; import { sqlLikeEscape } from "@/misc/sql-like-escape.js"; +import { Hashtags } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["hashtags"], diff --git a/packages/backend/src/server/api/endpoints/hashtags/show.ts b/packages/backend/src/server/api/endpoints/hashtags/show.ts index 09849dbd..136f3580 100644 --- a/packages/backend/src/server/api/endpoints/hashtags/show.ts +++ b/packages/backend/src/server/api/endpoints/hashtags/show.ts @@ -1,7 +1,7 @@ +import { normalizeForSearch } from "@/misc/normalize-for-search.js"; +import { Hashtags } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Hashtags } from "@/models/index.js"; -import { normalizeForSearch } from "@/misc/normalize-for-search.js"; export const meta = { tags: ["hashtags"], diff --git a/packages/backend/src/server/api/endpoints/hashtags/trend.ts b/packages/backend/src/server/api/endpoints/hashtags/trend.ts index fe8bba95..6c41f8b8 100644 --- a/packages/backend/src/server/api/endpoints/hashtags/trend.ts +++ b/packages/backend/src/server/api/endpoints/hashtags/trend.ts @@ -1,10 +1,10 @@ -import { Brackets } from "typeorm"; -import define from "@/server/api/define.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; -import { Notes } from "@/models/index.js"; -import type { Note } from "@/models/entities/note.js"; -import { safeForSql } from "@/misc/safe-for-sql.js"; import { normalizeForSearch } from "@/misc/normalize-for-search.js"; +import { safeForSql } from "@/misc/safe-for-sql.js"; +import type { Note } from "@/models/entities/note.js"; +import { Notes } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { Brackets } from "typeorm"; /* トレンドに載るためには「『直近a分間のユニーク投稿数が今からa分前~今からb分前の間のユニーク投稿数のn倍以上』のハッシュタグの上位5位以内に入る」ことが必要 diff --git a/packages/backend/src/server/api/endpoints/hashtags/users.ts b/packages/backend/src/server/api/endpoints/hashtags/users.ts index ccb70a05..15137032 100644 --- a/packages/backend/src/server/api/endpoints/hashtags/users.ts +++ b/packages/backend/src/server/api/endpoints/hashtags/users.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; -import { Users } from "@/models/index.js"; import { normalizeForSearch } from "@/misc/normalize-for-search.js"; +import { Users } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { requireCredential: false, diff --git a/packages/backend/src/server/api/endpoints/i/2fa/done.ts b/packages/backend/src/server/api/endpoints/i/2fa/done.ts index c1a7b16a..f10b74ef 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/done.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/done.ts @@ -1,7 +1,7 @@ +import { UserProfiles, Users } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { publishMainStream } from "@/services/stream.js"; import * as OTPAuth from "otpauth"; -import define from "@/server/api/define.js"; -import { Users, UserProfiles } from "@/models/index.js"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts b/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts index b8104e31..99f6994e 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts @@ -1,15 +1,15 @@ -import { decode } from "cbor-x"; -import define from "@/server/api/define.js"; +import config from "@/config/index.js"; +import { comparePassword } from "@/misc/password.js"; import { + AttestationChallenges, UserProfiles, UserSecurityKeys, - AttestationChallenges, Users, } from "@/models/index.js"; -import config from "@/config/index.js"; -import { procedures, hash } from "@/server/api/2fa.js"; +import { hash, procedures } from "@/server/api/2fa.js"; +import define from "@/server/api/define.js"; import { publishMainStream } from "@/services/stream.js"; -import { comparePassword } from "@/misc/password.js"; +import { decode } from "cbor-x"; const rpIdHashReal = hash(Buffer.from(config.hostname, "utf-8")); @@ -79,7 +79,7 @@ export default define(meta, paramDef, async (ps, user) => { const credentialIdLength = authData.readUInt16BE(53); const credentialId = authData.slice(55, 55 + credentialIdLength); const publicKeyData = authData.slice(55 + credentialIdLength); - const publicKey: Map = new Map( + const publicKey: Map = new Map( Object.entries(decode(publicKeyData)).map(([key, value]) => [ Number(key), value, diff --git a/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts b/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts index 8125f817..aee935eb 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts @@ -1,7 +1,7 @@ +import { UserProfiles, UserSecurityKeys, Users } from "@/models/index.js"; import define from "@/server/api/define.js"; -import { Users, UserProfiles, UserSecurityKeys } from "@/models/index.js"; -import { publishMainStream } from "@/services/stream.js"; import { ApiError } from "@/server/api/error.js"; +import { publishMainStream } from "@/services/stream.js"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/i/2fa/register-key.ts b/packages/backend/src/server/api/endpoints/i/2fa/register-key.ts index 8080c939..f6d58c27 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/register-key.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/register-key.ts @@ -1,10 +1,10 @@ -import define from "@/server/api/define.js"; -import { UserProfiles, AttestationChallenges } from "@/models/index.js"; -import { promisify } from "node:util"; import * as crypto from "node:crypto"; +import { promisify } from "node:util"; import { genId } from "@/misc/gen-id.js"; -import { hash } from "@/server/api/2fa.js"; import { comparePassword } from "@/misc/password.js"; +import { AttestationChallenges, UserProfiles } from "@/models/index.js"; +import { hash } from "@/server/api/2fa.js"; +import define from "@/server/api/define.js"; const randomBytes = promisify(crypto.randomBytes); diff --git a/packages/backend/src/server/api/endpoints/i/2fa/register.ts b/packages/backend/src/server/api/endpoints/i/2fa/register.ts index 52e1df39..ba0220b1 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/register.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/register.ts @@ -1,9 +1,9 @@ -import * as OTPAuth from "otpauth"; -import * as QRCode from "qrcode"; import config from "@/config/index.js"; +import { comparePassword } from "@/misc/password.js"; import { UserProfiles } from "@/models/index.js"; import define from "@/server/api/define.js"; -import { comparePassword } from "@/misc/password.js"; +import * as OTPAuth from "otpauth"; +import * as QRCode from "qrcode"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts b/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts index b3bc5bdf..cba8b431 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts @@ -1,6 +1,6 @@ import { comparePassword } from "@/misc/password.js"; -import define from "@/server/api/define.js"; import { UserProfiles, UserSecurityKeys, Users } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { publishMainStream } from "@/services/stream.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts b/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts index c4e78eec..39235042 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts @@ -1,7 +1,7 @@ -import { publishMainStream } from "@/services/stream.js"; -import define from "@/server/api/define.js"; -import { Users, UserProfiles } from "@/models/index.js"; import { comparePassword } from "@/misc/password.js"; +import { UserProfiles, Users } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { publishMainStream } from "@/services/stream.js"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/i/2fa/update-key.ts b/packages/backend/src/server/api/endpoints/i/2fa/update-key.ts index d77ecc88..0a55937d 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/update-key.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/update-key.ts @@ -1,7 +1,7 @@ -import { publishMainStream } from "@/services/stream.js"; +import { UserSecurityKeys, Users } from "@/models/index.js"; import define from "@/server/api/define.js"; -import { Users, UserSecurityKeys } from "@/models/index.js"; import { ApiError } from "@/server/api/error.js"; +import { publishMainStream } from "@/services/stream.js"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/i/apps.ts b/packages/backend/src/server/api/endpoints/i/apps.ts index 7e7574ec..9669d22c 100644 --- a/packages/backend/src/server/api/endpoints/i/apps.ts +++ b/packages/backend/src/server/api/endpoints/i/apps.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { AccessTokens } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/i/authorized-apps.ts b/packages/backend/src/server/api/endpoints/i/authorized-apps.ts index ad66fe1f..14505228 100644 --- a/packages/backend/src/server/api/endpoints/i/authorized-apps.ts +++ b/packages/backend/src/server/api/endpoints/i/authorized-apps.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { AccessTokens, Apps } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/i/change-password.ts b/packages/backend/src/server/api/endpoints/i/change-password.ts index b0dc8bba..cef86a6b 100644 --- a/packages/backend/src/server/api/endpoints/i/change-password.ts +++ b/packages/backend/src/server/api/endpoints/i/change-password.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; +import { comparePassword, hashPassword } from "@/misc/password.js"; import { UserProfiles } from "@/models/index.js"; -import { hashPassword, comparePassword } from "@/misc/password.js"; +import define from "@/server/api/define.js"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/i/delete-account.ts b/packages/backend/src/server/api/endpoints/i/delete-account.ts index 606cde82..9e6ce15c 100644 --- a/packages/backend/src/server/api/endpoints/i/delete-account.ts +++ b/packages/backend/src/server/api/endpoints/i/delete-account.ts @@ -1,7 +1,7 @@ -import { UserProfiles, Users } from "@/models/index.js"; -import { deleteAccount } from "@/services/delete-account.js"; -import define from "@/server/api/define.js"; import { comparePassword } from "@/misc/password.js"; +import { UserProfiles, Users } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { deleteAccount } from "@/services/delete-account.js"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/i/export-blocking.ts b/packages/backend/src/server/api/endpoints/i/export-blocking.ts index 30e74ab2..664689d0 100644 --- a/packages/backend/src/server/api/endpoints/i/export-blocking.ts +++ b/packages/backend/src/server/api/endpoints/i/export-blocking.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; -import { createExportBlockingJob } from "@/queue/index.js"; import { HOUR } from "@/const.js"; +import { createExportBlockingJob } from "@/queue/index.js"; +import define from "@/server/api/define.js"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/i/export-following.ts b/packages/backend/src/server/api/endpoints/i/export-following.ts index 07d2997a..6f574f8b 100644 --- a/packages/backend/src/server/api/endpoints/i/export-following.ts +++ b/packages/backend/src/server/api/endpoints/i/export-following.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; -import { createExportFollowingJob } from "@/queue/index.js"; import { HOUR } from "@/const.js"; +import { createExportFollowingJob } from "@/queue/index.js"; +import define from "@/server/api/define.js"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/i/export-mute.ts b/packages/backend/src/server/api/endpoints/i/export-mute.ts index 7d22a073..e5722978 100644 --- a/packages/backend/src/server/api/endpoints/i/export-mute.ts +++ b/packages/backend/src/server/api/endpoints/i/export-mute.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; -import { createExportMuteJob } from "@/queue/index.js"; import { HOUR } from "@/const.js"; +import { createExportMuteJob } from "@/queue/index.js"; +import define from "@/server/api/define.js"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/i/export-notes.ts b/packages/backend/src/server/api/endpoints/i/export-notes.ts index f167bb83..393ab01e 100644 --- a/packages/backend/src/server/api/endpoints/i/export-notes.ts +++ b/packages/backend/src/server/api/endpoints/i/export-notes.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; -import { createExportNotesJob } from "@/queue/index.js"; import { DAY } from "@/const.js"; +import { createExportNotesJob } from "@/queue/index.js"; +import define from "@/server/api/define.js"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/i/export-user-lists.ts b/packages/backend/src/server/api/endpoints/i/export-user-lists.ts index b68d889d..c77e4687 100644 --- a/packages/backend/src/server/api/endpoints/i/export-user-lists.ts +++ b/packages/backend/src/server/api/endpoints/i/export-user-lists.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; -import { createExportUserListsJob } from "@/queue/index.js"; import { MINUTE } from "@/const.js"; +import { createExportUserListsJob } from "@/queue/index.js"; +import define from "@/server/api/define.js"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/i/favorites.ts b/packages/backend/src/server/api/endpoints/i/favorites.ts index f0961ea2..1e34f137 100644 --- a/packages/backend/src/server/api/endpoints/i/favorites.ts +++ b/packages/backend/src/server/api/endpoints/i/favorites.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; import { NoteFavorites } from "@/models/index.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["account", "notes", "favorites"], diff --git a/packages/backend/src/server/api/endpoints/i/gallery/likes.ts b/packages/backend/src/server/api/endpoints/i/gallery/likes.ts index 80c90e68..42fd9ad8 100644 --- a/packages/backend/src/server/api/endpoints/i/gallery/likes.ts +++ b/packages/backend/src/server/api/endpoints/i/gallery/likes.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; import { GalleryLikes } from "@/models/index.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["account", "gallery"], diff --git a/packages/backend/src/server/api/endpoints/i/gallery/posts.ts b/packages/backend/src/server/api/endpoints/i/gallery/posts.ts index 05478484..c654bfc3 100644 --- a/packages/backend/src/server/api/endpoints/i/gallery/posts.ts +++ b/packages/backend/src/server/api/endpoints/i/gallery/posts.ts @@ -1,6 +1,6 @@ import { GalleryPosts } from "@/models/index.js"; -import define from "@/server/api/define.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["account", "gallery"], diff --git a/packages/backend/src/server/api/endpoints/i/get-word-muted-notes-count.ts b/packages/backend/src/server/api/endpoints/i/get-word-muted-notes-count.ts index 39cc45e8..f987a58a 100644 --- a/packages/backend/src/server/api/endpoints/i/get-word-muted-notes-count.ts +++ b/packages/backend/src/server/api/endpoints/i/get-word-muted-notes-count.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { MutedNotes } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["account"], diff --git a/packages/backend/src/server/api/endpoints/i/import-blocking.ts b/packages/backend/src/server/api/endpoints/i/import-blocking.ts index 58314ace..9672663e 100644 --- a/packages/backend/src/server/api/endpoints/i/import-blocking.ts +++ b/packages/backend/src/server/api/endpoints/i/import-blocking.ts @@ -1,8 +1,8 @@ -import define from "@/server/api/define.js"; -import { createImportBlockingJob } from "@/queue/index.js"; -import { ApiError } from "@/server/api/error.js"; -import { DriveFiles } from "@/models/index.js"; import { HOUR } from "@/const.js"; +import { DriveFiles } from "@/models/index.js"; +import { createImportBlockingJob } from "@/queue/index.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/i/import-following.ts b/packages/backend/src/server/api/endpoints/i/import-following.ts index b7c47569..a40b010c 100644 --- a/packages/backend/src/server/api/endpoints/i/import-following.ts +++ b/packages/backend/src/server/api/endpoints/i/import-following.ts @@ -1,8 +1,8 @@ -import define from "@/server/api/define.js"; -import { createImportFollowingJob } from "@/queue/index.js"; -import { ApiError } from "@/server/api/error.js"; -import { DriveFiles } from "@/models/index.js"; import { HOUR } from "@/const.js"; +import { DriveFiles } from "@/models/index.js"; +import { createImportFollowingJob } from "@/queue/index.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/i/import-muting.ts b/packages/backend/src/server/api/endpoints/i/import-muting.ts index 494fb0d4..750d23ec 100644 --- a/packages/backend/src/server/api/endpoints/i/import-muting.ts +++ b/packages/backend/src/server/api/endpoints/i/import-muting.ts @@ -1,8 +1,8 @@ -import define from "@/server/api/define.js"; -import { createImportMutingJob } from "@/queue/index.js"; -import { ApiError } from "@/server/api/error.js"; -import { DriveFiles } from "@/models/index.js"; import { HOUR } from "@/const.js"; +import { DriveFiles } from "@/models/index.js"; +import { createImportMutingJob } from "@/queue/index.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/i/import-posts.ts b/packages/backend/src/server/api/endpoints/i/import-posts.ts index b8b52be9..582807aa 100644 --- a/packages/backend/src/server/api/endpoints/i/import-posts.ts +++ b/packages/backend/src/server/api/endpoints/i/import-posts.ts @@ -1,9 +1,9 @@ -import define from "@/server/api/define.js"; -import { createImportPostsJob } from "@/queue/index.js"; -import { ApiError } from "@/server/api/error.js"; -import { DriveFiles } from "@/models/index.js"; import { DAY } from "@/const.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; +import { DriveFiles } from "@/models/index.js"; +import { createImportPostsJob } from "@/queue/index.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/i/import-user-lists.ts b/packages/backend/src/server/api/endpoints/i/import-user-lists.ts index ed82a960..10ce72e7 100644 --- a/packages/backend/src/server/api/endpoints/i/import-user-lists.ts +++ b/packages/backend/src/server/api/endpoints/i/import-user-lists.ts @@ -1,8 +1,8 @@ -import define from "@/server/api/define.js"; -import { createImportUserListsJob } from "@/queue/index.js"; -import { ApiError } from "@/server/api/error.js"; -import { DriveFiles } from "@/models/index.js"; import { HOUR } from "@/const.js"; +import { DriveFiles } from "@/models/index.js"; +import { createImportUserListsJob } from "@/queue/index.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/i/known-as.ts b/packages/backend/src/server/api/endpoints/i/known-as.ts index 39bf6fff..d6d44bf9 100644 --- a/packages/backend/src/server/api/endpoints/i/known-as.ts +++ b/packages/backend/src/server/api/endpoints/i/known-as.ts @@ -1,14 +1,14 @@ +import { DAY } from "@/const.js"; +import { parse } from "@/misc/acct.js"; import type { User } from "@/models/entities/user.js"; import { Users } from "@/models/index.js"; import { resolveUser } from "@/remote/resolve-user.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; +import { apiLogger } from "@/server/api/logger.js"; import acceptAllFollowRequests from "@/services/following/requests/accept-all.js"; import { publishToFollowers } from "@/services/i/update.js"; import { publishMainStream } from "@/services/stream.js"; -import { DAY } from "@/const.js"; -import { apiLogger } from "@/server/api/logger.js"; -import define from "@/server/api/define.js"; -import { ApiError } from "@/server/api/error.js"; -import { parse } from "@/misc/acct.js"; export const meta = { tags: ["users"], diff --git a/packages/backend/src/server/api/endpoints/i/move.ts b/packages/backend/src/server/api/endpoints/i/move.ts index 17b70ac8..2e0540e3 100644 --- a/packages/backend/src/server/api/endpoints/i/move.ts +++ b/packages/backend/src/server/api/endpoints/i/move.ts @@ -1,18 +1,18 @@ -import type { User } from "@/models/entities/user.js"; -import { resolveUser } from "@/remote/resolve-user.js"; +import config from "@/config/index.js"; import { DAY } from "@/const.js"; +import { parse } from "@/misc/acct.js"; +import type { User } from "@/models/entities/user.js"; +import { Followings, Users } from "@/models/index.js"; import DeliverManager from "@/remote/activitypub/deliver-manager.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import { resolveUser } from "@/remote/resolve-user.js"; +import { getUser } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; import { apiLogger } from "@/server/api/logger.js"; -import deleteFollowing from "@/services/following/delete.js"; import create from "@/services/following/create.js"; -import { getUser } from "@/server/api/common/getters.js"; -import { Followings, Users } from "@/models/index.js"; -import config from "@/config/index.js"; +import deleteFollowing from "@/services/following/delete.js"; import { publishMainStream } from "@/services/stream.js"; -import { parse } from "@/misc/acct.js"; export const meta = { tags: ["users"], @@ -109,7 +109,7 @@ export default define(meta, paramDef, async (ps, user) => { let allowed = false; moveTo.alsoKnownAs?.forEach((element) => { - if (fromUrl!.includes(element)) allowed = true; + if (fromUrl?.includes(element)) allowed = true; }); if (!(allowed && toUrl && fromUrl)) diff --git a/packages/backend/src/server/api/endpoints/i/notifications.ts b/packages/backend/src/server/api/endpoints/i/notifications.ts index b07247dd..2f9043f1 100644 --- a/packages/backend/src/server/api/endpoints/i/notifications.ts +++ b/packages/backend/src/server/api/endpoints/i/notifications.ts @@ -1,16 +1,16 @@ -import { Brackets } from "typeorm"; import { - Notifications, Followings, Mutings, - Users, + Notifications, UserProfiles, + Users, } from "@/models/index.js"; -import { notificationTypes } from "@/types.js"; -import read from "@/services/note/read.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; import { readNotification } from "@/server/api/common/read-notification.js"; import define from "@/server/api/define.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import read from "@/services/note/read.js"; +import { notificationTypes } from "@/types.js"; +import { Brackets } from "typeorm"; export const meta = { tags: ["account", "notifications"], diff --git a/packages/backend/src/server/api/endpoints/i/page-likes.ts b/packages/backend/src/server/api/endpoints/i/page-likes.ts index 289d0726..6cf7a8c0 100644 --- a/packages/backend/src/server/api/endpoints/i/page-likes.ts +++ b/packages/backend/src/server/api/endpoints/i/page-likes.ts @@ -1,6 +1,6 @@ import { PageLikes } from "@/models/index.js"; -import define from "@/server/api/define.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["account", "pages"], diff --git a/packages/backend/src/server/api/endpoints/i/pages.ts b/packages/backend/src/server/api/endpoints/i/pages.ts index 1177d2e6..f2912a6c 100644 --- a/packages/backend/src/server/api/endpoints/i/pages.ts +++ b/packages/backend/src/server/api/endpoints/i/pages.ts @@ -1,6 +1,6 @@ import { Pages } from "@/models/index.js"; -import define from "@/server/api/define.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["account", "pages"], diff --git a/packages/backend/src/server/api/endpoints/i/pin.ts b/packages/backend/src/server/api/endpoints/i/pin.ts index 4291541e..106342b6 100644 --- a/packages/backend/src/server/api/endpoints/i/pin.ts +++ b/packages/backend/src/server/api/endpoints/i/pin.ts @@ -1,7 +1,7 @@ -import { addPinned } from "@/services/i/pin.js"; +import { Users } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Users } from "@/models/index.js"; +import { addPinned } from "@/services/i/pin.js"; export const meta = { tags: ["account", "notes"], diff --git a/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts b/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts index 505c424e..0dcd89fa 100644 --- a/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts +++ b/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts @@ -1,6 +1,6 @@ -import { publishMainStream } from "@/services/stream.js"; -import define from "@/server/api/define.js"; import { MessagingMessages, UserGroupJoinings } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { publishMainStream } from "@/services/stream.js"; export const meta = { tags: ["account", "messaging"], diff --git a/packages/backend/src/server/api/endpoints/i/read-all-unread-notes.ts b/packages/backend/src/server/api/endpoints/i/read-all-unread-notes.ts index 6f70e55a..32439f54 100644 --- a/packages/backend/src/server/api/endpoints/i/read-all-unread-notes.ts +++ b/packages/backend/src/server/api/endpoints/i/read-all-unread-notes.ts @@ -1,6 +1,6 @@ -import { publishMainStream } from "@/services/stream.js"; -import define from "@/server/api/define.js"; import { NoteUnreads } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { publishMainStream } from "@/services/stream.js"; export const meta = { tags: ["account"], diff --git a/packages/backend/src/server/api/endpoints/i/read-announcement.ts b/packages/backend/src/server/api/endpoints/i/read-announcement.ts index a59d15b9..98da5576 100644 --- a/packages/backend/src/server/api/endpoints/i/read-announcement.ts +++ b/packages/backend/src/server/api/endpoints/i/read-announcement.ts @@ -1,7 +1,7 @@ -import define from "@/server/api/define.js"; -import { ApiError } from "@/server/api/error.js"; import { genId } from "@/misc/gen-id.js"; import { AnnouncementReads, Announcements, Users } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; import { publishMainStream } from "@/services/stream.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/i/regenerate-token.ts b/packages/backend/src/server/api/endpoints/i/regenerate-token.ts index c1b4325a..348167ae 100644 --- a/packages/backend/src/server/api/endpoints/i/regenerate-token.ts +++ b/packages/backend/src/server/api/endpoints/i/regenerate-token.ts @@ -1,12 +1,12 @@ +import { comparePassword } from "@/misc/password.js"; +import { UserProfiles, Users } from "@/models/index.js"; +import generateUserToken from "@/server/api/common/generate-native-user-token.js"; +import define from "@/server/api/define.js"; import { publishInternalEvent, publishMainStream, publishUserEvent, } from "@/services/stream.js"; -import generateUserToken from "@/server/api/common/generate-native-user-token.js"; -import define from "@/server/api/define.js"; -import { Users, UserProfiles } from "@/models/index.js"; -import { comparePassword } from "@/misc/password.js"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/i/registry/get-all.ts b/packages/backend/src/server/api/endpoints/i/registry/get-all.ts index c267bb14..b3edd0f9 100644 --- a/packages/backend/src/server/api/endpoints/i/registry/get-all.ts +++ b/packages/backend/src/server/api/endpoints/i/registry/get-all.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { RegistryItems } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/i/registry/get-detail.ts b/packages/backend/src/server/api/endpoints/i/registry/get-detail.ts index 57db3c71..d7f269ec 100644 --- a/packages/backend/src/server/api/endpoints/i/registry/get-detail.ts +++ b/packages/backend/src/server/api/endpoints/i/registry/get-detail.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { RegistryItems } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/i/registry/get-unsecure.ts b/packages/backend/src/server/api/endpoints/i/registry/get-unsecure.ts index ac37beea..dd2ef8c9 100644 --- a/packages/backend/src/server/api/endpoints/i/registry/get-unsecure.ts +++ b/packages/backend/src/server/api/endpoints/i/registry/get-unsecure.ts @@ -1,6 +1,6 @@ -import { ApiError } from "@/server/api/error.js"; -import define from "@/server/api/define.js"; import { RegistryItems } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/i/registry/get.ts b/packages/backend/src/server/api/endpoints/i/registry/get.ts index d25047e0..96ae834d 100644 --- a/packages/backend/src/server/api/endpoints/i/registry/get.ts +++ b/packages/backend/src/server/api/endpoints/i/registry/get.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { RegistryItems } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/i/registry/keys-with-type.ts b/packages/backend/src/server/api/endpoints/i/registry/keys-with-type.ts index f691552b..e261f8ee 100644 --- a/packages/backend/src/server/api/endpoints/i/registry/keys-with-type.ts +++ b/packages/backend/src/server/api/endpoints/i/registry/keys-with-type.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { RegistryItems } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/i/registry/keys.ts b/packages/backend/src/server/api/endpoints/i/registry/keys.ts index 186e744b..bc89e33a 100644 --- a/packages/backend/src/server/api/endpoints/i/registry/keys.ts +++ b/packages/backend/src/server/api/endpoints/i/registry/keys.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { RegistryItems } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/i/registry/remove.ts b/packages/backend/src/server/api/endpoints/i/registry/remove.ts index aa459952..bef2d7b2 100644 --- a/packages/backend/src/server/api/endpoints/i/registry/remove.ts +++ b/packages/backend/src/server/api/endpoints/i/registry/remove.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { RegistryItems } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/i/registry/scopes.ts b/packages/backend/src/server/api/endpoints/i/registry/scopes.ts index e235ef67..53d8113c 100644 --- a/packages/backend/src/server/api/endpoints/i/registry/scopes.ts +++ b/packages/backend/src/server/api/endpoints/i/registry/scopes.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { RegistryItems } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/i/registry/set.ts b/packages/backend/src/server/api/endpoints/i/registry/set.ts index 7a1f8ab5..0e61ef78 100644 --- a/packages/backend/src/server/api/endpoints/i/registry/set.ts +++ b/packages/backend/src/server/api/endpoints/i/registry/set.ts @@ -1,7 +1,7 @@ -import { publishMainStream } from "@/services/stream.js"; -import define from "@/server/api/define.js"; -import { RegistryItems } from "@/models/index.js"; import { genId } from "@/misc/gen-id.js"; +import { RegistryItems } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { publishMainStream } from "@/services/stream.js"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/i/revoke-token.ts b/packages/backend/src/server/api/endpoints/i/revoke-token.ts index f3e81169..4a86b861 100644 --- a/packages/backend/src/server/api/endpoints/i/revoke-token.ts +++ b/packages/backend/src/server/api/endpoints/i/revoke-token.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { AccessTokens } from "@/models/index.js"; +import define from "@/server/api/define.js"; import { publishUserEvent } from "@/services/stream.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/i/signin-history.ts b/packages/backend/src/server/api/endpoints/i/signin-history.ts index 14d30308..17802b74 100644 --- a/packages/backend/src/server/api/endpoints/i/signin-history.ts +++ b/packages/backend/src/server/api/endpoints/i/signin-history.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; import { Signins } from "@/models/index.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/i/unpin.ts b/packages/backend/src/server/api/endpoints/i/unpin.ts index 9aee1dfe..bba01786 100644 --- a/packages/backend/src/server/api/endpoints/i/unpin.ts +++ b/packages/backend/src/server/api/endpoints/i/unpin.ts @@ -1,7 +1,7 @@ -import { removePinned } from "@/services/i/pin.js"; +import { Users } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Users } from "@/models/index.js"; +import { removePinned } from "@/services/i/pin.js"; export const meta = { tags: ["account", "notes"], diff --git a/packages/backend/src/server/api/endpoints/i/update-email.ts b/packages/backend/src/server/api/endpoints/i/update-email.ts index a48252ed..494f35dd 100644 --- a/packages/backend/src/server/api/endpoints/i/update-email.ts +++ b/packages/backend/src/server/api/endpoints/i/update-email.ts @@ -1,13 +1,13 @@ -import { publishMainStream } from "@/services/stream.js"; -import define from "@/server/api/define.js"; -import rndstr from "rndstr"; import config from "@/config/index.js"; -import { Users, UserProfiles } from "@/models/index.js"; -import { sendEmail } from "@/services/send-email.js"; -import { ApiError } from "@/server/api/error.js"; -import { validateEmailForAccount } from "@/services/validate-email-for-account.js"; import { HOUR } from "@/const.js"; import { comparePassword } from "@/misc/password.js"; +import { UserProfiles, Users } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; +import { sendEmail } from "@/services/send-email.js"; +import { publishMainStream } from "@/services/stream.js"; +import { validateEmailForAccount } from "@/services/validate-email-for-account.js"; +import rndstr from "rndstr"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts index 08210838..d352db72 100644 --- a/packages/backend/src/server/api/endpoints/i/update.ts +++ b/packages/backend/src/server/api/endpoints/i/update.ts @@ -1,20 +1,20 @@ -import RE2 from "re2"; -import * as mfm from "mfm-js"; -import { publishMainStream, publishUserEvent } from "@/services/stream.js"; -import acceptAllFollowRequests from "@/services/following/requests/accept-all.js"; -import { publishToFollowers } from "@/services/i/update.js"; import { extractCustomEmojisFromMfm } from "@/misc/extract-custom-emojis-from-mfm.js"; import { extractHashtags } from "@/misc/extract-hashtags.js"; -import { updateUsertags } from "@/services/update-hashtag.js"; -import { Users, DriveFiles, UserProfiles, Pages } from "@/models/index.js"; -import type { User } from "@/models/entities/user.js"; -import type { UserProfile } from "@/models/entities/user-profile.js"; -import { notificationTypes } from "@/types.js"; -import { normalizeForSearch } from "@/misc/normalize-for-search.js"; import { langmap } from "@/misc/langmap.js"; -import { verifyLink } from "@/services/fetch-rel-me.js"; -import { ApiError } from "@/server/api/error.js"; +import { normalizeForSearch } from "@/misc/normalize-for-search.js"; +import type { UserProfile } from "@/models/entities/user-profile.js"; +import type { User } from "@/models/entities/user.js"; +import { DriveFiles, Pages, UserProfiles, Users } from "@/models/index.js"; import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; +import { verifyLink } from "@/services/fetch-rel-me.js"; +import acceptAllFollowRequests from "@/services/following/requests/accept-all.js"; +import { publishToFollowers } from "@/services/i/update.js"; +import { publishMainStream, publishUserEvent } from "@/services/stream.js"; +import { updateUsertags } from "@/services/update-hashtag.js"; +import { notificationTypes } from "@/types.js"; +import * as mfm from "mfm-js"; +import RE2 from "re2"; export const meta = { tags: ["account"], diff --git a/packages/backend/src/server/api/endpoints/i/user-group-invites.ts b/packages/backend/src/server/api/endpoints/i/user-group-invites.ts index 99e8209a..19cab832 100644 --- a/packages/backend/src/server/api/endpoints/i/user-group-invites.ts +++ b/packages/backend/src/server/api/endpoints/i/user-group-invites.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; import { UserGroupInvitations } from "@/models/index.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["account", "groups"], diff --git a/packages/backend/src/server/api/endpoints/i/webhooks/create.ts b/packages/backend/src/server/api/endpoints/i/webhooks/create.ts index ee38b763..161a4a05 100644 --- a/packages/backend/src/server/api/endpoints/i/webhooks/create.ts +++ b/packages/backend/src/server/api/endpoints/i/webhooks/create.ts @@ -1,8 +1,8 @@ -import define from "@/server/api/define.js"; import { genId } from "@/misc/gen-id.js"; -import { Webhooks } from "@/models/index.js"; -import { publishInternalEvent } from "@/services/stream.js"; import { webhookEventTypes } from "@/models/entities/webhook.js"; +import { Webhooks } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { publishInternalEvent } from "@/services/stream.js"; export const meta = { tags: ["webhooks"], diff --git a/packages/backend/src/server/api/endpoints/i/webhooks/delete.ts b/packages/backend/src/server/api/endpoints/i/webhooks/delete.ts index a92ed179..a9df7a94 100644 --- a/packages/backend/src/server/api/endpoints/i/webhooks/delete.ts +++ b/packages/backend/src/server/api/endpoints/i/webhooks/delete.ts @@ -1,6 +1,6 @@ +import { Webhooks } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Webhooks } from "@/models/index.js"; import { publishInternalEvent } from "@/services/stream.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/i/webhooks/list.ts b/packages/backend/src/server/api/endpoints/i/webhooks/list.ts index f937e560..da98cb81 100644 --- a/packages/backend/src/server/api/endpoints/i/webhooks/list.ts +++ b/packages/backend/src/server/api/endpoints/i/webhooks/list.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { Webhooks } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["webhooks", "account"], diff --git a/packages/backend/src/server/api/endpoints/i/webhooks/show.ts b/packages/backend/src/server/api/endpoints/i/webhooks/show.ts index b24850f5..158d71b0 100644 --- a/packages/backend/src/server/api/endpoints/i/webhooks/show.ts +++ b/packages/backend/src/server/api/endpoints/i/webhooks/show.ts @@ -1,6 +1,6 @@ +import { Webhooks } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Webhooks } from "@/models/index.js"; export const meta = { tags: ["webhooks"], diff --git a/packages/backend/src/server/api/endpoints/i/webhooks/update.ts b/packages/backend/src/server/api/endpoints/i/webhooks/update.ts index 4a211b91..f2656bbf 100644 --- a/packages/backend/src/server/api/endpoints/i/webhooks/update.ts +++ b/packages/backend/src/server/api/endpoints/i/webhooks/update.ts @@ -1,8 +1,8 @@ +import { webhookEventTypes } from "@/models/entities/webhook.js"; +import { Webhooks } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { Webhooks } from "@/models/index.js"; import { publishInternalEvent } from "@/services/stream.js"; -import { webhookEventTypes } from "@/models/entities/webhook.js"; export const meta = { tags: ["webhooks"], diff --git a/packages/backend/src/server/api/endpoints/messaging/history.ts b/packages/backend/src/server/api/endpoints/messaging/history.ts index 25418a17..f9e00aa7 100644 --- a/packages/backend/src/server/api/endpoints/messaging/history.ts +++ b/packages/backend/src/server/api/endpoints/messaging/history.ts @@ -1,4 +1,3 @@ -import { Brackets } from "typeorm"; import type { MessagingMessage } from "@/models/entities/messaging-message.js"; import { MessagingMessages, @@ -6,6 +5,7 @@ import { UserGroupJoinings, } from "@/models/index.js"; import define from "@/server/api/define.js"; +import { Brackets } from "typeorm"; export const meta = { tags: ["messaging"], diff --git a/packages/backend/src/server/api/endpoints/messaging/messages.ts b/packages/backend/src/server/api/endpoints/messaging/messages.ts index 01f70286..dde4c9a0 100644 --- a/packages/backend/src/server/api/endpoints/messaging/messages.ts +++ b/packages/backend/src/server/api/endpoints/messaging/messages.ts @@ -1,19 +1,19 @@ -import define from "@/server/api/define.js"; -import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; import { MessagingMessages, - UserGroups, UserGroupJoinings, + UserGroups, Users, } from "@/models/index.js"; +import { getUser } from "@/server/api/common/getters.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; -import { Brackets } from "typeorm"; import { - readUserMessagingMessage, - readGroupMessagingMessage, deliverReadActivity, + readGroupMessagingMessage, + readUserMessagingMessage, } from "@/server/api/common/read-messaging-message.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; +import { Brackets } from "typeorm"; export const meta = { tags: ["messaging"], diff --git a/packages/backend/src/server/api/endpoints/messaging/messages/create.ts b/packages/backend/src/server/api/endpoints/messaging/messages/create.ts index 6fd38eff..654bd75f 100644 --- a/packages/backend/src/server/api/endpoints/messaging/messages/create.ts +++ b/packages/backend/src/server/api/endpoints/messaging/messages/create.ts @@ -1,14 +1,14 @@ +import type { UserGroup } from "@/models/entities/user-group.js"; +import type { User } from "@/models/entities/user.js"; +import { + Blockings, + DriveFiles, + UserGroupJoinings, + UserGroups, +} from "@/models/index.js"; +import { getUser } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; -import { - DriveFiles, - UserGroups, - UserGroupJoinings, - Blockings, -} from "@/models/index.js"; -import type { User } from "@/models/entities/user.js"; -import type { UserGroup } from "@/models/entities/user-group.js"; import { createMessage } from "@/services/messages/create.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/messaging/messages/delete.ts b/packages/backend/src/server/api/endpoints/messaging/messages/delete.ts index 76691dd3..dd8471ae 100644 --- a/packages/backend/src/server/api/endpoints/messaging/messages/delete.ts +++ b/packages/backend/src/server/api/endpoints/messaging/messages/delete.ts @@ -1,8 +1,8 @@ +import { HOUR, SECOND } from "@/const.js"; +import { MessagingMessages } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { MessagingMessages } from "@/models/index.js"; import { deleteMessage } from "@/services/messages/delete.js"; -import { SECOND, HOUR } from "@/const.js"; export const meta = { tags: ["messaging"], diff --git a/packages/backend/src/server/api/endpoints/messaging/messages/read.ts b/packages/backend/src/server/api/endpoints/messaging/messages/read.ts index 5aa50155..1b4cc4d7 100644 --- a/packages/backend/src/server/api/endpoints/messaging/messages/read.ts +++ b/packages/backend/src/server/api/endpoints/messaging/messages/read.ts @@ -1,10 +1,10 @@ -import define from "@/server/api/define.js"; -import { ApiError } from "@/server/api/error.js"; import { MessagingMessages } from "@/models/index.js"; import { - readUserMessagingMessage, readGroupMessagingMessage, + readUserMessagingMessage, } from "@/server/api/common/read-messaging-message.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; export const meta = { tags: ["messaging"], diff --git a/packages/backend/src/server/api/endpoints/meta.ts b/packages/backend/src/server/api/endpoints/meta.ts index 27fa3dff..b330e96d 100644 --- a/packages/backend/src/server/api/endpoints/meta.ts +++ b/packages/backend/src/server/api/endpoints/meta.ts @@ -1,10 +1,10 @@ -import JSON5 from "json5"; -import { IsNull, MoreThan } from "typeorm"; import config from "@/config/index.js"; +import { MAX_CAPTION_TEXT_LENGTH, MAX_NOTE_TEXT_LENGTH } from "@/const.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; import { Ads, Emojis, Users } from "@/models/index.js"; -import { MAX_NOTE_TEXT_LENGTH, MAX_CAPTION_TEXT_LENGTH } from "@/const.js"; import define from "@/server/api/define.js"; +import JSON5 from "json5"; +import { IsNull, MoreThan } from "typeorm"; export const meta = { tags: ["meta"], diff --git a/packages/backend/src/server/api/endpoints/miauth/gen-token.ts b/packages/backend/src/server/api/endpoints/miauth/gen-token.ts index bca09d3f..35f18c0e 100644 --- a/packages/backend/src/server/api/endpoints/miauth/gen-token.ts +++ b/packages/backend/src/server/api/endpoints/miauth/gen-token.ts @@ -1,7 +1,7 @@ -import define from "@/server/api/define.js"; -import { AccessTokens } from "@/models/index.js"; import { genId } from "@/misc/gen-id.js"; import { secureRndstr } from "@/misc/secure-rndstr.js"; +import { AccessTokens } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["auth"], diff --git a/packages/backend/src/server/api/endpoints/mute/create.ts b/packages/backend/src/server/api/endpoints/mute/create.ts index 2eb93519..0ff1721d 100644 --- a/packages/backend/src/server/api/endpoints/mute/create.ts +++ b/packages/backend/src/server/api/endpoints/mute/create.ts @@ -1,9 +1,9 @@ +import { genId } from "@/misc/gen-id.js"; +import type { Muting } from "@/models/entities/muting.js"; +import { Mutings, NoteWatchings } from "@/models/index.js"; +import { getUser } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; -import { genId } from "@/misc/gen-id.js"; -import { Mutings, NoteWatchings } from "@/models/index.js"; -import type { Muting } from "@/models/entities/muting.js"; import { publishUserEvent } from "@/services/stream.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/mute/delete.ts b/packages/backend/src/server/api/endpoints/mute/delete.ts index 8058e9a6..104bc494 100644 --- a/packages/backend/src/server/api/endpoints/mute/delete.ts +++ b/packages/backend/src/server/api/endpoints/mute/delete.ts @@ -1,7 +1,7 @@ +import { Mutings } from "@/models/index.js"; +import { getUser } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; -import { Mutings } from "@/models/index.js"; import { publishUserEvent } from "@/services/stream.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/mute/list.ts b/packages/backend/src/server/api/endpoints/mute/list.ts index 9619457c..a0126468 100644 --- a/packages/backend/src/server/api/endpoints/mute/list.ts +++ b/packages/backend/src/server/api/endpoints/mute/list.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; import { Mutings } from "@/models/index.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["account"], diff --git a/packages/backend/src/server/api/endpoints/my/apps.ts b/packages/backend/src/server/api/endpoints/my/apps.ts index bc75b38e..1147c22f 100644 --- a/packages/backend/src/server/api/endpoints/my/apps.ts +++ b/packages/backend/src/server/api/endpoints/my/apps.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { Apps } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["account", "app"], diff --git a/packages/backend/src/server/api/endpoints/notes.ts b/packages/backend/src/server/api/endpoints/notes.ts index 6e2d3b4f..a63f597f 100644 --- a/packages/backend/src/server/api/endpoints/notes.ts +++ b/packages/backend/src/server/api/endpoints/notes.ts @@ -1,6 +1,6 @@ import { Notes } from "@/models/index.js"; -import define from "@/server/api/define.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/children.ts b/packages/backend/src/server/api/endpoints/notes/children.ts index d76771c3..afdd9c41 100644 --- a/packages/backend/src/server/api/endpoints/notes/children.ts +++ b/packages/backend/src/server/api/endpoints/notes/children.ts @@ -1,9 +1,9 @@ import { Notes } from "@/models/index.js"; -import define from "@/server/api/define.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; -import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; -import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; +import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; +import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/clips.ts b/packages/backend/src/server/api/endpoints/notes/clips.ts index 430ed02e..f649ae45 100644 --- a/packages/backend/src/server/api/endpoints/notes/clips.ts +++ b/packages/backend/src/server/api/endpoints/notes/clips.ts @@ -1,8 +1,8 @@ -import { In } from "typeorm"; import { ClipNotes, Clips } from "@/models/index.js"; -import define from "@/server/api/define.js"; import { getNote } from "@/server/api/common/getters.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; +import { In } from "typeorm"; export const meta = { tags: ["clips", "notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/conversation.ts b/packages/backend/src/server/api/endpoints/notes/conversation.ts index 99397408..fdb45430 100644 --- a/packages/backend/src/server/api/endpoints/notes/conversation.ts +++ b/packages/backend/src/server/api/endpoints/notes/conversation.ts @@ -1,8 +1,8 @@ import type { Note } from "@/models/entities/note.js"; import { Notes } from "@/models/index.js"; +import { getNote } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getNote } from "@/server/api/common/getters.js"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index 0465d09e..426b6904 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -1,22 +1,22 @@ -import { In } from "typeorm"; -import create from "@/services/note/create.js"; -import type { User } from "@/models/entities/user.js"; -import { - Users, - DriveFiles, - Notes, - Channels, - Blockings, -} from "@/models/index.js"; +import { MAX_NOTE_TEXT_LENGTH } from "@/const.js"; +import { HOUR } from "@/const.js"; +import type { Channel } from "@/models/entities/channel.js"; import type { DriveFile } from "@/models/entities/drive-file.js"; import type { Note } from "@/models/entities/note.js"; -import type { Channel } from "@/models/entities/channel.js"; -import { MAX_NOTE_TEXT_LENGTH } from "@/const.js"; -import { noteVisibilities } from "@/types.js"; -import { ApiError } from "@/server/api/error.js"; -import define from "@/server/api/define.js"; -import { HOUR } from "@/const.js"; +import type { User } from "@/models/entities/user.js"; +import { + Blockings, + Channels, + DriveFiles, + Notes, + Users, +} from "@/models/index.js"; import { getNote } from "@/server/api/common/getters.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; +import create from "@/services/note/create.js"; +import { noteVisibilities } from "@/types.js"; +import { In } from "typeorm"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/delete.ts b/packages/backend/src/server/api/endpoints/notes/delete.ts index 54aad1eb..32a64661 100644 --- a/packages/backend/src/server/api/endpoints/notes/delete.ts +++ b/packages/backend/src/server/api/endpoints/notes/delete.ts @@ -1,9 +1,9 @@ -import deleteNote from "@/services/note/delete.js"; +import { HOUR, SECOND } from "@/const.js"; import { Users } from "@/models/index.js"; -import define from "@/server/api/define.js"; import { getNote } from "@/server/api/common/getters.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { SECOND, HOUR } from "@/const.js"; +import deleteNote from "@/services/note/delete.js"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/edit.ts b/packages/backend/src/server/api/endpoints/notes/edit.ts index a0869e41..9e9fdd9e 100644 --- a/packages/backend/src/server/api/endpoints/notes/edit.ts +++ b/packages/backend/src/server/api/endpoints/notes/edit.ts @@ -1,41 +1,41 @@ -import { In } from "typeorm"; -import { index } from "@/services/note/create.js"; -import type { IRemoteUser, User } from "@/models/entities/user.js"; -import { - Users, - DriveFiles, - Notes, - Channels, - Blockings, - UserProfiles, - Polls, - NoteEdits, -} from "@/models/index.js"; +import { MAX_NOTE_TEXT_LENGTH } from "@/const.js"; +import { HOUR } from "@/const.js"; +import detectLanguage from "@/misc/detect-language.js"; +import { extractCustomEmojisFromMfm } from "@/misc/extract-custom-emojis-from-mfm.js"; +import { extractHashtags } from "@/misc/extract-hashtags.js"; +import { genId } from "@/misc/gen-id.js"; +// import { deliverQuestionUpdate } from "@/services/note/polls/update.js"; +import { langmap } from "@/misc/langmap.js"; +import type { Channel } from "@/models/entities/channel.js"; import type { DriveFile } from "@/models/entities/drive-file.js"; import type { IMentionedRemoteUsers, Note } from "@/models/entities/note.js"; -import type { Channel } from "@/models/entities/channel.js"; -import { MAX_NOTE_TEXT_LENGTH } from "@/const.js"; -import { noteVisibilities } from "@/types.js"; -import { ApiError } from "@/server/api/error.js"; -import define from "@/server/api/define.js"; -import { HOUR } from "@/const.js"; -import { getNote } from "@/server/api/common/getters.js"; import { Poll } from "@/models/entities/poll.js"; -import * as mfm from "mfm-js"; +import type { IRemoteUser, User } from "@/models/entities/user.js"; +import { + Blockings, + Channels, + DriveFiles, + NoteEdits, + Notes, + Polls, + UserProfiles, + Users, +} from "@/models/index.js"; import { concat } from "@/prelude/array.js"; -import { extractHashtags } from "@/misc/extract-hashtags.js"; -import { extractCustomEmojisFromMfm } from "@/misc/extract-custom-emojis-from-mfm.js"; -import { extractMentionedUsers } from "@/services/note/create.js"; -import { genId } from "@/misc/gen-id.js"; -import { publishNoteStream } from "@/services/stream.js"; import DeliverManager from "@/remote/activitypub/deliver-manager.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderNote from "@/remote/activitypub/renderer/note.js"; import renderUpdate from "@/remote/activitypub/renderer/update.js"; +import { getNote } from "@/server/api/common/getters.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; +import { index } from "@/services/note/create.js"; +import { extractMentionedUsers } from "@/services/note/create.js"; import { deliverToRelays } from "@/services/relay.js"; -// import { deliverQuestionUpdate } from "@/services/note/polls/update.js"; -import { langmap } from "@/misc/langmap.js"; -import detectLanguage from "@/misc/detect-language.js"; +import { publishNoteStream } from "@/services/stream.js"; +import { noteVisibilities } from "@/types.js"; +import * as mfm from "mfm-js"; +import { In } from "typeorm"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/favorites/create.ts b/packages/backend/src/server/api/endpoints/notes/favorites/create.ts index 8b2c7ad3..16cf51c2 100644 --- a/packages/backend/src/server/api/endpoints/notes/favorites/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/favorites/create.ts @@ -1,8 +1,8 @@ -import { NoteFavorites } from "@/models/index.js"; import { genId } from "@/misc/gen-id.js"; +import { NoteFavorites } from "@/models/index.js"; +import { getNote } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getNote } from "@/server/api/common/getters.js"; export const meta = { tags: ["notes", "favorites"], diff --git a/packages/backend/src/server/api/endpoints/notes/favorites/delete.ts b/packages/backend/src/server/api/endpoints/notes/favorites/delete.ts index 018ef91b..b2b0ad6b 100644 --- a/packages/backend/src/server/api/endpoints/notes/favorites/delete.ts +++ b/packages/backend/src/server/api/endpoints/notes/favorites/delete.ts @@ -1,7 +1,7 @@ import { NoteFavorites } from "@/models/index.js"; +import { getNote } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getNote } from "@/server/api/common/getters.js"; export const meta = { tags: ["notes", "favorites"], diff --git a/packages/backend/src/server/api/endpoints/notes/featured.ts b/packages/backend/src/server/api/endpoints/notes/featured.ts index 4f90145e..3c15d705 100644 --- a/packages/backend/src/server/api/endpoints/notes/featured.ts +++ b/packages/backend/src/server/api/endpoints/notes/featured.ts @@ -1,7 +1,7 @@ import { Notes } from "@/models/index.js"; -import define from "@/server/api/define.js"; -import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; +import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/global-timeline.ts b/packages/backend/src/server/api/endpoints/notes/global-timeline.ts index fee660dd..d8e49f06 100644 --- a/packages/backend/src/server/api/endpoints/notes/global-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/global-timeline.ts @@ -1,14 +1,14 @@ import { fetchMeta } from "@/misc/fetch-meta.js"; import { Notes } from "@/models/index.js"; -import { activeUsersChart } from "@/services/chart/index.js"; -import define from "@/server/api/define.js"; -import { ApiError } from "@/server/api/error.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; +import { generateMutedNoteQuery } from "@/server/api/common/generate-muted-note-query.js"; import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; import { generateRepliesQuery } from "@/server/api/common/generate-replies-query.js"; -import { generateMutedNoteQuery } from "@/server/api/common/generate-muted-note-query.js"; -import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; import { generateMutedUserRenotesQueryForNotes } from "@/server/api/common/generated-muted-renote-query.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; +import { activeUsersChart } from "@/services/chart/index.js"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts index c573a0c8..4639b97e 100644 --- a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts @@ -1,17 +1,17 @@ -import { Brackets } from "typeorm"; import { fetchMeta } from "@/misc/fetch-meta.js"; import { Followings, Notes } from "@/models/index.js"; -import { activeUsersChart } from "@/services/chart/index.js"; -import define from "@/server/api/define.js"; -import { ApiError } from "@/server/api/error.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; -import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; +import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; +import { generateChannelQuery } from "@/server/api/common/generate-channel-query.js"; +import { generateMutedNoteQuery } from "@/server/api/common/generate-muted-note-query.js"; import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; import { generateRepliesQuery } from "@/server/api/common/generate-replies-query.js"; -import { generateMutedNoteQuery } from "@/server/api/common/generate-muted-note-query.js"; -import { generateChannelQuery } from "@/server/api/common/generate-channel-query.js"; -import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; +import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; import { generateMutedUserRenotesQueryForNotes } from "@/server/api/common/generated-muted-renote-query.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; +import { activeUsersChart } from "@/services/chart/index.js"; +import { Brackets } from "typeorm"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts index c89b8f87..b015e7d0 100644 --- a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts @@ -1,17 +1,17 @@ -import { Brackets } from "typeorm"; import { fetchMeta } from "@/misc/fetch-meta.js"; import { Notes } from "@/models/index.js"; -import { activeUsersChart } from "@/services/chart/index.js"; +import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; +import { generateChannelQuery } from "@/server/api/common/generate-channel-query.js"; +import { generateMutedNoteQuery } from "@/server/api/common/generate-muted-note-query.js"; +import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; +import { generateRepliesQuery } from "@/server/api/common/generate-replies-query.js"; +import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; +import { generateMutedUserRenotesQueryForNotes } from "@/server/api/common/generated-muted-renote-query.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; -import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; -import { generateRepliesQuery } from "@/server/api/common/generate-replies-query.js"; -import { generateMutedNoteQuery } from "@/server/api/common/generate-muted-note-query.js"; -import { generateChannelQuery } from "@/server/api/common/generate-channel-query.js"; -import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; -import { generateMutedUserRenotesQueryForNotes } from "@/server/api/common/generated-muted-renote-query.js"; +import { activeUsersChart } from "@/services/chart/index.js"; +import { Brackets } from "typeorm"; export const meta = { tags: ["notes"], @@ -118,7 +118,7 @@ export default define(meta, paramDef, async (ps, user) => { query.andWhere( new Brackets((qb) => { for (const type of ps.fileType!) { - const i = ps.fileType!.indexOf(type); + const i = ps.fileType?.indexOf(type); qb.orWhere(`:type${i} = ANY(note.attachedFileTypes)`, { [`type${i}`]: type, }); diff --git a/packages/backend/src/server/api/endpoints/notes/make-private.ts b/packages/backend/src/server/api/endpoints/notes/make-private.ts index a4a26d15..d10bfa4f 100644 --- a/packages/backend/src/server/api/endpoints/notes/make-private.ts +++ b/packages/backend/src/server/api/endpoints/notes/make-private.ts @@ -1,10 +1,10 @@ -import deleteNote from "@/services/note/delete.js"; +import { HOUR, SECOND } from "@/const.js"; import { Notes } from "@/models/index.js"; -import define from "../../define.js"; -import { getNote } from "../../common/getters.js"; -import { ApiError } from "../../error.js"; -import { SECOND, HOUR } from "@/const.js"; +import deleteNote from "@/services/note/delete.js"; import { publishNoteStream } from "@/services/stream.js"; +import { getNote } from "../../common/getters.js"; +import define from "../../define.js"; +import { ApiError } from "../../error.js"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/mentions.ts b/packages/backend/src/server/api/endpoints/notes/mentions.ts index 44ee9093..1b606087 100644 --- a/packages/backend/src/server/api/endpoints/notes/mentions.ts +++ b/packages/backend/src/server/api/endpoints/notes/mentions.ts @@ -1,12 +1,12 @@ -import { Brackets } from "typeorm"; -import read from "@/services/note/read.js"; -import { Notes, Followings } from "@/models/index.js"; -import define from "@/server/api/define.js"; -import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; -import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import { Followings, Notes } from "@/models/index.js"; import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; import { generateMutedNoteThreadQuery } from "@/server/api/common/generate-muted-note-thread-query.js"; +import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; +import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; +import read from "@/services/note/read.js"; +import { Brackets } from "typeorm"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts b/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts index ca0d0f03..a792b75e 100644 --- a/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts +++ b/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts @@ -1,6 +1,6 @@ -import { Brackets, In } from "typeorm"; -import { Polls, Mutings, Notes, PollVotes } from "@/models/index.js"; +import { Mutings, Notes, PollVotes, Polls } from "@/models/index.js"; import define from "@/server/api/define.js"; +import { Brackets, In } from "typeorm"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/polls/vote.ts b/packages/backend/src/server/api/endpoints/notes/polls/vote.ts index 1680eca6..45916e72 100644 --- a/packages/backend/src/server/api/endpoints/notes/polls/vote.ts +++ b/packages/backend/src/server/api/endpoints/notes/polls/vote.ts @@ -1,21 +1,21 @@ -import { Not } from "typeorm"; -import { publishNoteStream } from "@/services/stream.js"; -import { createNotification } from "@/services/create-notification.js"; +import { genId } from "@/misc/gen-id.js"; +import type { IRemoteUser } from "@/models/entities/user.js"; +import { + Blockings, + NoteWatchings, + PollVotes, + Polls, + Users, +} from "@/models/index.js"; import { deliver } from "@/queue/index.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderVote from "@/remote/activitypub/renderer/vote.js"; -import { - PollVotes, - NoteWatchings, - Users, - Polls, - Blockings, -} from "@/models/index.js"; -import type { IRemoteUser } from "@/models/entities/user.js"; -import { genId } from "@/misc/gen-id.js"; import { getNote } from "@/server/api/common/getters.js"; -import { ApiError } from "@/server/api/error.js"; import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; +import { createNotification } from "@/services/create-notification.js"; +import { publishNoteStream } from "@/services/stream.js"; +import { Not } from "typeorm"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/reactions.ts b/packages/backend/src/server/api/endpoints/notes/reactions.ts index 386a3a08..ed38b1af 100644 --- a/packages/backend/src/server/api/endpoints/notes/reactions.ts +++ b/packages/backend/src/server/api/endpoints/notes/reactions.ts @@ -1,9 +1,9 @@ -import type { FindOptionsWhere } from "typeorm"; -import { NoteReactions } from "@/models/index.js"; import type { NoteReaction } from "@/models/entities/note-reaction.js"; +import { NoteReactions } from "@/models/index.js"; +import { getNote } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getNote } from "@/server/api/common/getters.js"; +import type { FindOptionsWhere } from "typeorm"; export const meta = { tags: ["notes", "reactions"], diff --git a/packages/backend/src/server/api/endpoints/notes/reactions/create.ts b/packages/backend/src/server/api/endpoints/notes/reactions/create.ts index c49a957d..36c70c34 100644 --- a/packages/backend/src/server/api/endpoints/notes/reactions/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/reactions/create.ts @@ -1,7 +1,7 @@ -import createReaction from "@/services/note/reaction/create.js"; -import define from "@/server/api/define.js"; import { getNote } from "@/server/api/common/getters.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; +import createReaction from "@/services/note/reaction/create.js"; export const meta = { tags: ["reactions", "notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/reactions/delete.ts b/packages/backend/src/server/api/endpoints/notes/reactions/delete.ts index f135bd7f..503015fd 100644 --- a/packages/backend/src/server/api/endpoints/notes/reactions/delete.ts +++ b/packages/backend/src/server/api/endpoints/notes/reactions/delete.ts @@ -1,8 +1,8 @@ -import deleteReaction from "@/services/note/reaction/delete.js"; -import define from "@/server/api/define.js"; +import { HOUR, SECOND } from "@/const.js"; import { getNote } from "@/server/api/common/getters.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { SECOND, HOUR } from "@/const.js"; +import deleteReaction from "@/services/note/reaction/delete.js"; export const meta = { tags: ["reactions", "notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/recommended-timeline.ts b/packages/backend/src/server/api/endpoints/notes/recommended-timeline.ts index 53ac1288..599bf158 100644 --- a/packages/backend/src/server/api/endpoints/notes/recommended-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/recommended-timeline.ts @@ -1,17 +1,17 @@ -import { Brackets } from "typeorm"; import { fetchMeta } from "@/misc/fetch-meta.js"; import { Notes } from "@/models/index.js"; -import { activeUsersChart } from "@/services/chart/index.js"; +import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; +import { generateChannelQuery } from "@/server/api/common/generate-channel-query.js"; +import { generateMutedNoteQuery } from "@/server/api/common/generate-muted-note-query.js"; +import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; +import { generateRepliesQuery } from "@/server/api/common/generate-replies-query.js"; +import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; +import { generateMutedUserRenotesQueryForNotes } from "@/server/api/common/generated-muted-renote-query.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; -import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; -import { generateRepliesQuery } from "@/server/api/common/generate-replies-query.js"; -import { generateMutedNoteQuery } from "@/server/api/common/generate-muted-note-query.js"; -import { generateChannelQuery } from "@/server/api/common/generate-channel-query.js"; -import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; -import { generateMutedUserRenotesQueryForNotes } from "@/server/api/common/generated-muted-renote-query.js"; +import { activeUsersChart } from "@/services/chart/index.js"; +import { Brackets } from "typeorm"; export const meta = { tags: ["notes"], @@ -121,7 +121,7 @@ export default define(meta, paramDef, async (ps, user) => { query.andWhere( new Brackets((qb) => { for (const type of ps.fileType!) { - const i = ps.fileType!.indexOf(type); + const i = ps.fileType?.indexOf(type); qb.orWhere(`:type${i} = ANY(note.attachedFileTypes)`, { [`type${i}`]: type, }); diff --git a/packages/backend/src/server/api/endpoints/notes/renotes.ts b/packages/backend/src/server/api/endpoints/notes/renotes.ts index 683004eb..7b7d88cd 100644 --- a/packages/backend/src/server/api/endpoints/notes/renotes.ts +++ b/packages/backend/src/server/api/endpoints/notes/renotes.ts @@ -1,11 +1,11 @@ import { Notes } from "@/models/index.js"; -import define from "@/server/api/define.js"; -import { getNote } from "@/server/api/common/getters.js"; -import { ApiError } from "@/server/api/error.js"; -import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; -import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; +import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; +import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; +import { getNote } from "@/server/api/common/getters.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; export const meta = { tags: ["notes"], @@ -53,7 +53,7 @@ export default define(meta, paramDef, async (ps, user) => { throw err; }); - let query = makePaginationQuery( + const query = makePaginationQuery( Notes.createQueryBuilder("note"), ps.sinceId, ps.untilId, diff --git a/packages/backend/src/server/api/endpoints/notes/replies.ts b/packages/backend/src/server/api/endpoints/notes/replies.ts index e4341ebc..8da59ea8 100644 --- a/packages/backend/src/server/api/endpoints/notes/replies.ts +++ b/packages/backend/src/server/api/endpoints/notes/replies.ts @@ -1,9 +1,9 @@ import { Notes } from "@/models/index.js"; -import define from "@/server/api/define.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; -import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; -import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; +import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; +import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts b/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts index e87725e3..6ede52a1 100644 --- a/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts +++ b/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts @@ -1,12 +1,12 @@ -import { Brackets } from "typeorm"; -import { Notes } from "@/models/index.js"; -import { safeForSql } from "@/misc/safe-for-sql.js"; import { normalizeForSearch } from "@/misc/normalize-for-search.js"; -import define from "@/server/api/define.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import { safeForSql } from "@/misc/safe-for-sql.js"; +import { Notes } from "@/models/index.js"; +import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; -import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; +import { Brackets } from "typeorm"; export const meta = { tags: ["notes", "hashtags"], diff --git a/packages/backend/src/server/api/endpoints/notes/search.ts b/packages/backend/src/server/api/endpoints/notes/search.ts index 7f971978..c4dc2067 100644 --- a/packages/backend/src/server/api/endpoints/notes/search.ts +++ b/packages/backend/src/server/api/endpoints/notes/search.ts @@ -1,16 +1,16 @@ +import { sqlLikeEscape } from "@/misc/sql-like-escape.js"; +import { Note } from "@/models/entities/note.js"; // import { FindManyOptions, In } from "typeorm"; import { Notes } from "@/models/index.js"; -import { Note } from "@/models/entities/note.js"; +import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; +import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; +import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; // import config from "@/config/index.js"; // import es from "@/db/elasticsearch.js"; // import sonic from "@/db/sonic.js"; // import meilisearch, { MeilisearchNote } from "@/db/meilisearch.js"; import define from "@/server/api/define.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; -import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; -import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; -import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; -import { sqlLikeEscape } from "@/misc/sql-like-escape.js"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/show.ts b/packages/backend/src/server/api/endpoints/notes/show.ts index 1319e47d..7cbb6b3f 100644 --- a/packages/backend/src/server/api/endpoints/notes/show.ts +++ b/packages/backend/src/server/api/endpoints/notes/show.ts @@ -1,6 +1,6 @@ import { Notes } from "@/models/index.js"; -import define from "@/server/api/define.js"; import { getNote } from "@/server/api/common/getters.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts b/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts index 7c40a459..9dd3c53a 100644 --- a/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts @@ -1,9 +1,9 @@ -import { Notes, NoteThreadMutings } from "@/models/index.js"; import { genId } from "@/misc/gen-id.js"; -import readNote from "@/services/note/read.js"; -import define from "@/server/api/define.js"; +import { NoteThreadMutings, Notes } from "@/models/index.js"; import { getNote } from "@/server/api/common/getters.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; +import readNote from "@/services/note/read.js"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/thread-muting/delete.ts b/packages/backend/src/server/api/endpoints/notes/thread-muting/delete.ts index 62766bed..dc188765 100644 --- a/packages/backend/src/server/api/endpoints/notes/thread-muting/delete.ts +++ b/packages/backend/src/server/api/endpoints/notes/thread-muting/delete.ts @@ -1,6 +1,6 @@ import { NoteThreadMutings } from "@/models/index.js"; -import define from "@/server/api/define.js"; import { getNote } from "@/server/api/common/getters.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/notes/timeline.ts b/packages/backend/src/server/api/endpoints/notes/timeline.ts index 0f8da62e..8512149e 100644 --- a/packages/backend/src/server/api/endpoints/notes/timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/timeline.ts @@ -1,16 +1,16 @@ -import { Brackets } from "typeorm"; -import { Notes, Followings } from "@/models/index.js"; -import { activeUsersChart } from "@/services/chart/index.js"; -import define from "@/server/api/define.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; -import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; +import { Followings, Notes } from "@/models/index.js"; +import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; +import { generateChannelQuery } from "@/server/api/common/generate-channel-query.js"; +import { generateMutedNoteQuery } from "@/server/api/common/generate-muted-note-query.js"; import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; import { generateRepliesQuery } from "@/server/api/common/generate-replies-query.js"; -import { generateMutedNoteQuery } from "@/server/api/common/generate-muted-note-query.js"; -import { generateChannelQuery } from "@/server/api/common/generate-channel-query.js"; -import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; +import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; import { generateMutedUserRenotesQueryForNotes } from "@/server/api/common/generated-muted-renote-query.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; +import { activeUsersChart } from "@/services/chart/index.js"; +import { Brackets } from "typeorm"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/translate.ts b/packages/backend/src/server/api/endpoints/notes/translate.ts index d1de3999..61f7041d 100644 --- a/packages/backend/src/server/api/endpoints/notes/translate.ts +++ b/packages/backend/src/server/api/endpoints/notes/translate.ts @@ -1,12 +1,12 @@ import { URLSearchParams } from "node:url"; -import fetch from "node-fetch"; import config from "@/config/index.js"; -import { Converter } from "opencc-js"; -import { getAgentByUrl } from "@/misc/fetch.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; -import { ApiError } from "@/server/api/error.js"; +import { getAgentByUrl } from "@/misc/fetch.js"; import { getNote } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; +import fetch from "node-fetch"; +import { Converter } from "opencc-js"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/unrenote.ts b/packages/backend/src/server/api/endpoints/notes/unrenote.ts index 4a396612..18e49574 100644 --- a/packages/backend/src/server/api/endpoints/notes/unrenote.ts +++ b/packages/backend/src/server/api/endpoints/notes/unrenote.ts @@ -1,9 +1,9 @@ -import deleteNote from "@/services/note/delete.js"; +import { HOUR, SECOND } from "@/const.js"; import { Notes, Users } from "@/models/index.js"; -import define from "@/server/api/define.js"; import { getNote } from "@/server/api/common/getters.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { SECOND, HOUR } from "@/const.js"; +import deleteNote from "@/services/note/delete.js"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts index 3a87ed64..d52f10ad 100644 --- a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts @@ -1,10 +1,10 @@ -import { Brackets } from "typeorm"; -import { UserLists, UserListJoinings, Notes } from "@/models/index.js"; -import { activeUsersChart } from "@/services/chart/index.js"; +import { Notes, UserListJoinings, UserLists } from "@/models/index.js"; +import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; -import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; +import { activeUsersChart } from "@/services/chart/index.js"; +import { Brackets } from "typeorm"; export const meta = { tags: ["notes", "lists"], diff --git a/packages/backend/src/server/api/endpoints/notes/watching/create.ts b/packages/backend/src/server/api/endpoints/notes/watching/create.ts index ec13f5aa..f5faf5ad 100644 --- a/packages/backend/src/server/api/endpoints/notes/watching/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/watching/create.ts @@ -1,7 +1,7 @@ -import watch from "@/services/note/watch.js"; -import define from "@/server/api/define.js"; import { getNote } from "@/server/api/common/getters.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; +import watch from "@/services/note/watch.js"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/watching/delete.ts b/packages/backend/src/server/api/endpoints/notes/watching/delete.ts index 18994fa8..f4bea441 100644 --- a/packages/backend/src/server/api/endpoints/notes/watching/delete.ts +++ b/packages/backend/src/server/api/endpoints/notes/watching/delete.ts @@ -1,7 +1,7 @@ -import unwatch from "@/services/note/unwatch.js"; -import define from "@/server/api/define.js"; import { getNote } from "@/server/api/common/getters.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; +import unwatch from "@/services/note/unwatch.js"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notifications/create.ts b/packages/backend/src/server/api/endpoints/notifications/create.ts index 2077cceb..f29a30ac 100644 --- a/packages/backend/src/server/api/endpoints/notifications/create.ts +++ b/packages/backend/src/server/api/endpoints/notifications/create.ts @@ -1,5 +1,5 @@ -import { createNotification } from "@/services/create-notification.js"; import define from "@/server/api/define.js"; +import { createNotification } from "@/services/create-notification.js"; export const meta = { tags: ["notifications"], diff --git a/packages/backend/src/server/api/endpoints/notifications/mark-all-as-read.ts b/packages/backend/src/server/api/endpoints/notifications/mark-all-as-read.ts index 56803638..06539dd1 100644 --- a/packages/backend/src/server/api/endpoints/notifications/mark-all-as-read.ts +++ b/packages/backend/src/server/api/endpoints/notifications/mark-all-as-read.ts @@ -1,7 +1,7 @@ -import { publishMainStream } from "@/services/stream.js"; -import { pushNotification } from "@/services/push-notification.js"; import { Notifications } from "@/models/index.js"; import define from "@/server/api/define.js"; +import { pushNotification } from "@/services/push-notification.js"; +import { publishMainStream } from "@/services/stream.js"; export const meta = { tags: ["notifications", "account"], diff --git a/packages/backend/src/server/api/endpoints/notifications/read.ts b/packages/backend/src/server/api/endpoints/notifications/read.ts index 358ca062..534d3f78 100644 --- a/packages/backend/src/server/api/endpoints/notifications/read.ts +++ b/packages/backend/src/server/api/endpoints/notifications/read.ts @@ -1,5 +1,5 @@ -import define from "@/server/api/define.js"; import { readNotification } from "@/server/api/common/read-notification.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["notifications", "account"], diff --git a/packages/backend/src/server/api/endpoints/page-push.ts b/packages/backend/src/server/api/endpoints/page-push.ts index 1f87372d..194129e4 100644 --- a/packages/backend/src/server/api/endpoints/page-push.ts +++ b/packages/backend/src/server/api/endpoints/page-push.ts @@ -1,7 +1,7 @@ -import { publishMainStream } from "@/services/stream.js"; -import { Users, Pages } from "@/models/index.js"; +import { Pages, Users } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; +import { publishMainStream } from "@/services/stream.js"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/pages/create.ts b/packages/backend/src/server/api/endpoints/pages/create.ts index ea0f8ba8..cac0fd3b 100644 --- a/packages/backend/src/server/api/endpoints/pages/create.ts +++ b/packages/backend/src/server/api/endpoints/pages/create.ts @@ -1,9 +1,9 @@ -import { Pages, DriveFiles } from "@/models/index.js"; +import { HOUR } from "@/const.js"; import { genId } from "@/misc/gen-id.js"; import { Page } from "@/models/entities/page.js"; +import { DriveFiles, Pages } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { HOUR } from "@/const.js"; export const meta = { tags: ["pages"], diff --git a/packages/backend/src/server/api/endpoints/pages/like.ts b/packages/backend/src/server/api/endpoints/pages/like.ts index ab64b9b9..4a396786 100644 --- a/packages/backend/src/server/api/endpoints/pages/like.ts +++ b/packages/backend/src/server/api/endpoints/pages/like.ts @@ -1,5 +1,5 @@ -import { Pages, PageLikes } from "@/models/index.js"; import { genId } from "@/misc/gen-id.js"; +import { PageLikes, Pages } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; diff --git a/packages/backend/src/server/api/endpoints/pages/show.ts b/packages/backend/src/server/api/endpoints/pages/show.ts index ac347cf1..54b6b3cc 100644 --- a/packages/backend/src/server/api/endpoints/pages/show.ts +++ b/packages/backend/src/server/api/endpoints/pages/show.ts @@ -1,8 +1,8 @@ -import { IsNull } from "typeorm"; -import { Pages, Users } from "@/models/index.js"; import type { Page } from "@/models/entities/page.js"; +import { Pages, Users } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; +import { IsNull } from "typeorm"; export const meta = { tags: ["pages"], diff --git a/packages/backend/src/server/api/endpoints/pages/unlike.ts b/packages/backend/src/server/api/endpoints/pages/unlike.ts index 428f9845..3b020709 100644 --- a/packages/backend/src/server/api/endpoints/pages/unlike.ts +++ b/packages/backend/src/server/api/endpoints/pages/unlike.ts @@ -1,4 +1,4 @@ -import { Pages, PageLikes } from "@/models/index.js"; +import { PageLikes, Pages } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; diff --git a/packages/backend/src/server/api/endpoints/pages/update.ts b/packages/backend/src/server/api/endpoints/pages/update.ts index 5f434d02..87fa93ce 100644 --- a/packages/backend/src/server/api/endpoints/pages/update.ts +++ b/packages/backend/src/server/api/endpoints/pages/update.ts @@ -1,8 +1,8 @@ -import { Not } from "typeorm"; -import { Pages, DriveFiles } from "@/models/index.js"; +import { HOUR } from "@/const.js"; +import { DriveFiles, Pages } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { HOUR } from "@/const.js"; +import { Not } from "typeorm"; export const meta = { tags: ["pages"], @@ -129,6 +129,6 @@ export default define(meta, paramDef, async (ps, user) => { ? null : ps.eyeCatchingImageId === undefined ? page.eyeCatchingImageId - : eyeCatchingImage!.id, + : eyeCatchingImage?.id, }); }); diff --git a/packages/backend/src/server/api/endpoints/patrons.ts b/packages/backend/src/server/api/endpoints/patrons.ts index 51ab2752..517aba8b 100644 --- a/packages/backend/src/server/api/endpoints/patrons.ts +++ b/packages/backend/src/server/api/endpoints/patrons.ts @@ -1,7 +1,7 @@ -import define from "@/server/api/define.js"; import * as fs from "node:fs"; -import { fileURLToPath } from "node:url"; import { dirname } from "node:path"; +import { fileURLToPath } from "node:url"; +import define from "@/server/api/define.js"; const _filename = fileURLToPath(import.meta.url); const _dirname = dirname(_filename); @@ -27,7 +27,7 @@ export default define(meta, paramDef, async (ps) => { fs.readFileSync(`${_dirname}/../../../../../../patrons.json`, "utf-8"), ); return { - patrons: patrons["patrons"], - sponsors: patrons["sponsors"], + patrons: patrons.patrons, + sponsors: patrons.sponsors, }; }); diff --git a/packages/backend/src/server/api/endpoints/pinned-users.ts b/packages/backend/src/server/api/endpoints/pinned-users.ts index b3273787..b75eb3f2 100644 --- a/packages/backend/src/server/api/endpoints/pinned-users.ts +++ b/packages/backend/src/server/api/endpoints/pinned-users.ts @@ -1,9 +1,9 @@ -import { IsNull } from "typeorm"; -import { Users } from "@/models/index.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; import * as Acct from "@/misc/acct.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; import type { User } from "@/models/entities/user.js"; +import { Users } from "@/models/index.js"; import define from "@/server/api/define.js"; +import { IsNull } from "typeorm"; export const meta = { tags: ["users"], diff --git a/packages/backend/src/server/api/endpoints/promo/read.ts b/packages/backend/src/server/api/endpoints/promo/read.ts index 4b414679..eb1cc128 100644 --- a/packages/backend/src/server/api/endpoints/promo/read.ts +++ b/packages/backend/src/server/api/endpoints/promo/read.ts @@ -1,8 +1,8 @@ -import { PromoReads } from "@/models/index.js"; import { genId } from "@/misc/gen-id.js"; +import { PromoReads } from "@/models/index.js"; +import { getNote } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getNote } from "@/server/api/common/getters.js"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/renote-mute/create.ts b/packages/backend/src/server/api/endpoints/renote-mute/create.ts index afe23f38..6b020c2a 100644 --- a/packages/backend/src/server/api/endpoints/renote-mute/create.ts +++ b/packages/backend/src/server/api/endpoints/renote-mute/create.ts @@ -1,9 +1,9 @@ import { genId } from "@/misc/gen-id.js"; -import { RenoteMutings } from "@/models/index.js"; import { RenoteMuting } from "@/models/entities/renote-muting.js"; +import { RenoteMutings } from "@/models/index.js"; +import { getUser } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; export const meta = { tags: ["account"], diff --git a/packages/backend/src/server/api/endpoints/renote-mute/delete.ts b/packages/backend/src/server/api/endpoints/renote-mute/delete.ts index 6a824881..436ff8a8 100644 --- a/packages/backend/src/server/api/endpoints/renote-mute/delete.ts +++ b/packages/backend/src/server/api/endpoints/renote-mute/delete.ts @@ -1,7 +1,7 @@ import { RenoteMutings } from "@/models/index.js"; +import { getUser } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; export const meta = { tags: ["account"], diff --git a/packages/backend/src/server/api/endpoints/renote-mute/list.ts b/packages/backend/src/server/api/endpoints/renote-mute/list.ts index b1945271..9dbea924 100644 --- a/packages/backend/src/server/api/endpoints/renote-mute/list.ts +++ b/packages/backend/src/server/api/endpoints/renote-mute/list.ts @@ -1,6 +1,6 @@ import { RenoteMutings } from "@/models/index.js"; -import define from "@/server/api/define.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["account"], diff --git a/packages/backend/src/server/api/endpoints/request-reset-password.ts b/packages/backend/src/server/api/endpoints/request-reset-password.ts index 3c78058a..802b882e 100644 --- a/packages/backend/src/server/api/endpoints/request-reset-password.ts +++ b/packages/backend/src/server/api/endpoints/request-reset-password.ts @@ -1,11 +1,11 @@ +import config from "@/config/index.js"; +import { HOUR } from "@/const.js"; +import { genId } from "@/misc/gen-id.js"; +import { PasswordResetRequests, UserProfiles, Users } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { sendEmail } from "@/services/send-email.js"; import rndstr from "rndstr"; import { IsNull } from "typeorm"; -import config from "@/config/index.js"; -import { Users, UserProfiles, PasswordResetRequests } from "@/models/index.js"; -import { sendEmail } from "@/services/send-email.js"; -import { genId } from "@/misc/gen-id.js"; -import define from "@/server/api/define.js"; -import { HOUR } from "@/const.js"; export const meta = { tags: ["reset password"], diff --git a/packages/backend/src/server/api/endpoints/reset-password.ts b/packages/backend/src/server/api/endpoints/reset-password.ts index ff5c8d98..8f642f88 100644 --- a/packages/backend/src/server/api/endpoints/reset-password.ts +++ b/packages/backend/src/server/api/endpoints/reset-password.ts @@ -1,6 +1,6 @@ -import { UserProfiles, PasswordResetRequests } from "@/models/index.js"; -import define from "@/server/api/define.js"; import { hashPassword } from "@/misc/password.js"; +import { PasswordResetRequests, UserProfiles } from "@/models/index.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["reset password"], diff --git a/packages/backend/src/server/api/endpoints/server-info.ts b/packages/backend/src/server/api/endpoints/server-info.ts index ff3bfcd1..dd9ff162 100644 --- a/packages/backend/src/server/api/endpoints/server-info.ts +++ b/packages/backend/src/server/api/endpoints/server-info.ts @@ -1,8 +1,8 @@ import * as os from "node:os"; -import si from "systeminformation"; -import define from "@/server/api/define.js"; import meilisearch from "@/db/meilisearch.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; +import define from "@/server/api/define.js"; +import si from "systeminformation"; export const meta = { requireCredential: false, diff --git a/packages/backend/src/server/api/endpoints/stats.ts b/packages/backend/src/server/api/endpoints/stats.ts index 184d7fb7..b667f10a 100644 --- a/packages/backend/src/server/api/endpoints/stats.ts +++ b/packages/backend/src/server/api/endpoints/stats.ts @@ -1,7 +1,7 @@ +import { Cache } from "@/misc/cache.js"; import { Instances, Notes, Users } from "@/models/index.js"; import define from "@/server/api/define.js"; import { IsNull } from "typeorm"; -import { Cache } from "@/misc/cache.js"; export const meta = { requireCredential: false, diff --git a/packages/backend/src/server/api/endpoints/username/available.ts b/packages/backend/src/server/api/endpoints/username/available.ts index cd634a79..88c5964b 100644 --- a/packages/backend/src/server/api/endpoints/username/available.ts +++ b/packages/backend/src/server/api/endpoints/username/available.ts @@ -1,7 +1,7 @@ -import { IsNull } from "typeorm"; -import { Users, UsedUsernames } from "@/models/index.js"; import config from "@/config/index.js"; +import { UsedUsernames, Users } from "@/models/index.js"; import define from "@/server/api/define.js"; +import { IsNull } from "typeorm"; export const meta = { tags: ["users"], diff --git a/packages/backend/src/server/api/endpoints/users.ts b/packages/backend/src/server/api/endpoints/users.ts index 20371fce..f8a24c29 100644 --- a/packages/backend/src/server/api/endpoints/users.ts +++ b/packages/backend/src/server/api/endpoints/users.ts @@ -1,7 +1,7 @@ import { Users } from "@/models/index.js"; -import define from "@/server/api/define.js"; -import { generateMutedUserQueryForUsers } from "@/server/api/common/generate-muted-user-query.js"; import { generateBlockQueryForUsers } from "@/server/api/common/generate-block-query.js"; +import { generateMutedUserQueryForUsers } from "@/server/api/common/generate-muted-user-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["users"], diff --git a/packages/backend/src/server/api/endpoints/users/clips.ts b/packages/backend/src/server/api/endpoints/users/clips.ts index 132e190b..f57c3cfd 100644 --- a/packages/backend/src/server/api/endpoints/users/clips.ts +++ b/packages/backend/src/server/api/endpoints/users/clips.ts @@ -1,6 +1,6 @@ import { Clips } from "@/models/index.js"; -import define from "@/server/api/define.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["users", "clips"], diff --git a/packages/backend/src/server/api/endpoints/users/followers.ts b/packages/backend/src/server/api/endpoints/users/followers.ts index f57983d4..b65f3f22 100644 --- a/packages/backend/src/server/api/endpoints/users/followers.ts +++ b/packages/backend/src/server/api/endpoints/users/followers.ts @@ -1,9 +1,9 @@ -import { IsNull } from "typeorm"; -import { Users, Followings, UserProfiles } from "@/models/index.js"; import { toPunyNullable } from "@/misc/convert-host.js"; +import { Followings, UserProfiles, Users } from "@/models/index.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import { IsNull } from "typeorm"; export const meta = { tags: ["users"], @@ -79,7 +79,7 @@ export default define(meta, paramDef, async (ps, me) => { ps.userId != null ? { id: ps.userId } : { - usernameLower: ps.username!.toLowerCase(), + usernameLower: ps.username?.toLowerCase(), host: toPunyNullable(ps.host) ?? IsNull(), }, ); diff --git a/packages/backend/src/server/api/endpoints/users/following.ts b/packages/backend/src/server/api/endpoints/users/following.ts index 84eb7ccc..b8ef2503 100644 --- a/packages/backend/src/server/api/endpoints/users/following.ts +++ b/packages/backend/src/server/api/endpoints/users/following.ts @@ -1,9 +1,9 @@ -import { IsNull } from "typeorm"; -import { Users, Followings, UserProfiles } from "@/models/index.js"; import { toPunyNullable } from "@/misc/convert-host.js"; +import { Followings, UserProfiles, Users } from "@/models/index.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import { IsNull } from "typeorm"; export const meta = { tags: ["users"], @@ -78,7 +78,7 @@ export default define(meta, paramDef, async (ps, me) => { ps.userId != null ? { id: ps.userId } : { - usernameLower: ps.username!.toLowerCase(), + usernameLower: ps.username?.toLowerCase(), host: toPunyNullable(ps.host) ?? IsNull(), }, ); diff --git a/packages/backend/src/server/api/endpoints/users/gallery/posts.ts b/packages/backend/src/server/api/endpoints/users/gallery/posts.ts index e2edbee8..dad29f43 100644 --- a/packages/backend/src/server/api/endpoints/users/gallery/posts.ts +++ b/packages/backend/src/server/api/endpoints/users/gallery/posts.ts @@ -1,6 +1,6 @@ -import define from "@/server/api/define.js"; import { GalleryPosts } from "@/models/index.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["users", "gallery"], diff --git a/packages/backend/src/server/api/endpoints/users/get-frequently-replied-users.ts b/packages/backend/src/server/api/endpoints/users/get-frequently-replied-users.ts index 0694bd66..3a4caf98 100644 --- a/packages/backend/src/server/api/endpoints/users/get-frequently-replied-users.ts +++ b/packages/backend/src/server/api/endpoints/users/get-frequently-replied-users.ts @@ -1,9 +1,9 @@ -import { Not, In, IsNull } from "typeorm"; -import { maximum } from "@/prelude/array.js"; import { Notes, Users } from "@/models/index.js"; +import { maximum } from "@/prelude/array.js"; +import { getUser } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; +import { In, IsNull, Not } from "typeorm"; export const meta = { tags: ["users"], diff --git a/packages/backend/src/server/api/endpoints/users/groups/create.ts b/packages/backend/src/server/api/endpoints/users/groups/create.ts index 1cfb2230..797906e7 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/create.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/create.ts @@ -1,7 +1,7 @@ -import { UserGroups, UserGroupJoinings } from "@/models/index.js"; import { genId } from "@/misc/gen-id.js"; -import type { UserGroup } from "@/models/entities/user-group.js"; import type { UserGroupJoining } from "@/models/entities/user-group-joining.js"; +import type { UserGroup } from "@/models/entities/user-group.js"; +import { UserGroupJoinings, UserGroups } from "@/models/index.js"; import define from "@/server/api/define.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts b/packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts index a483ccd1..dc739da5 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts @@ -1,8 +1,8 @@ -import { UserGroupJoinings, UserGroupInvitations } from "@/models/index.js"; import { genId } from "@/misc/gen-id.js"; import type { UserGroupJoining } from "@/models/entities/user-group-joining.js"; -import { ApiError } from "@/server/api/error.js"; +import { UserGroupInvitations, UserGroupJoinings } from "@/models/index.js"; import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; export const meta = { tags: ["groups", "users"], diff --git a/packages/backend/src/server/api/endpoints/users/groups/invite.ts b/packages/backend/src/server/api/endpoints/users/groups/invite.ts index 8a1e6b31..bdc5f2a8 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/invite.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/invite.ts @@ -1,14 +1,14 @@ -import { - UserGroups, - UserGroupJoinings, - UserGroupInvitations, -} from "@/models/index.js"; import { genId } from "@/misc/gen-id.js"; import type { UserGroupInvitation } from "@/models/entities/user-group-invitation.js"; -import { createNotification } from "@/services/create-notification.js"; +import { + UserGroupInvitations, + UserGroupJoinings, + UserGroups, +} from "@/models/index.js"; import { getUser } from "@/server/api/common/getters.js"; -import { ApiError } from "@/server/api/error.js"; import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; +import { createNotification } from "@/services/create-notification.js"; export const meta = { tags: ["groups", "users"], diff --git a/packages/backend/src/server/api/endpoints/users/groups/joined.ts b/packages/backend/src/server/api/endpoints/users/groups/joined.ts index 5d50b5e3..aa9df7f9 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/joined.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/joined.ts @@ -1,6 +1,6 @@ -import { Not, In } from "typeorm"; -import { UserGroups, UserGroupJoinings } from "@/models/index.js"; +import { UserGroupJoinings, UserGroups } from "@/models/index.js"; import define from "@/server/api/define.js"; +import { In, Not } from "typeorm"; export const meta = { tags: ["groups", "account"], diff --git a/packages/backend/src/server/api/endpoints/users/groups/leave.ts b/packages/backend/src/server/api/endpoints/users/groups/leave.ts index 8165b1d9..e01b8e16 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/leave.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/leave.ts @@ -1,4 +1,4 @@ -import { UserGroups, UserGroupJoinings } from "@/models/index.js"; +import { UserGroupJoinings, UserGroups } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; diff --git a/packages/backend/src/server/api/endpoints/users/groups/pull.ts b/packages/backend/src/server/api/endpoints/users/groups/pull.ts index 5e7f91d7..a20ac733 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/pull.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/pull.ts @@ -1,7 +1,7 @@ -import { UserGroups, UserGroupJoinings } from "@/models/index.js"; +import { UserGroupJoinings, UserGroups } from "@/models/index.js"; +import { getUser } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; export const meta = { tags: ["groups", "users"], diff --git a/packages/backend/src/server/api/endpoints/users/groups/show.ts b/packages/backend/src/server/api/endpoints/users/groups/show.ts index 0cd5a923..20c7f0e8 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/show.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/show.ts @@ -1,4 +1,4 @@ -import { UserGroups, UserGroupJoinings } from "@/models/index.js"; +import { UserGroupJoinings, UserGroups } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; diff --git a/packages/backend/src/server/api/endpoints/users/groups/transfer.ts b/packages/backend/src/server/api/endpoints/users/groups/transfer.ts index b58ea57b..e742365c 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/transfer.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/transfer.ts @@ -1,7 +1,7 @@ -import { UserGroups, UserGroupJoinings } from "@/models/index.js"; +import { UserGroupJoinings, UserGroups } from "@/models/index.js"; +import { getUser } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; export const meta = { tags: ["groups", "users"], diff --git a/packages/backend/src/server/api/endpoints/users/lists/create.ts b/packages/backend/src/server/api/endpoints/users/lists/create.ts index c23e8f6f..d506b49a 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/create.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/create.ts @@ -1,6 +1,6 @@ -import { UserLists } from "@/models/index.js"; import { genId } from "@/misc/gen-id.js"; import type { UserList } from "@/models/entities/user-list.js"; +import { UserLists } from "@/models/index.js"; import define from "@/server/api/define.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/users/lists/pull.ts b/packages/backend/src/server/api/endpoints/users/lists/pull.ts index ffca5b20..69dc2727 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/pull.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/pull.ts @@ -1,8 +1,8 @@ -import { publishUserListStream } from "@/services/stream.js"; -import { UserLists, UserListJoinings, Users } from "@/models/index.js"; +import { UserListJoinings, UserLists, Users } from "@/models/index.js"; +import { getUser } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; +import { publishUserListStream } from "@/services/stream.js"; export const meta = { tags: ["lists", "users"], diff --git a/packages/backend/src/server/api/endpoints/users/lists/push.ts b/packages/backend/src/server/api/endpoints/users/lists/push.ts index 8dd4442d..2aa8c425 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/push.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/push.ts @@ -1,8 +1,8 @@ -import { pushUserToUserList } from "@/services/user-list/push.js"; -import { UserLists, UserListJoinings, Blockings } from "@/models/index.js"; +import { Blockings, UserListJoinings, UserLists } from "@/models/index.js"; +import { getUser } from "@/server/api/common/getters.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; +import { pushUserToUserList } from "@/services/user-list/push.js"; export const meta = { tags: ["lists", "users"], diff --git a/packages/backend/src/server/api/endpoints/users/notes.ts b/packages/backend/src/server/api/endpoints/users/notes.ts index 1485dfa6..805a68e0 100644 --- a/packages/backend/src/server/api/endpoints/users/notes.ts +++ b/packages/backend/src/server/api/endpoints/users/notes.ts @@ -1,12 +1,12 @@ -import { Brackets } from "typeorm"; import { Notes } from "@/models/index.js"; -import define from "@/server/api/define.js"; -import { ApiError } from "@/server/api/error.js"; +import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; +import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; +import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; import { getUser } from "@/server/api/common/getters.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; -import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; -import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; -import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; +import { Brackets } from "typeorm"; export const meta = { tags: ["users", "notes"], @@ -102,7 +102,7 @@ export default define(meta, paramDef, async (ps, me) => { query.andWhere( new Brackets((qb) => { for (const type of ps.fileType!) { - const i = ps.fileType!.indexOf(type); + const i = ps.fileType?.indexOf(type); qb.orWhere(`:type${i} = ANY(note.attachedFileTypes)`, { [`type${i}`]: type, }); diff --git a/packages/backend/src/server/api/endpoints/users/pages.ts b/packages/backend/src/server/api/endpoints/users/pages.ts index 1af50e78..774e4871 100644 --- a/packages/backend/src/server/api/endpoints/users/pages.ts +++ b/packages/backend/src/server/api/endpoints/users/pages.ts @@ -1,6 +1,6 @@ import { Pages } from "@/models/index.js"; -import define from "@/server/api/define.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["users", "pages"], diff --git a/packages/backend/src/server/api/endpoints/users/reactions.ts b/packages/backend/src/server/api/endpoints/users/reactions.ts index 483a7886..3a41c671 100644 --- a/packages/backend/src/server/api/endpoints/users/reactions.ts +++ b/packages/backend/src/server/api/endpoints/users/reactions.ts @@ -1,7 +1,7 @@ import { NoteReactions, UserProfiles } from "@/models/index.js"; -import define from "@/server/api/define.js"; -import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; +import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; +import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/users/recommendation.ts b/packages/backend/src/server/api/endpoints/users/recommendation.ts index 4ea0d618..6b65d92e 100644 --- a/packages/backend/src/server/api/endpoints/users/recommendation.ts +++ b/packages/backend/src/server/api/endpoints/users/recommendation.ts @@ -1,11 +1,11 @@ -import { Users, Followings } from "@/models/index.js"; -import define from "@/server/api/define.js"; -import { generateMutedUserQueryForUsers } from "@/server/api/common/generate-muted-user-query.js"; -import { - generateBlockedUserQuery, - generateBlockQueryForUsers, -} from "@/server/api/common/generate-block-query.js"; import { DAY } from "@/const.js"; +import { Followings, Users } from "@/models/index.js"; +import { + generateBlockQueryForUsers, + generateBlockedUserQuery, +} from "@/server/api/common/generate-block-query.js"; +import { generateMutedUserQueryForUsers } from "@/server/api/common/generate-muted-user-query.js"; +import define from "@/server/api/define.js"; export const meta = { tags: ["users"], diff --git a/packages/backend/src/server/api/endpoints/users/report-abuse.ts b/packages/backend/src/server/api/endpoints/users/report-abuse.ts index 7e9ba723..988dfa9d 100644 --- a/packages/backend/src/server/api/endpoints/users/report-abuse.ts +++ b/packages/backend/src/server/api/endpoints/users/report-abuse.ts @@ -1,14 +1,14 @@ +import { toHtml } from "@/mfm/to-html.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; +import { genId } from "@/misc/gen-id.js"; +import { AbuseUserReports, UserProfiles, Users } from "@/models/index.js"; +import { getUser } from "@/server/api/common/getters.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; +import { sendEmail } from "@/services/send-email.js"; +import { publishAdminStream } from "@/services/stream.js"; import * as mfm from "mfm-js"; import sanitizeHtml from "sanitize-html"; -import { publishAdminStream } from "@/services/stream.js"; -import { AbuseUserReports, UserProfiles, Users } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; -import { sendEmail } from "@/services/send-email.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; -import { getUser } from "@/server/api/common/getters.js"; -import { ApiError } from "@/server/api/error.js"; -import define from "@/server/api/define.js"; -import { toHtml } from "@/mfm/to-html.js"; export const meta = { tags: ["users"], diff --git a/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts b/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts index 517ef615..44a10ec6 100644 --- a/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts +++ b/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts @@ -1,8 +1,8 @@ -import { Brackets } from "typeorm"; -import { Followings, Users } from "@/models/index.js"; -import type { User } from "@/models/entities/user.js"; -import define from "@/server/api/define.js"; import { sqlLikeEscape } from "@/misc/sql-like-escape.js"; +import type { User } from "@/models/entities/user.js"; +import { Followings, Users } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { Brackets } from "typeorm"; export const meta = { tags: ["users"], diff --git a/packages/backend/src/server/api/endpoints/users/search.ts b/packages/backend/src/server/api/endpoints/users/search.ts index a15a0feb..0e797f6c 100644 --- a/packages/backend/src/server/api/endpoints/users/search.ts +++ b/packages/backend/src/server/api/endpoints/users/search.ts @@ -1,8 +1,8 @@ -import { Brackets } from "typeorm"; -import { UserProfiles, Users } from "@/models/index.js"; -import type { User } from "@/models/entities/user.js"; -import define from "@/server/api/define.js"; import { sqlLikeEscape } from "@/misc/sql-like-escape.js"; +import type { User } from "@/models/entities/user.js"; +import { UserProfiles, Users } from "@/models/index.js"; +import define from "@/server/api/define.js"; +import { Brackets } from "typeorm"; export const meta = { tags: ["users"], diff --git a/packages/backend/src/server/api/endpoints/users/show.ts b/packages/backend/src/server/api/endpoints/users/show.ts index 61812a01..436dd8d4 100644 --- a/packages/backend/src/server/api/endpoints/users/show.ts +++ b/packages/backend/src/server/api/endpoints/users/show.ts @@ -1,11 +1,11 @@ +import type { User } from "@/models/entities/user.js"; +import { Users } from "@/models/index.js"; +import { resolveUser } from "@/remote/resolve-user.js"; +import define from "@/server/api/define.js"; +import { ApiError } from "@/server/api/error.js"; +import { apiLogger } from "@/server/api/logger.js"; import type { FindOptionsWhere } from "typeorm"; import { In, IsNull } from "typeorm"; -import { resolveUser } from "@/remote/resolve-user.js"; -import { Users } from "@/models/index.js"; -import type { User } from "@/models/entities/user.js"; -import define from "@/server/api/define.js"; -import { apiLogger } from "@/server/api/logger.js"; -import { ApiError } from "@/server/api/error.js"; export const meta = { tags: ["users"], @@ -137,7 +137,7 @@ export default define(meta, paramDef, async (ps, me) => { ? ps.userId.startsWith("http") ? { uri: ps.userId } : { id: ps.userId } - : { usernameLower: ps.username!.toLowerCase(), host: IsNull() }; + : { usernameLower: ps.username?.toLowerCase(), host: IsNull() }; user = await Users.findOneBy(q); } diff --git a/packages/backend/src/server/api/index.ts b/packages/backend/src/server/api/index.ts index a5970d58..edce9be2 100644 --- a/packages/backend/src/server/api/index.ts +++ b/packages/backend/src/server/api/index.ts @@ -2,31 +2,31 @@ * API Server */ -import Koa from "koa"; -import Router from "@koa/router"; -import multer from "@koa/multer"; -import bodyParser from "koa-bodyparser"; +import config from "@/config/index.js"; +import { AccessTokens, Users } from "@/models/index.js"; import cors from "@koa/cors"; +import multer from "@koa/multer"; +import Router from "@koa/router"; +import Koa from "koa"; +import { koaBody } from "koa-body"; +import bodyParser from "koa-bodyparser"; +import handler from "./api-handler.js"; +import compatibility from "./compatibility.js"; +import endpoints from "./endpoints.js"; import { apiMastodonCompatible, getClient, } from "./mastodon/ApiMastodonCompatibleService.js"; -import { AccessTokens, Users } from "@/models/index.js"; -import config from "@/config/index.js"; -import endpoints from "./endpoints.js"; -import compatibility from "./compatibility.js"; -import handler from "./api-handler.js"; -import signup from "./private/signup.js"; +import { convertAttachment } from "./mastodon/converters.js"; import signin from "./private/signin.js"; import signupPending from "./private/signup-pending.js"; +import signup from "./private/signup.js"; import verifyEmail from "./private/verify-email.js"; -import { koaBody } from "koa-body"; -import { convertAttachment } from "./mastodon/converters.js"; // TODO?: should we avoid importing things from built directory? import { - convertId, IdConvertType as IdType, + convertId, } from "native-utils/built/index.js"; // re-export native rust id conversion (function and enum) diff --git a/packages/backend/src/server/api/limiter.ts b/packages/backend/src/server/api/limiter.ts index f03f8754..edaed8f2 100644 --- a/packages/backend/src/server/api/limiter.ts +++ b/packages/backend/src/server/api/limiter.ts @@ -1,8 +1,8 @@ -import Limiter from "ratelimiter"; -import Logger from "@/services/logger.js"; import { redisClient } from "@/db/redis.js"; -import type { IEndpointMeta } from "./endpoints.js"; import { convertMilliseconds } from "@/misc/convert-milliseconds.js"; +import Logger from "@/services/logger.js"; +import Limiter from "ratelimiter"; +import type { IEndpointMeta } from "./endpoints.js"; const logger = new Logger("limiter"); diff --git a/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts b/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts index e029bc60..c58709ea 100644 --- a/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts +++ b/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts @@ -1,21 +1,21 @@ +import { Users } from "@/models/index.js"; +import { IdType, convertId } from "@/server/api/index.js"; import Router from "@koa/router"; import megalodon, { MegalodonInterface } from "megalodon"; -import { apiAuthMastodon } from "./endpoints/auth.js"; -import { apiAccountMastodon } from "./endpoints/account.js"; -import { apiStatusMastodon } from "./endpoints/status.js"; -import { apiFilterMastodon } from "./endpoints/filter.js"; -import { apiTimelineMastodon } from "./endpoints/timeline.js"; -import { apiNotificationsMastodon } from "./endpoints/notifications.js"; -import { apiSearchMastodon } from "./endpoints/search.js"; -import { getInstance } from "./endpoints/meta.js"; +import { IsNull } from "typeorm"; import { convertAccount, convertAnnouncement, convertFilter, } from "./converters.js"; -import { convertId, IdType } from "@/server/api/index.js"; -import { Users } from "@/models/index.js"; -import { IsNull } from "typeorm"; +import { apiAccountMastodon } from "./endpoints/account.js"; +import { apiAuthMastodon } from "./endpoints/auth.js"; +import { apiFilterMastodon } from "./endpoints/filter.js"; +import { getInstance } from "./endpoints/meta.js"; +import { apiNotificationsMastodon } from "./endpoints/notifications.js"; +import { apiSearchMastodon } from "./endpoints/search.js"; +import { apiStatusMastodon } from "./endpoints/status.js"; +import { apiTimelineMastodon } from "./endpoints/timeline.js"; export function getClient( BASE_URL: string, diff --git a/packages/backend/src/server/api/mastodon/converters.ts b/packages/backend/src/server/api/mastodon/converters.ts index 30506d9c..03217d80 100644 --- a/packages/backend/src/server/api/mastodon/converters.ts +++ b/packages/backend/src/server/api/mastodon/converters.ts @@ -1,5 +1,5 @@ +import { IdType, convertId } from "@/server/api/index.js"; import { Entity } from "megalodon"; -import { convertId, IdType } from "@/server/api/index.js"; function simpleConvert(data: any) { // copy the object to bypass weird pass by reference bugs diff --git a/packages/backend/src/server/api/mastodon/endpoints/account.ts b/packages/backend/src/server/api/mastodon/endpoints/account.ts index 76c3af37..9d9c2c54 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/account.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/account.ts @@ -1,7 +1,6 @@ +import { IdType, convertId } from "@/server/api/index.js"; import Router from "@koa/router"; import { getClient } from "../ApiMastodonCompatibleService.js"; -import { argsToBools, convertTimelinesArgsId, limitToInt } from "./timeline.js"; -import { convertId, IdType } from "@/server/api/index.js"; import { convertAccount, convertFeaturedTag, @@ -9,6 +8,7 @@ import { convertRelationship, convertStatus, } from "../converters.js"; +import { argsToBools, convertTimelinesArgsId, limitToInt } from "./timeline.js"; const relationshipModel = { id: "", @@ -34,7 +34,7 @@ export function apiAccountMastodon(router: Router): void { const client = getClient(BASE_URL, accessTokens); try { const data = await client.verifyAccountCredentials(); - let acct = data.data; + const acct = data.data; acct.id = convertId(acct.id, IdType.MastodonId); acct.display_name = acct.display_name || acct.username; acct.url = `${BASE_URL}/@${acct.url}`; @@ -109,7 +109,7 @@ export function apiAccountMastodon(router: Router): void { return; } - let reqIds = []; + const reqIds = []; for (let i = 0; i < ids.length; i++) { reqIds.push(convertId(ids[i], IdType.FirefishId)); } @@ -120,7 +120,7 @@ export function apiAccountMastodon(router: Router): void { ); } catch (e: any) { console.error(e); - let data = e.response.data; + const data = e.response.data; data.users = users; console.error(data); ctx.status = 401; @@ -250,7 +250,7 @@ export function apiAccountMastodon(router: Router): void { const data = await client.followAccount( convertId(ctx.params.id, IdType.FirefishId), ); - let acct = convertRelationship(data.data); + const acct = convertRelationship(data.data); acct.following = true; ctx.body = acct; } catch (e: any) { @@ -271,7 +271,7 @@ export function apiAccountMastodon(router: Router): void { const data = await client.unfollowAccount( convertId(ctx.params.id, IdType.FirefishId), ); - let acct = convertRelationship(data.data); + const acct = convertRelationship(data.data); acct.following = false; ctx.body = acct; } catch (e: any) { diff --git a/packages/backend/src/server/api/mastodon/endpoints/filter.ts b/packages/backend/src/server/api/mastodon/endpoints/filter.ts index 6524fd2f..a3a6c33c 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/filter.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/filter.ts @@ -1,6 +1,6 @@ +import { IdType, convertId } from "@/server/api/index.js"; import Router from "@koa/router"; import { getClient } from "../ApiMastodonCompatibleService.js"; -import { IdType, convertId } from "@/server/api/index.js"; import { convertFilter } from "../converters.js"; export function apiFilterMastodon(router: Router): void { diff --git a/packages/backend/src/server/api/mastodon/endpoints/meta.ts b/packages/backend/src/server/api/mastodon/endpoints/meta.ts index c458798d..52e43ff8 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/meta.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/meta.ts @@ -1,7 +1,7 @@ -import { Entity } from "megalodon"; import config from "@/config/index.js"; +import { FILE_TYPE_BROWSERSAFE, MAX_NOTE_TEXT_LENGTH } from "@/const.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; -import { MAX_NOTE_TEXT_LENGTH, FILE_TYPE_BROWSERSAFE } from "@/const.js"; +import { Entity } from "megalodon"; export async function getInstance( response: Entity.Instance, diff --git a/packages/backend/src/server/api/mastodon/endpoints/notifications.ts b/packages/backend/src/server/api/mastodon/endpoints/notifications.ts index 9628eccd..da590046 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/notifications.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/notifications.ts @@ -1,8 +1,8 @@ +import { IdType, convertId } from "@/server/api/index.js"; import Router from "@koa/router"; -import { convertId, IdType } from "@/server/api/index.js"; import { getClient } from "../ApiMastodonCompatibleService.js"; -import { convertTimelinesArgsId } from "./timeline.js"; import { convertNotification } from "../converters.js"; +import { convertTimelinesArgsId } from "./timeline.js"; function toLimitToInt(q: any) { if (q.limit) if (typeof q.limit === "string") q.limit = parseInt(q.limit, 10); return q; diff --git a/packages/backend/src/server/api/mastodon/endpoints/search.ts b/packages/backend/src/server/api/mastodon/endpoints/search.ts index c9bbab0a..d6ef388b 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/search.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/search.ts @@ -1,9 +1,9 @@ import Router from "@koa/router"; -import { getClient } from "../ApiMastodonCompatibleService.js"; import axios from "axios"; import { Converter } from "megalodon"; -import { convertTimelinesArgsId, limitToInt } from "./timeline.js"; +import { getClient } from "../ApiMastodonCompatibleService.js"; import { convertAccount, convertStatus } from "../converters.js"; +import { convertTimelinesArgsId, limitToInt } from "./timeline.js"; export function apiSearchMastodon(router: Router): void { router.get("/v1/search", async (ctx) => { diff --git a/packages/backend/src/server/api/mastodon/endpoints/status.ts b/packages/backend/src/server/api/mastodon/endpoints/status.ts index ac1cbe60..a34a1570 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/status.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/status.ts @@ -1,17 +1,17 @@ -import Router from "@koa/router"; -import { getClient } from "../ApiMastodonCompatibleService.js"; -import { emojiRegexAtStartToEnd } from "@/misc/emoji-regex.js"; import querystring from "node:querystring"; +import { emojiRegexAtStartToEnd } from "@/misc/emoji-regex.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; +import { IdType, convertId } from "@/server/api/index.js"; +import Router from "@koa/router"; import qs from "qs"; -import { convertTimelinesArgsId, limitToInt } from "./timeline.js"; -import { convertId, IdType } from "@/server/api/index.js"; +import { getClient } from "../ApiMastodonCompatibleService.js"; import { convertAccount, convertAttachment, convertPoll, convertStatus, } from "../converters.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { convertTimelinesArgsId, limitToInt } from "./timeline.js"; function normalizeQuery(data: any) { const str = querystring.stringify(data); @@ -80,12 +80,12 @@ export function apiStatusMastodon(router: Router): void { body.poll.multiple != null && typeof body.poll.multiple === "string" ) - body.poll.multiple = body.poll.multiple == "true"; + body.poll.multiple = body.poll.multiple === "true"; if ( body.poll.hide_totals != null && typeof body.poll.hide_totals === "string" ) - body.poll.hide_totals = body.poll.hide_totals == "true"; + body.poll.hide_totals = body.poll.hide_totals === "true"; } const data = await client.postStatus(text, body); @@ -107,7 +107,7 @@ export function apiStatusMastodon(router: Router): void { ctx.body = convertStatus(data.data); } catch (e: any) { console.error(e); - ctx.status = ctx.status == 404 ? 404 : 401; + ctx.status = ctx.status === 404 ? 404 : 401; ctx.body = e.response.data; } }); diff --git a/packages/backend/src/server/api/mastodon/endpoints/timeline.ts b/packages/backend/src/server/api/mastodon/endpoints/timeline.ts index 05741c4c..747afc08 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/timeline.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/timeline.ts @@ -1,16 +1,16 @@ +import { ParsedUrlQuery } from "querystring"; +import { IdType, convertId } from "@/server/api/index.js"; import Router from "@koa/router"; import { getClient } from "../ApiMastodonCompatibleService.js"; -import { ParsedUrlQuery } from "querystring"; import { convertAccount, convertConversation, convertList, convertStatus, } from "../converters.js"; -import { convertId, IdType } from "@/server/api/index.js"; export function limitToInt(q: ParsedUrlQuery) { - let object: any = q; + const object: any = q; if (q.limit) if (typeof q.limit === "string") object.limit = parseInt(q.limit, 10); if (q.offset) @@ -27,7 +27,7 @@ export function argsToBools(q: ParsedUrlQuery) { // - https://docs.joinmastodon.org/methods/accounts/#statuses // - https://docs.joinmastodon.org/methods/timelines/#public // - https://docs.joinmastodon.org/methods/timelines/#tag - let object: any = q; + const object: any = q; if (q.only_media) if (typeof q.only_media === "string") object.only_media = toBoolean(q.only_media); diff --git a/packages/backend/src/server/api/openapi/gen-spec.ts b/packages/backend/src/server/api/openapi/gen-spec.ts index 25f84e5b..d05b7a56 100644 --- a/packages/backend/src/server/api/openapi/gen-spec.ts +++ b/packages/backend/src/server/api/openapi/gen-spec.ts @@ -1,7 +1,7 @@ -import endpoints from "@/server/api/endpoints.js"; import config from "@/config/index.js"; +import endpoints from "@/server/api/endpoints.js"; import { errors as basicErrors } from "./errors.js"; -import { schemas, convertSchemaToOpenApiSchema } from "./schemas.js"; +import { convertSchemaToOpenApiSchema, schemas } from "./schemas.js"; export function genOpenapiSpec() { const spec = { @@ -61,10 +61,11 @@ export function genOpenapiSpec() { ? convertSchemaToOpenApiSchema(endpoint.meta.res) : {}; - let desc = - (endpoint.meta.description + let desc = `${ + endpoint.meta.description ? endpoint.meta.description - : "No description provided.") + "\n\n"; + : "No description provided." + }\n\n`; desc += `**Credential required**: *${ endpoint.meta.requireCredential ? "Yes" : "No" }*`; diff --git a/packages/backend/src/server/api/private/signin.ts b/packages/backend/src/server/api/private/signin.ts index 3e70d80f..8aebf157 100644 --- a/packages/backend/src/server/api/private/signin.ts +++ b/packages/backend/src/server/api/private/signin.ts @@ -1,35 +1,35 @@ -import type Koa from "koa"; -import * as OTPAuth from "otpauth"; -import signin from "@/server/api/common/signin.js"; +import { randomBytes } from "node:crypto"; import config from "@/config/index.js"; -import { - Users, - Signins, - UserProfiles, - UserSecurityKeys, - AttestationChallenges, -} from "@/models/index.js"; -import type { ILocalUser } from "@/models/entities/user.js"; import { genId } from "@/misc/gen-id.js"; +import { getIpHash } from "@/misc/get-ip-hash.js"; import { comparePassword, hashPassword, isOldAlgorithm, } from "@/misc/password.js"; -import { verifyLogin, hash } from "@/server/api/2fa.js"; -import { randomBytes } from "node:crypto"; -import { IsNull } from "typeorm"; +import type { ILocalUser } from "@/models/entities/user.js"; +import { + AttestationChallenges, + Signins, + UserProfiles, + UserSecurityKeys, + Users, +} from "@/models/index.js"; +import { hash, verifyLogin } from "@/server/api/2fa.js"; +import signin from "@/server/api/common/signin.js"; import { limiter } from "@/server/api/limiter.js"; -import { getIpHash } from "@/misc/get-ip-hash.js"; +import type Koa from "koa"; +import * as OTPAuth from "otpauth"; +import { IsNull } from "typeorm"; export default async (ctx: Koa.Context) => { ctx.set("Access-Control-Allow-Origin", config.url); ctx.set("Access-Control-Allow-Credentials", "true"); const body = ctx.request.body as any; - const username = body["username"]; - const password = body["password"]; - const token = body["token"]; + const username = body.username; + const password = body.password; + const token = body.token; function error(status: number, error: { id: string }) { ctx.status = status; diff --git a/packages/backend/src/server/api/private/signup-pending.ts b/packages/backend/src/server/api/private/signup-pending.ts index b92fb90b..1bb23ecc 100644 --- a/packages/backend/src/server/api/private/signup-pending.ts +++ b/packages/backend/src/server/api/private/signup-pending.ts @@ -1,12 +1,12 @@ -import type Koa from "koa"; import { UserPendings, UserProfiles } from "@/models/index.js"; -import { signup } from "@/server/api/common/signup.js"; import signin from "@/server/api/common/signin.js"; +import { signup } from "@/server/api/common/signup.js"; +import type Koa from "koa"; export default async (ctx: Koa.Context) => { const body = ctx.request.body; - const code = body["code"]; + const code = body.code; try { const pendingUser = await UserPendings.findOneByOrFail({ code }); diff --git a/packages/backend/src/server/api/private/signup.ts b/packages/backend/src/server/api/private/signup.ts index d60e5a19..0c40050f 100644 --- a/packages/backend/src/server/api/private/signup.ts +++ b/packages/backend/src/server/api/private/signup.ts @@ -1,14 +1,14 @@ +import config from "@/config/index.js"; +import { verifyHcaptcha, verifyRecaptcha } from "@/misc/captcha.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; +import { genId } from "@/misc/gen-id.js"; +import { hashPassword } from "@/misc/password.js"; +import { RegistrationTickets, UserPendings, Users } from "@/models/index.js"; +import { signup } from "@/server/api/common/signup.js"; +import { sendEmail } from "@/services/send-email.js"; +import { validateEmailForAccount } from "@/services/validate-email-for-account.js"; import type Koa from "koa"; import rndstr from "rndstr"; -import { fetchMeta } from "@/misc/fetch-meta.js"; -import { verifyHcaptcha, verifyRecaptcha } from "@/misc/captcha.js"; -import { Users, RegistrationTickets, UserPendings } from "@/models/index.js"; -import { signup } from "@/server/api/common/signup.js"; -import config from "@/config/index.js"; -import { sendEmail } from "@/services/send-email.js"; -import { genId } from "@/misc/gen-id.js"; -import { validateEmailForAccount } from "@/services/validate-email-for-account.js"; -import { hashPassword } from "@/misc/password.js"; export default async (ctx: Koa.Context) => { const body = ctx.request.body; @@ -37,12 +37,12 @@ export default async (ctx: Koa.Context) => { } } - const username = body["username"]; - const password = body["password"]; + const username = body.username; + const password = body.password; const host: string | null = - process.env.NODE_ENV === "test" ? body["host"] || null : null; - const invitationCode = body["invitationCode"]; - const emailAddress = body["emailAddress"]; + process.env.NODE_ENV === "test" ? body.host || null : null; + const invitationCode = body.invitationCode; + const emailAddress = body.emailAddress; if (config.reservedUsernames?.includes(username.toLowerCase())) { ctx.status = 400; diff --git a/packages/backend/src/server/api/private/verify-email.ts b/packages/backend/src/server/api/private/verify-email.ts index e6c8295d..a5e8b9c1 100644 --- a/packages/backend/src/server/api/private/verify-email.ts +++ b/packages/backend/src/server/api/private/verify-email.ts @@ -1,11 +1,11 @@ -import type Koa from "koa"; -import { Users, UserProfiles } from "@/models/index.js"; +import { UserProfiles, Users } from "@/models/index.js"; import { publishMainStream } from "@/services/stream.js"; +import type Koa from "koa"; export default async (ctx: Koa.Context) => { const body = ctx.request.body; - const code = body["code"]; + const code = body.code; const profile = await UserProfiles.findOneByOrFail({ emailVerifyCode: code }); diff --git a/packages/backend/src/server/api/stream/channel.ts b/packages/backend/src/server/api/stream/channel.ts index fc8e0ce3..67681b99 100644 --- a/packages/backend/src/server/api/stream/channel.ts +++ b/packages/backend/src/server/api/stream/channel.ts @@ -1,8 +1,8 @@ -import type Connection from "."; +import { IdentifiableError } from "@/misc/identifiable-error.js"; +import type { Packed } from "@/misc/schema.js"; import type { Note } from "@/models/entities/note.js"; import { Notes } from "@/models/index.js"; -import type { Packed } from "@/misc/schema.js"; -import { IdentifiableError } from "@/misc/identifiable-error.js"; +import type Connection from "."; /** * Stream channel diff --git a/packages/backend/src/server/api/stream/channels/admin.ts b/packages/backend/src/server/api/stream/channels/admin.ts index 59ae2282..a1b8b7fc 100644 --- a/packages/backend/src/server/api/stream/channels/admin.ts +++ b/packages/backend/src/server/api/stream/channels/admin.ts @@ -7,7 +7,7 @@ export default class extends Channel { public async init(params: any) { // Subscribe admin stream - this.subscriber.on(`adminStream:${this.user!.id}`, (data) => { + this.subscriber.on(`adminStream:${this.user?.id}`, (data) => { this.send(data); }); } diff --git a/packages/backend/src/server/api/stream/channels/antenna.ts b/packages/backend/src/server/api/stream/channels/antenna.ts index ec5a8b17..6aae49d1 100644 --- a/packages/backend/src/server/api/stream/channels/antenna.ts +++ b/packages/backend/src/server/api/stream/channels/antenna.ts @@ -1,8 +1,8 @@ -import Channel from "../channel.js"; -import { Notes } from "@/models/index.js"; -import { isUserRelated } from "@/misc/is-user-related.js"; -import type { StreamMessages } from "../types.js"; import { IdentifiableError } from "@/misc/identifiable-error.js"; +import { isUserRelated } from "@/misc/is-user-related.js"; +import { Notes } from "@/models/index.js"; +import Channel from "../channel.js"; +import type { StreamMessages } from "../types.js"; export default class extends Channel { public readonly chName = "antenna"; diff --git a/packages/backend/src/server/api/stream/channels/channel.ts b/packages/backend/src/server/api/stream/channels/channel.ts index 2ff4e082..b668544b 100644 --- a/packages/backend/src/server/api/stream/channels/channel.ts +++ b/packages/backend/src/server/api/stream/channels/channel.ts @@ -1,9 +1,9 @@ -import Channel from "../channel.js"; -import { Users } from "@/models/index.js"; import { isUserRelated } from "@/misc/is-user-related.js"; -import type { User } from "@/models/entities/user.js"; -import type { StreamMessages } from "../types.js"; import type { Packed } from "@/misc/schema.js"; +import type { User } from "@/models/entities/user.js"; +import { Users } from "@/models/index.js"; +import Channel from "../channel.js"; +import type { StreamMessages } from "../types.js"; export default class extends Channel { public readonly chName = "channel"; diff --git a/packages/backend/src/server/api/stream/channels/drive.ts b/packages/backend/src/server/api/stream/channels/drive.ts index 275730ea..b6fb7c4b 100644 --- a/packages/backend/src/server/api/stream/channels/drive.ts +++ b/packages/backend/src/server/api/stream/channels/drive.ts @@ -7,7 +7,7 @@ export default class extends Channel { public async init(params: any) { // Subscribe drive stream - this.subscriber.on(`driveStream:${this.user!.id}`, (data) => { + this.subscriber.on(`driveStream:${this.user?.id}`, (data) => { this.send(data); }); } diff --git a/packages/backend/src/server/api/stream/channels/global-timeline.ts b/packages/backend/src/server/api/stream/channels/global-timeline.ts index e750ac92..183c03e3 100644 --- a/packages/backend/src/server/api/stream/channels/global-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/global-timeline.ts @@ -1,9 +1,9 @@ -import Channel from "../channel.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; import { getWordHardMute } from "@/misc/check-word-mute.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; import { isInstanceMuted } from "@/misc/is-instance-muted.js"; import { isUserRelated } from "@/misc/is-user-related.js"; import type { Packed } from "@/misc/schema.js"; +import Channel from "../channel.js"; export default class extends Channel { public readonly chName = "globalTimeline"; @@ -38,8 +38,8 @@ export default class extends Channel { const reply = note.reply; // 「チャンネル接続主への返信」でもなければ、「チャンネル接続主が行った返信」でもなければ、「投稿者の投稿者自身への返信」でもない場合 if ( - reply.userId !== this.user!.id && - note.userId !== this.user!.id && + reply.userId !== this.user?.id && + note.userId !== this.user?.id && reply.userId !== note.userId ) return; diff --git a/packages/backend/src/server/api/stream/channels/hashtag.ts b/packages/backend/src/server/api/stream/channels/hashtag.ts index 011bb088..d44fef11 100644 --- a/packages/backend/src/server/api/stream/channels/hashtag.ts +++ b/packages/backend/src/server/api/stream/channels/hashtag.ts @@ -1,7 +1,7 @@ -import Channel from "../channel.js"; -import { normalizeForSearch } from "@/misc/normalize-for-search.js"; import { isUserRelated } from "@/misc/is-user-related.js"; +import { normalizeForSearch } from "@/misc/normalize-for-search.js"; import type { Packed } from "@/misc/schema.js"; +import Channel from "../channel.js"; export default class extends Channel { public readonly chName = "hashtag"; diff --git a/packages/backend/src/server/api/stream/channels/home-timeline.ts b/packages/backend/src/server/api/stream/channels/home-timeline.ts index 5aafe865..c702ccd0 100644 --- a/packages/backend/src/server/api/stream/channels/home-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/home-timeline.ts @@ -1,8 +1,8 @@ -import Channel from "../channel.js"; import { getWordHardMute } from "@/misc/check-word-mute.js"; -import { isUserRelated } from "@/misc/is-user-related.js"; import { isInstanceMuted } from "@/misc/is-instance-muted.js"; +import { isUserRelated } from "@/misc/is-user-related.js"; import type { Packed } from "@/misc/schema.js"; +import Channel from "../channel.js"; export default class extends Channel { public readonly chName = "homeTimeline"; @@ -28,7 +28,7 @@ export default class extends Channel { if (!this.followingChannels.has(note.channelId)) return; } else { // その投稿のユーザーをフォローしていなかったら弾く - if (this.user!.id !== note.userId && !this.following.has(note.userId)) + if (this.user?.id !== note.userId && !this.following.has(note.userId)) return; } @@ -46,8 +46,8 @@ export default class extends Channel { const reply = note.reply; // 「チャンネル接続主への返信」でもなければ、「チャンネル接続主が行った返信」でもなければ、「投稿者の投稿者自身への返信」でもない場合 if ( - reply.userId !== this.user!.id && - note.userId !== this.user!.id && + reply.userId !== this.user?.id && + note.userId !== this.user?.id && reply.userId !== note.userId ) return; diff --git a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts index 2ec53a3f..dff4d5fc 100644 --- a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts @@ -1,9 +1,9 @@ -import Channel from "../channel.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; import { getWordHardMute } from "@/misc/check-word-mute.js"; -import { isUserRelated } from "@/misc/is-user-related.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; import { isInstanceMuted } from "@/misc/is-instance-muted.js"; +import { isUserRelated } from "@/misc/is-user-related.js"; import type { Packed } from "@/misc/schema.js"; +import Channel from "../channel.js"; export default class extends Channel { public readonly chName = "hybridTimeline"; @@ -20,8 +20,8 @@ export default class extends Channel { const meta = await fetchMeta(); if ( meta.disableLocalTimeline && - !this.user!.isAdmin && - !this.user!.isModerator + !this.user?.isAdmin && + !this.user?.isModerator ) return; @@ -39,7 +39,7 @@ export default class extends Channel { // フォローしているチャンネルの投稿 の場合だけ if ( !( - (note.channelId == null && this.user!.id === note.userId) || + (note.channelId == null && this.user?.id === note.userId) || (note.channelId == null && this.following.has(note.userId)) || (note.channelId == null && note.user.host == null && @@ -63,8 +63,8 @@ export default class extends Channel { const reply = note.reply; // 「チャンネル接続主への返信」でもなければ、「チャンネル接続主が行った返信」でもなければ、「投稿者の投稿者自身への返信」でもない場合 if ( - reply.userId !== this.user!.id && - note.userId !== this.user!.id && + reply.userId !== this.user?.id && + note.userId !== this.user?.id && reply.userId !== note.userId ) return; diff --git a/packages/backend/src/server/api/stream/channels/index.ts b/packages/backend/src/server/api/stream/channels/index.ts index d1127be4..60d703e5 100644 --- a/packages/backend/src/server/api/stream/channels/index.ts +++ b/packages/backend/src/server/api/stream/channels/index.ts @@ -1,19 +1,19 @@ -import main from "./main.js"; -import homeTimeline from "./home-timeline.js"; -import localTimeline from "./local-timeline.js"; -import hybridTimeline from "./hybrid-timeline.js"; -import recommendedTimeline from "./recommended-timeline.js"; -import globalTimeline from "./global-timeline.js"; -import serverStats from "./server-stats.js"; -import queueStats from "./queue-stats.js"; -import userList from "./user-list.js"; -import antenna from "./antenna.js"; -import messaging from "./messaging.js"; -import messagingIndex from "./messaging-index.js"; -import drive from "./drive.js"; -import hashtag from "./hashtag.js"; -import channel from "./channel.js"; import admin from "./admin.js"; +import antenna from "./antenna.js"; +import channel from "./channel.js"; +import drive from "./drive.js"; +import globalTimeline from "./global-timeline.js"; +import hashtag from "./hashtag.js"; +import homeTimeline from "./home-timeline.js"; +import hybridTimeline from "./hybrid-timeline.js"; +import localTimeline from "./local-timeline.js"; +import main from "./main.js"; +import messagingIndex from "./messaging-index.js"; +import messaging from "./messaging.js"; +import queueStats from "./queue-stats.js"; +import recommendedTimeline from "./recommended-timeline.js"; +import serverStats from "./server-stats.js"; +import userList from "./user-list.js"; export default { main, diff --git a/packages/backend/src/server/api/stream/channels/local-timeline.ts b/packages/backend/src/server/api/stream/channels/local-timeline.ts index 40e38c24..989be256 100644 --- a/packages/backend/src/server/api/stream/channels/local-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/local-timeline.ts @@ -1,8 +1,8 @@ -import Channel from "../channel.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; import { getWordHardMute } from "@/misc/check-word-mute.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; import { isUserRelated } from "@/misc/is-user-related.js"; import type { Packed } from "@/misc/schema.js"; +import Channel from "../channel.js"; export default class extends Channel { public readonly chName = "localTimeline"; @@ -39,8 +39,8 @@ export default class extends Channel { const reply = note.reply; // 「チャンネル接続主への返信」でもなければ、「チャンネル接続主が行った返信」でもなければ、「投稿者の投稿者自身への返信」でもない場合 if ( - reply.userId !== this.user!.id && - note.userId !== this.user!.id && + reply.userId !== this.user?.id && + note.userId !== this.user?.id && reply.userId !== note.userId ) return; diff --git a/packages/backend/src/server/api/stream/channels/main.ts b/packages/backend/src/server/api/stream/channels/main.ts index b8c72442..93dee28e 100644 --- a/packages/backend/src/server/api/stream/channels/main.ts +++ b/packages/backend/src/server/api/stream/channels/main.ts @@ -1,8 +1,8 @@ -import Channel from "../channel.js"; import { isInstanceMuted, isUserFromMutedInstance, } from "@/misc/is-instance-muted.js"; +import Channel from "../channel.js"; export default class extends Channel { public readonly chName = "main"; @@ -11,7 +11,7 @@ export default class extends Channel { public async init(params: any) { // Subscribe main stream channel - this.subscriber.on(`mainStream:${this.user!.id}`, async (data) => { + this.subscriber.on(`mainStream:${this.user?.id}`, async (data) => { switch (data.type) { case "notification": { // Ignore notifications from instances the user has muted diff --git a/packages/backend/src/server/api/stream/channels/messaging-index.ts b/packages/backend/src/server/api/stream/channels/messaging-index.ts index 8165172d..fcb78531 100644 --- a/packages/backend/src/server/api/stream/channels/messaging-index.ts +++ b/packages/backend/src/server/api/stream/channels/messaging-index.ts @@ -7,7 +7,7 @@ export default class extends Channel { public async init(params: any) { // Subscribe messaging index stream - this.subscriber.on(`messagingIndexStream:${this.user!.id}`, (data) => { + this.subscriber.on(`messagingIndexStream:${this.user?.id}`, (data) => { this.send(data); }); } diff --git a/packages/backend/src/server/api/stream/channels/messaging.ts b/packages/backend/src/server/api/stream/channels/messaging.ts index a650db8b..f9e5afac 100644 --- a/packages/backend/src/server/api/stream/channels/messaging.ts +++ b/packages/backend/src/server/api/stream/channels/messaging.ts @@ -1,12 +1,12 @@ +import type { UserGroup } from "@/models/entities/user-group.js"; +import type { ILocalUser, IRemoteUser, User } from "@/models/entities/user.js"; +import { MessagingMessages, UserGroupJoinings, Users } from "@/models/index.js"; import { - readUserMessagingMessage, - readGroupMessagingMessage, deliverReadActivity, + readGroupMessagingMessage, + readUserMessagingMessage, } from "@/server/api/common/read-messaging-message.js"; import Channel from "../channel.js"; -import { UserGroupJoinings, Users, MessagingMessages } from "@/models/index.js"; -import type { User, ILocalUser, IRemoteUser } from "@/models/entities/user.js"; -import type { UserGroup } from "@/models/entities/user-group.js"; import type { StreamMessages } from "../types.js"; export default class extends Channel { @@ -40,7 +40,7 @@ export default class extends Channel { // Check joining if (this.groupId) { const joining = await UserGroupJoinings.findOneBy({ - userId: this.user!.id, + userId: this.user?.id, userGroupId: this.groupId, }); @@ -52,7 +52,7 @@ export default class extends Channel { this.emitTypersIntervalId = setInterval(this.emitTypers, 5000); this.subCh = this.otherpartyId - ? `messagingStream:${this.user!.id}-${this.otherpartyId}` + ? `messagingStream:${this.user?.id}-${this.otherpartyId}` : `messagingStream:${this.groupId}`; // Subscribe messaging stream @@ -80,7 +80,7 @@ export default class extends Channel { switch (type) { case "read": if (this.otherpartyId) { - readUserMessagingMessage(this.user!.id, this.otherpartyId, [body.id]); + readUserMessagingMessage(this.user?.id, this.otherpartyId, [body.id]); // リモートユーザーからのメッセージだったら既読配信 if ( @@ -97,7 +97,7 @@ export default class extends Channel { }); } } else if (this.groupId) { - readGroupMessagingMessage(this.user!.id, this.groupId, [body.id]); + readGroupMessagingMessage(this.user?.id, this.groupId, [body.id]); } break; } diff --git a/packages/backend/src/server/api/stream/channels/recommended-timeline.ts b/packages/backend/src/server/api/stream/channels/recommended-timeline.ts index bbbc4e7a..65accf05 100644 --- a/packages/backend/src/server/api/stream/channels/recommended-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/recommended-timeline.ts @@ -1,9 +1,9 @@ -import Channel from "../channel.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; import { getWordHardMute } from "@/misc/check-word-mute.js"; -import { isUserRelated } from "@/misc/is-user-related.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; import { isInstanceMuted } from "@/misc/is-instance-muted.js"; +import { isUserRelated } from "@/misc/is-user-related.js"; import type { Packed } from "@/misc/schema.js"; +import Channel from "../channel.js"; export default class extends Channel { public readonly chName = "recommendedTimeline"; @@ -20,8 +20,8 @@ export default class extends Channel { const meta = await fetchMeta(); if ( meta.disableRecommendedTimeline && - !this.user!.isAdmin && - !this.user!.isModerator + !this.user?.isAdmin && + !this.user?.isModerator ) return; @@ -61,8 +61,8 @@ export default class extends Channel { const reply = note.reply; // 「チャンネル接続主への返信」でもなければ、「チャンネル接続主が行った返信」でもなければ、「投稿者の投稿者自身への返信」でもない場合 if ( - reply.userId !== this.user!.id && - note.userId !== this.user!.id && + reply.userId !== this.user?.id && + note.userId !== this.user?.id && reply.userId !== note.userId ) return; diff --git a/packages/backend/src/server/api/stream/channels/user-list.ts b/packages/backend/src/server/api/stream/channels/user-list.ts index d1403195..6c0e6b39 100644 --- a/packages/backend/src/server/api/stream/channels/user-list.ts +++ b/packages/backend/src/server/api/stream/channels/user-list.ts @@ -1,8 +1,8 @@ -import Channel from "../channel.js"; -import { UserListJoinings, UserLists } from "@/models/index.js"; -import type { User } from "@/models/entities/user.js"; import { isUserRelated } from "@/misc/is-user-related.js"; import type { Packed } from "@/misc/schema.js"; +import type { User } from "@/models/entities/user.js"; +import { UserListJoinings, UserLists } from "@/models/index.js"; +import Channel from "../channel.js"; export default class extends Channel { public readonly chName = "userList"; @@ -25,7 +25,7 @@ export default class extends Channel { const exist = await UserLists.exist({ where: { id: this.listId, - userId: this.user!.id, + userId: this.user?.id, }, }); if (!exist) return; diff --git a/packages/backend/src/server/api/stream/index.ts b/packages/backend/src/server/api/stream/index.ts index 86408a03..b1947b2a 100644 --- a/packages/backend/src/server/api/stream/index.ts +++ b/packages/backend/src/server/api/stream/index.ts @@ -1,32 +1,32 @@ import type { EventEmitter } from "events"; -import type * as websocket from "websocket"; -import readNote from "@/services/note/read.js"; -import type { User } from "@/models/entities/user.js"; +import type { Packed } from "@/misc/schema.js"; +import type { AccessToken } from "@/models/entities/access-token.js"; import type { Channel as ChannelModel } from "@/models/entities/channel.js"; +import type { UserGroup } from "@/models/entities/user-group.js"; +import type { UserProfile } from "@/models/entities/user-profile.js"; +import type { User } from "@/models/entities/user.js"; import { - Users, + Blockings, + ChannelFollowings, Followings, Mutings, RenoteMutings, UserProfiles, - ChannelFollowings, - Blockings, + Users, } from "@/models/index.js"; -import type { AccessToken } from "@/models/entities/access-token.js"; -import type { UserProfile } from "@/models/entities/user-profile.js"; +import { readNotification } from "@/server/api/common/read-notification.js"; +import { getClient } from "@/server/api/mastodon/ApiMastodonCompatibleService.js"; +import readNote from "@/services/note/read.js"; import { publishChannelStream, publishGroupMessagingStream, publishMessagingStream, } from "@/services/stream.js"; -import type { UserGroup } from "@/models/entities/user-group.js"; -import type { Packed } from "@/misc/schema.js"; -import { readNotification } from "@/server/api/common/read-notification.js"; -import channels from "./channels/index.js"; -import type Channel from "./channel.js"; -import type { StreamEventEmitter, StreamMessages } from "./types.js"; import { Converter } from "megalodon"; -import { getClient } from "@/server/api/mastodon/ApiMastodonCompatibleService.js"; +import type * as websocket from "websocket"; +import type Channel from "./channel.js"; +import channels from "./channels/index.js"; +import type { StreamEventEmitter, StreamMessages } from "./types.js"; /** * Main stream connection @@ -159,7 +159,7 @@ export default class Connection { // is Mastodon Compatible this.isMastodonCompatible = true; if (simpleObj.type === "subscribe") { - let forSubscribe = []; + const forSubscribe = []; if (simpleObj.stream === "user") { this.currentSubscribe.push(["user"]); objs = [ @@ -329,7 +329,7 @@ export default class Connection { private onReadNotification(payload: any) { if (!payload.id) return; - readNotification(this.user!.id, [payload.id]); + readNotification(this.user?.id, [payload.id]); } /** @@ -534,7 +534,7 @@ export default class Connection { private async updateFollowing() { const followings = await Followings.find({ where: { - followerId: this.user!.id, + followerId: this.user?.id, }, select: ["followeeId"], }); @@ -545,7 +545,7 @@ export default class Connection { private async updateMuting() { const mutings = await Mutings.find({ where: { - muterId: this.user!.id, + muterId: this.user?.id, }, select: ["muteeId"], }); @@ -556,7 +556,7 @@ export default class Connection { private async updateRenoteMuting() { const renoteMutings = await RenoteMutings.find({ where: { - muterId: this.user!.id, + muterId: this.user?.id, }, select: ["muteeId"], }); @@ -568,7 +568,7 @@ export default class Connection { // ここでいうBlockingは被Blockingの意 const blockings = await Blockings.find({ where: { - blockeeId: this.user!.id, + blockeeId: this.user?.id, }, select: ["blockerId"], }); @@ -579,7 +579,7 @@ export default class Connection { private async updateFollowingChannels() { const followings = await ChannelFollowings.find({ where: { - followerId: this.user!.id, + followerId: this.user?.id, }, select: ["followeeId"], }); @@ -591,7 +591,7 @@ export default class Connection { private async updateUserProfile() { this.userProfile = await UserProfiles.findOneBy({ - userId: this.user!.id, + userId: this.user?.id, }); } diff --git a/packages/backend/src/server/api/stream/types.ts b/packages/backend/src/server/api/stream/types.ts index 91095a46..07c9202a 100644 --- a/packages/backend/src/server/api/stream/types.ts +++ b/packages/backend/src/server/api/stream/types.ts @@ -1,20 +1,20 @@ import type { EventEmitter } from "events"; -import type Emitter from "strict-event-emitter-types"; -import type { Channel } from "@/models/entities/channel.js"; -import type { User } from "@/models/entities/user.js"; -import type { UserProfile } from "@/models/entities/user-profile.js"; -import type { Note } from "@/models/entities/note.js"; +import type { Packed } from "@/misc/schema.js"; +import type { AbuseUserReport } from "@/models/entities/abuse-user-report.js"; import type { Antenna } from "@/models/entities/antenna.js"; +import type { Channel } from "@/models/entities/channel.js"; import type { DriveFile } from "@/models/entities/drive-file.js"; import type { DriveFolder } from "@/models/entities/drive-folder.js"; -import type { UserList } from "@/models/entities/user-list.js"; import type { MessagingMessage } from "@/models/entities/messaging-message.js"; -import type { UserGroup } from "@/models/entities/user-group.js"; -import type { AbuseUserReport } from "@/models/entities/abuse-user-report.js"; -import type { Signin } from "@/models/entities/signin.js"; +import type { Note } from "@/models/entities/note.js"; import type { Page } from "@/models/entities/page.js"; -import type { Packed } from "@/misc/schema.js"; +import type { Signin } from "@/models/entities/signin.js"; +import type { UserGroup } from "@/models/entities/user-group.js"; +import type { UserList } from "@/models/entities/user-list.js"; +import type { UserProfile } from "@/models/entities/user-profile.js"; +import type { User } from "@/models/entities/user.js"; import type { Webhook } from "@/models/entities/webhook"; +import type Emitter from "strict-event-emitter-types"; //#region Stream type-body definitions export interface InternalStreamTypes { diff --git a/packages/backend/src/server/api/streaming.ts b/packages/backend/src/server/api/streaming.ts index 14e07b74..96ee49ce 100644 --- a/packages/backend/src/server/api/streaming.ts +++ b/packages/backend/src/server/api/streaming.ts @@ -1,12 +1,12 @@ -import type * as http from "node:http"; import { EventEmitter } from "events"; +import type * as http from "node:http"; import type { ParsedUrlQuery } from "querystring"; import * as websocket from "websocket"; import { subscriber as redisClient } from "@/db/redis.js"; import { Users } from "@/models/index.js"; -import MainStreamConnection from "./stream/index.js"; import authenticate from "./authenticate.js"; +import MainStreamConnection from "./stream/index.js"; export const initializeStreamingServer = (server: http.Server) => { // Init websocket server diff --git a/packages/backend/src/server/file/byte-range-readable.ts b/packages/backend/src/server/file/byte-range-readable.ts index 96dcbc4a..c9892310 100644 --- a/packages/backend/src/server/file/byte-range-readable.ts +++ b/packages/backend/src/server/file/byte-range-readable.ts @@ -1,6 +1,6 @@ -import { Readable, ReadableOptions } from "node:stream"; import { Buffer } from "node:buffer"; import * as fs from "node:fs"; +import { Readable, ReadableOptions } from "node:stream"; interface ByteRange { start: bigint; @@ -82,7 +82,7 @@ function extractRanges( } function createBoundary(len: number): string { - let chars = []; + const chars = []; for (let i = 0; i < len; i = i + 1) { chars[i] = BOUNDARY_CHARS.charAt( Math.floor(Math.random() * BOUNDARY_CHARS.length), @@ -167,7 +167,7 @@ class ByteRangeReadable extends Readable { } _read(n) { - if (this.index == this.ranges.length) { + if (this.index === this.ranges.length) { this.push(null); return; } @@ -204,7 +204,7 @@ class ByteRangeReadable extends Readable { this.destroy(err); return; } - if (bytesRead == 0) { + if (bytesRead === 0) { /* something seems to have gone wrong? */ this.push(null); return; diff --git a/packages/backend/src/server/file/index.ts b/packages/backend/src/server/file/index.ts index 26df1de5..1b1e81a2 100644 --- a/packages/backend/src/server/file/index.ts +++ b/packages/backend/src/server/file/index.ts @@ -3,11 +3,11 @@ */ import * as fs from "node:fs"; -import { fileURLToPath } from "node:url"; import { dirname } from "node:path"; -import Koa from "koa"; +import { fileURLToPath } from "node:url"; import cors from "@koa/cors"; import Router from "@koa/router"; +import Koa from "koa"; import sendDriveFile from "./send-drive-file.js"; const _filename = fileURLToPath(import.meta.url); diff --git a/packages/backend/src/server/file/send-drive-file.ts b/packages/backend/src/server/file/send-drive-file.ts index cb299349..435f159c 100644 --- a/packages/backend/src/server/file/send-drive-file.ts +++ b/packages/backend/src/server/file/send-drive-file.ts @@ -1,21 +1,21 @@ import * as fs from "node:fs"; -import { fileURLToPath } from "node:url"; import { dirname } from "node:path"; +import { fileURLToPath } from "node:url"; +import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; +import { contentDisposition } from "@/misc/content-disposition.js"; +import { createTemp } from "@/misc/create-temp.js"; +import { downloadUrl } from "@/misc/download-url.js"; +import { StatusError } from "@/misc/fetch.js"; +import { detectType } from "@/misc/get-file-info.js"; +import { DriveFiles } from "@/models/index.js"; +import { GenerateVideoThumbnail } from "@/services/drive/generate-video-thumbnail.js"; +import { convertToWebp } from "@/services/drive/image-processor.js"; +import { InternalStorage } from "@/services/drive/internal-storage.js"; import type Koa from "koa"; import send from "koa-send"; import rename from "rename"; import { serverLogger } from "../index.js"; -import { contentDisposition } from "@/misc/content-disposition.js"; -import { DriveFiles } from "@/models/index.js"; -import { InternalStorage } from "@/services/drive/internal-storage.js"; -import { createTemp } from "@/misc/create-temp.js"; -import { downloadUrl } from "@/misc/download-url.js"; -import { detectType } from "@/misc/get-file-info.js"; -import { convertToWebp } from "@/services/drive/image-processor.js"; -import { GenerateVideoThumbnail } from "@/services/drive/generate-video-thumbnail.js"; -import { StatusError } from "@/misc/fetch.js"; import { ByteRangeReadable } from "./byte-range-readable.js"; -import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; const _filename = fileURLToPath(import.meta.url); const _dirname = dirname(_filename); @@ -174,7 +174,7 @@ export default async function (ctx: Koa.Context) { const ranges = ByteRangeReadable.parseByteRanges( BigInt(file.size), MAX_BYTE_RANGES, - ctx.headers["range"], + ctx.headers.range, ); const readable = ranges.length === 0 diff --git a/packages/backend/src/server/index.ts b/packages/backend/src/server/index.ts index 3a9f62f3..26f9b9b9 100644 --- a/packages/backend/src/server/index.ts +++ b/packages/backend/src/server/index.ts @@ -5,34 +5,34 @@ import cluster from "node:cluster"; import * as fs from "node:fs"; import * as http from "node:http"; -import Koa from "koa"; -import Router from "@koa/router"; import cors from "@koa/cors"; -import mount from "koa-mount"; +import Router from "@koa/router"; +import Koa from "koa"; import koaLogger from "koa-logger"; +import mount from "koa-mount"; import * as slow from "koa-slow"; -import { IsNull } from "typeorm"; import config from "@/config/index.js"; -import Logger from "@/services/logger.js"; -import { Users } from "@/models/index.js"; +import { envOption } from "@/env.js"; +import * as Acct from "@/misc/acct.js"; +import { createTemp } from "@/misc/create-temp.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; import { genIdenticon } from "@/misc/gen-identicon.js"; -import { createTemp } from "@/misc/create-temp.js"; -import * as Acct from "@/misc/acct.js"; -import { envOption } from "@/env.js"; -import megalodon, { MegalodonInterface } from "megalodon"; -import activityPub from "./activitypub.js"; -import nodeinfo from "./nodeinfo.js"; -import wellKnown from "./well-known.js"; -import apiServer from "./api/index.js"; -import fileServer from "./file/index.js"; -import proxyServer from "./proxy/index.js"; -import webServer from "./web/index.js"; -import { initializeStreamingServer } from "./api/streaming.js"; +import { Users } from "@/models/index.js"; +import Logger from "@/services/logger.js"; import { koaBody } from "koa-body"; import removeTrailingSlash from "koa-remove-trailing-slashes"; +import megalodon, { MegalodonInterface } from "megalodon"; +import { IsNull } from "typeorm"; import { v4 as uuid } from "uuid"; +import activityPub from "./activitypub.js"; +import apiServer from "./api/index.js"; +import { initializeStreamingServer } from "./api/streaming.js"; +import fileServer from "./file/index.js"; +import nodeinfo from "./nodeinfo.js"; +import proxyServer from "./proxy/index.js"; +import webServer from "./web/index.js"; +import wellKnown from "./well-known.js"; export const serverLogger = new Logger("server", "gray", false); @@ -177,7 +177,7 @@ mastoRouter.post("/oauth/token", async (ctx) => { console.log(body.code, token); token = body.code; } - if (client_id instanceof Array) { + if (Array.isArray(client_id)) { client_id = client_id.toString(); } else if (!client_id) { client_id = null; @@ -251,7 +251,7 @@ export default () => } if (cluster.isWorker) { - process.send!("listenFailed"); + process.send?.("listenFailed"); } else { // disableClustering process.exit(1); diff --git a/packages/backend/src/server/nodeinfo.ts b/packages/backend/src/server/nodeinfo.ts index a1d519f3..665636dc 100644 --- a/packages/backend/src/server/nodeinfo.ts +++ b/packages/backend/src/server/nodeinfo.ts @@ -1,10 +1,10 @@ -import Router from "@koa/router"; import config from "@/config/index.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; -import { Users, Notes } from "@/models/index.js"; -import { IsNull, MoreThan } from "typeorm"; -import { MAX_NOTE_TEXT_LENGTH, MAX_CAPTION_TEXT_LENGTH } from "@/const.js"; +import { MAX_CAPTION_TEXT_LENGTH, MAX_NOTE_TEXT_LENGTH } from "@/const.js"; import { Cache } from "@/misc/cache.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; +import { Notes, Users } from "@/models/index.js"; +import Router from "@koa/router"; +import { IsNull, MoreThan } from "typeorm"; const router = new Router(); diff --git a/packages/backend/src/server/proxy/index.ts b/packages/backend/src/server/proxy/index.ts index 004b3779..4cc65691 100644 --- a/packages/backend/src/server/proxy/index.ts +++ b/packages/backend/src/server/proxy/index.ts @@ -2,9 +2,9 @@ * Media Proxy */ -import Koa from "koa"; import cors from "@koa/cors"; import Router from "@koa/router"; +import Koa from "koa"; import { proxyMedia } from "./proxy-media.js"; // Init app diff --git a/packages/backend/src/server/proxy/proxy-media.ts b/packages/backend/src/server/proxy/proxy-media.ts index ed607daa..1a8626bb 100644 --- a/packages/backend/src/server/proxy/proxy-media.ts +++ b/packages/backend/src/server/proxy/proxy-media.ts @@ -1,17 +1,17 @@ +import { promises } from "node:dns"; import * as fs from "node:fs"; import net from "node:net"; -import { promises } from "node:dns"; -import type Koa from "koa"; -import sharp from "sharp"; -import type { IImage } from "@/services/drive/image-processor.js"; -import { convertToWebp } from "@/services/drive/image-processor.js"; +import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; import { createTemp } from "@/misc/create-temp.js"; import { downloadUrl } from "@/misc/download-url.js"; -import { detectType } from "@/misc/get-file-info.js"; import { StatusError } from "@/misc/fetch.js"; -import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; -import { serverLogger } from "../index.js"; +import { detectType } from "@/misc/get-file-info.js"; import { isMimeImage } from "@/misc/is-mime-image.js"; +import type { IImage } from "@/services/drive/image-processor.js"; +import { convertToWebp } from "@/services/drive/image-processor.js"; +import type Koa from "koa"; +import sharp from "sharp"; +import { serverLogger } from "../index.js"; export async function proxyMedia(ctx: Koa.Context) { let url = "url" in ctx.query ? ctx.query.url : `https://${ctx.params.url}`; diff --git a/packages/backend/src/server/web/feed.ts b/packages/backend/src/server/web/feed.ts index 50e6bfc3..75c3c6ab 100644 --- a/packages/backend/src/server/web/feed.ts +++ b/packages/backend/src/server/web/feed.ts @@ -1,8 +1,8 @@ -import { Feed } from "feed"; -import { In, IsNull } from "typeorm"; import config from "@/config/index.js"; import type { User } from "@/models/entities/user.js"; -import { Notes, DriveFiles, UserProfiles, Users } from "@/models/index.js"; +import { DriveFiles, Notes, UserProfiles, Users } from "@/models/index.js"; +import { Feed } from "feed"; +import { In, IsNull } from "typeorm"; export default async function ( user: User, @@ -135,7 +135,7 @@ export default async function ( }">${file.name}`; } } - outstr += `${note.cw ? note.cw + "
" : ""}${note.text || ""}${fileEle}`; + outstr += `${note.cw ? `${note.cw}
` : ""}${note.text || ""}${fileEle}`; if (isTheNote) { outstr += ` `; + text += "
"; text += await noteToString(findings); next = findings.renoteId ? findings.renoteId : findings.replyId; } diff --git a/packages/backend/src/server/web/index.ts b/packages/backend/src/server/web/index.ts index 3981d576..90738060 100644 --- a/packages/backend/src/server/web/index.ts +++ b/packages/backend/src/server/web/index.ts @@ -2,39 +2,39 @@ * Web Client Server */ +import { readFileSync } from "node:fs"; import { dirname } from "node:path"; import { fileURLToPath } from "node:url"; -import { readFileSync } from "node:fs"; -import Koa from "koa"; -import Router from "@koa/router"; -import send from "koa-send"; -import favicon from "koa-favicon"; -import views from "@ladjs/koa-views"; -import sharp from "sharp"; import { createBullBoard } from "@bull-board/api"; import { BullAdapter } from "@bull-board/api/bullAdapter.js"; import { KoaAdapter } from "@bull-board/koa"; +import Router from "@koa/router"; +import views from "@ladjs/koa-views"; +import Koa from "koa"; +import favicon from "koa-favicon"; +import send from "koa-send"; +import sharp from "sharp"; -import { In, IsNull } from "typeorm"; -import { fetchMeta, metaToPugArgs } from "@/misc/fetch-meta.js"; import config from "@/config/index.js"; +import { DAY, MINUTE } from "@/const.js"; +import * as Acct from "@/misc/acct.js"; +import { fetchMeta, metaToPugArgs } from "@/misc/fetch-meta.js"; +import { getNoteSummary } from "@/misc/get-note-summary.js"; import { - Users, - Notes, - UserProfiles, - Pages, Channels, Clips, GalleryPosts, + Notes, + Pages, + UserProfiles, + Users, } from "@/models/index.js"; -import * as Acct from "@/misc/acct.js"; -import { getNoteSummary } from "@/misc/get-note-summary.js"; import { queues } from "@/queue/queues.js"; +import { In, IsNull } from "typeorm"; import { genOpenapiSpec } from "../api/openapi/gen-spec.js"; -import { urlPreviewHandler } from "./url-preview.js"; -import { manifestHandler } from "./manifest.js"; import packFeed from "./feed.js"; -import { MINUTE, DAY } from "@/const.js"; +import { manifestHandler } from "./manifest.js"; +import { urlPreviewHandler } from "./url-preview.js"; const _filename = fileURLToPath(import.meta.url); const _dirname = dirname(_filename); @@ -294,12 +294,12 @@ const getFeed = async ( return; } let thread = parseInt(threadDepth, 10); - if (isNaN(thread) || thread < 0 || thread > 30) { + if (Number.isNaN(thread) || thread < 0 || thread > 30) { thread = 3; } let history = parseInt(historyCount, 10); //cant be 0 here or it will get all posts - if (isNaN(history) || history <= 0 || history > 30) { + if (Number.isNaN(history) || history <= 0 || history > 30) { history = 20; } return ( @@ -308,9 +308,9 @@ const getFeed = async ( user, thread, history, - !isNaN(noteInTitle), - isNaN(noRenotes), - isNaN(noReplies), + !Number.isNaN(noteInTitle), + Number.isNaN(noRenotes), + Number.isNaN(noReplies), )) ); }; diff --git a/packages/backend/src/server/web/manifest.ts b/packages/backend/src/server/web/manifest.ts index bbcf639f..38cb6755 100644 --- a/packages/backend/src/server/web/manifest.ts +++ b/packages/backend/src/server/web/manifest.ts @@ -1,6 +1,6 @@ -import type Koa from "koa"; -import { fetchMeta } from "@/misc/fetch-meta.js"; import config from "@/config/index.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; +import type Koa from "koa"; import manifest from "./manifest.json" assert { type: "json" }; export const manifestHandler = async (ctx: Koa.Context) => { diff --git a/packages/backend/src/server/web/url-preview.ts b/packages/backend/src/server/web/url-preview.ts index c9f3b6ca..e8362670 100644 --- a/packages/backend/src/server/web/url-preview.ts +++ b/packages/backend/src/server/web/url-preview.ts @@ -1,10 +1,10 @@ +import config from "@/config/index.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; +import { getJson } from "@/misc/fetch.js"; +import { query } from "@/prelude/url.js"; +import Logger from "@/services/logger.js"; import type Koa from "koa"; import summaly from "summaly"; -import { fetchMeta } from "@/misc/fetch-meta.js"; -import Logger from "@/services/logger.js"; -import config from "@/config/index.js"; -import { query } from "@/prelude/url.js"; -import { getJson } from "@/misc/fetch.js"; const logger = new Logger("url-preview"); diff --git a/packages/backend/src/server/well-known.ts b/packages/backend/src/server/well-known.ts index 5af3b2c8..c70861c6 100644 --- a/packages/backend/src/server/well-known.ts +++ b/packages/backend/src/server/well-known.ts @@ -2,12 +2,12 @@ import Router from "@koa/router"; import config from "@/config/index.js"; import * as Acct from "@/misc/acct.js"; -import { links } from "./nodeinfo.js"; -import { escapeAttribute, escapeValue } from "@/prelude/xml.js"; -import { Users } from "@/models/index.js"; import type { User } from "@/models/entities/user.js"; +import { Users } from "@/models/index.js"; +import { escapeAttribute, escapeValue } from "@/prelude/xml.js"; import type { FindOptionsWhere } from "typeorm"; import { IsNull } from "typeorm"; +import { links } from "./nodeinfo.js"; // Init router const router = new Router(); diff --git a/packages/backend/src/services/add-note-to-antenna.ts b/packages/backend/src/services/add-note-to-antenna.ts index 49941800..b9c40e1d 100644 --- a/packages/backend/src/services/add-note-to-antenna.ts +++ b/packages/backend/src/services/add-note-to-antenna.ts @@ -1,9 +1,9 @@ +import { redisClient } from "@/db/redis.js"; +import { getTimestamp } from "@/misc/gen-id.js"; import type { Antenna } from "@/models/entities/antenna.js"; import type { Note } from "@/models/entities/note.js"; -import { getTimestamp } from "@/misc/gen-id.js"; -import { redisClient } from "@/db/redis.js"; -import { publishAntennaStream } from "@/services/stream.js"; import type { User } from "@/models/entities/user.js"; +import { publishAntennaStream } from "@/services/stream.js"; export async function addNoteToAntenna( antenna: Antenna, diff --git a/packages/backend/src/services/blocking/create.ts b/packages/backend/src/services/blocking/create.ts index 144304cf..c7a12fd6 100644 --- a/packages/backend/src/services/blocking/create.ts +++ b/packages/backend/src/services/blocking/create.ts @@ -1,23 +1,23 @@ -import { publishMainStream, publishUserEvent } from "@/services/stream.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import renderFollow from "@/remote/activitypub/renderer/follow.js"; -import renderUndo from "@/remote/activitypub/renderer/undo.js"; -import { renderBlock } from "@/remote/activitypub/renderer/block.js"; -import { deliver } from "@/queue/index.js"; -import renderReject from "@/remote/activitypub/renderer/reject.js"; +import { genId } from "@/misc/gen-id.js"; +import { getActiveWebhooks } from "@/misc/webhook-cache.js"; import type { Blocking } from "@/models/entities/blocking.js"; import type { User } from "@/models/entities/user.js"; import { Blockings, - Users, FollowRequests, Followings, UserListJoinings, UserLists, + Users, } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; -import { getActiveWebhooks } from "@/misc/webhook-cache.js"; +import { deliver } from "@/queue/index.js"; import { webhookDeliver } from "@/queue/index.js"; +import { renderBlock } from "@/remote/activitypub/renderer/block.js"; +import renderFollow from "@/remote/activitypub/renderer/follow.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import renderReject from "@/remote/activitypub/renderer/reject.js"; +import renderUndo from "@/remote/activitypub/renderer/undo.js"; +import { publishMainStream, publishUserEvent } from "@/services/stream.js"; export default async function (blocker: User, blockee: User) { await Promise.all([ diff --git a/packages/backend/src/services/blocking/delete.ts b/packages/backend/src/services/blocking/delete.ts index 271883fe..2e57525a 100644 --- a/packages/backend/src/services/blocking/delete.ts +++ b/packages/backend/src/services/blocking/delete.ts @@ -1,10 +1,10 @@ -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import { renderBlock } from "@/remote/activitypub/renderer/block.js"; -import renderUndo from "@/remote/activitypub/renderer/undo.js"; -import { deliver } from "@/queue/index.js"; -import Logger from "@/services/logger.js"; import type { CacheableUser } from "@/models/entities/user.js"; import { Blockings, Users } from "@/models/index.js"; +import { deliver } from "@/queue/index.js"; +import { renderBlock } from "@/remote/activitypub/renderer/block.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import renderUndo from "@/remote/activitypub/renderer/undo.js"; +import Logger from "@/services/logger.js"; const logger = new Logger("blocking/delete"); diff --git a/packages/backend/src/services/chart/charts/active-users.ts b/packages/backend/src/services/chart/charts/active-users.ts index 3f4b7e33..669caa91 100644 --- a/packages/backend/src/services/chart/charts/active-users.ts +++ b/packages/backend/src/services/chart/charts/active-users.ts @@ -1,6 +1,6 @@ +import type { User } from "@/models/entities/user.js"; import type { KVs } from "../core.js"; import Chart from "../core.js"; -import type { User } from "@/models/entities/user.js"; import { name, schema } from "./entities/active-users.js"; const week = 1000 * 60 * 60 * 24 * 7; diff --git a/packages/backend/src/services/chart/core.ts b/packages/backend/src/services/chart/core.ts index d6bdca8d..5bab7d69 100644 --- a/packages/backend/src/services/chart/core.ts +++ b/packages/backend/src/services/chart/core.ts @@ -4,20 +4,20 @@ * Tests located in test/chart */ -import * as nestedProperty from "nested-property"; -import Logger from "../logger.js"; -import type { Repository } from "typeorm"; -import { EntitySchema, LessThan, Between } from "typeorm"; -import { - dateUTC, - isTimeSame, - isTimeBefore, - subtractTime, - addTime, -} from "@/prelude/time.js"; -import { getChartInsertLock } from "@/misc/app-lock.js"; import { db } from "@/db/postgre.js"; +import { getChartInsertLock } from "@/misc/app-lock.js"; +import { + addTime, + dateUTC, + isTimeBefore, + isTimeSame, + subtractTime, +} from "@/prelude/time.js"; +import * as nestedProperty from "nested-property"; import promiseLimit from "promise-limit"; +import type { Repository } from "typeorm"; +import { Between, EntitySchema, LessThan } from "typeorm"; +import Logger from "../logger.js"; const logger = new Logger("chart", "white", process.env.NODE_ENV !== "test"); @@ -463,7 +463,7 @@ export default abstract class Chart { protected commit(diff: Commit, group: string | null = null): void { for (const [k, v] of Object.entries(diff)) { if (v == null || v === 0 || (Array.isArray(v) && v.length === 0)) - // rome-ignore lint/performance/noDelete: needs to be deleted not just set to undefined + // biome-ignore lint/performance/noDelete: needs to be deleted not just set to undefined delete diff[k]; } this.buffer.push({ diff --git a/packages/backend/src/services/create-notification.ts b/packages/backend/src/services/create-notification.ts index 9bfd1a7b..d537fcd7 100644 --- a/packages/backend/src/services/create-notification.ts +++ b/packages/backend/src/services/create-notification.ts @@ -1,18 +1,18 @@ -import { publishMainStream } from "@/services/stream.js"; -import { pushNotification } from "@/services/push-notification.js"; +import { genId } from "@/misc/gen-id.js"; +import { shouldSilenceInstance } from "@/misc/should-block-instance.js"; +import type { Notification } from "@/models/entities/notification.js"; +import type { User } from "@/models/entities/user.js"; import { - Notifications, + Followings, Mutings, NoteThreadMutings, + Notifications, UserProfiles, Users, - Followings, } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; -import type { User } from "@/models/entities/user.js"; -import type { Notification } from "@/models/entities/notification.js"; +import { pushNotification } from "@/services/push-notification.js"; +import { publishMainStream } from "@/services/stream.js"; import { sendEmailNotification } from "./send-email-notification.js"; -import { shouldSilenceInstance } from "@/misc/should-block-instance.js"; export async function createNotification( notifieeId: User["id"], diff --git a/packages/backend/src/services/create-system-user.ts b/packages/backend/src/services/create-system-user.ts index 0ebd1142..6ed53535 100644 --- a/packages/backend/src/services/create-system-user.ts +++ b/packages/backend/src/services/create-system-user.ts @@ -1,14 +1,14 @@ -import { v4 as uuid } from "uuid"; -import generateNativeUserToken from "@/server/api/common/generate-native-user-token.js"; -import { genRsaKeyPair } from "@/misc/gen-key-pair.js"; -import { User } from "@/models/entities/user.js"; -import { UserProfile } from "@/models/entities/user-profile.js"; -import { IsNull } from "typeorm"; -import { genId } from "@/misc/gen-id.js"; -import { UserKeypair } from "@/models/entities/user-keypair.js"; -import { UsedUsername } from "@/models/entities/used-username.js"; import { db } from "@/db/postgre.js"; +import { genId } from "@/misc/gen-id.js"; +import { genRsaKeyPair } from "@/misc/gen-key-pair.js"; import { hashPassword } from "@/misc/password.js"; +import { UsedUsername } from "@/models/entities/used-username.js"; +import { UserKeypair } from "@/models/entities/user-keypair.js"; +import { UserProfile } from "@/models/entities/user-profile.js"; +import { User } from "@/models/entities/user.js"; +import generateNativeUserToken from "@/server/api/common/generate-native-user-token.js"; +import { IsNull } from "typeorm"; +import { v4 as uuid } from "uuid"; export async function createSystemUser(username: string) { const password = uuid(); diff --git a/packages/backend/src/services/detect-sensitive.ts b/packages/backend/src/services/detect-sensitive.ts index df695e86..289e2dfc 100644 --- a/packages/backend/src/services/detect-sensitive.ts +++ b/packages/backend/src/services/detect-sensitive.ts @@ -1,6 +1,6 @@ import * as fs from "node:fs"; -import { fileURLToPath } from "node:url"; import { dirname } from "node:path"; +import { fileURLToPath } from "node:url"; import * as nsfw from "nsfwjs"; import si from "systeminformation"; diff --git a/packages/backend/src/services/drive/add-file.ts b/packages/backend/src/services/drive/add-file.ts index 1042c0e0..fe5511ca 100644 --- a/packages/backend/src/services/drive/add-file.ts +++ b/packages/backend/src/services/drive/add-file.ts @@ -2,32 +2,32 @@ import * as fs from "node:fs"; import { v4 as uuid } from "uuid"; -import type S3 from "aws-sdk/clients/s3.js"; // TODO: migrate to SDK v3 -import sharp from "sharp"; -import { IsNull } from "typeorm"; -import { publishMainStream, publishDriveStream } from "@/services/stream.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; import { contentDisposition } from "@/misc/content-disposition.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; +import { genId } from "@/misc/gen-id.js"; import { getFileInfo } from "@/misc/get-file-info.js"; +import { IdentifiableError } from "@/misc/identifiable-error.js"; +import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; +import { DriveFile } from "@/models/entities/drive-file.js"; +import type { IRemoteUser, User } from "@/models/entities/user.js"; import { DriveFiles, DriveFolders, - Users, UserProfiles, + Users, } from "@/models/index.js"; -import { DriveFile } from "@/models/entities/drive-file.js"; -import type { IRemoteUser, User } from "@/models/entities/user.js"; -import { genId } from "@/misc/gen-id.js"; -import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; -import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; -import { IdentifiableError } from "@/misc/identifiable-error.js"; -import { getS3 } from "./s3.js"; -import { InternalStorage } from "./internal-storage.js"; +import { publishDriveStream, publishMainStream } from "@/services/stream.js"; +import type S3 from "aws-sdk/clients/s3.js"; // TODO: migrate to SDK v3 +import sharp from "sharp"; +import { IsNull } from "typeorm"; +import { deleteFile } from "./delete-file.js"; +import { GenerateVideoThumbnail } from "./generate-video-thumbnail.js"; import type { IImage } from "./image-processor.js"; import { convertSharpToWebp } from "./image-processor.js"; +import { InternalStorage } from "./internal-storage.js"; import { driveLogger } from "./logger.js"; -import { GenerateVideoThumbnail } from "./generate-video-thumbnail.js"; -import { deleteFile } from "./delete-file.js"; +import { getS3 } from "./s3.js"; const logger = driveLogger.createSubLogger("register", "yellow"); @@ -591,11 +591,11 @@ export async function addFile({ } = {}; if (info.width) { - properties["width"] = info.width; - properties["height"] = info.height; + properties.width = info.width; + properties.height = info.height; } if (info.orientation != null) { - properties["orientation"] = info.orientation; + properties.orientation = info.orientation; } const profile = user @@ -619,14 +619,14 @@ export async function addFile({ file.maybeSensitive = info.sensitive; file.maybePorn = info.porn; file.isSensitive = user - ? Users.isLocalUser(user) && profile!.alwaysMarkNsfw + ? Users.isLocalUser(user) && profile?.alwaysMarkNsfw ? true : sensitive !== null && sensitive !== undefined ? sensitive : false : false; - if (info.sensitive && profile!.autoSensitive) file.isSensitive = true; + if (info.sensitive && profile?.autoSensitive) file.isSensitive = true; if (info.sensitive && instance.setSensitiveFlagAutomatically) file.isSensitive = true; diff --git a/packages/backend/src/services/drive/delete-file.ts b/packages/backend/src/services/drive/delete-file.ts index b172c7d9..6624031c 100644 --- a/packages/backend/src/services/drive/delete-file.ts +++ b/packages/backend/src/services/drive/delete-file.ts @@ -1,10 +1,10 @@ +import { fetchMeta } from "@/misc/fetch-meta.js"; import type { DriveFile } from "@/models/entities/drive-file.js"; -import { InternalStorage } from "./internal-storage.js"; import { DriveFiles } from "@/models/index.js"; import { createDeleteObjectStorageFileJob } from "@/queue/index.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; -import { getS3 } from "./s3.js"; import { v4 as uuid } from "uuid"; +import { InternalStorage } from "./internal-storage.js"; +import { getS3 } from "./s3.js"; export async function deleteFile(file: DriveFile, isExpired = false) { if (file.storedInternal) { diff --git a/packages/backend/src/services/drive/generate-video-thumbnail.ts b/packages/backend/src/services/drive/generate-video-thumbnail.ts index 0e3f0db5..694a7965 100644 --- a/packages/backend/src/services/drive/generate-video-thumbnail.ts +++ b/packages/backend/src/services/drive/generate-video-thumbnail.ts @@ -1,7 +1,7 @@ import { createTempDir } from "@/misc/create-temp.js"; +import FFmpeg from "fluent-ffmpeg"; import type { IImage } from "./image-processor.js"; import { convertToWebp } from "./image-processor.js"; -import FFmpeg from "fluent-ffmpeg"; export async function GenerateVideoThumbnail(source: string): Promise { const [dir, cleanup] = await createTempDir(); diff --git a/packages/backend/src/services/drive/internal-storage.ts b/packages/backend/src/services/drive/internal-storage.ts index b2a663b3..560c272d 100644 --- a/packages/backend/src/services/drive/internal-storage.ts +++ b/packages/backend/src/services/drive/internal-storage.ts @@ -1,8 +1,8 @@ import * as fs from "node:fs"; import * as fsPromises from "node:fs/promises"; import * as Path from "node:path"; -import { fileURLToPath } from "node:url"; import { dirname } from "node:path"; +import { fileURLToPath } from "node:url"; import config from "@/config/index.js"; const _filename = fileURLToPath(import.meta.url); diff --git a/packages/backend/src/services/drive/s3.ts b/packages/backend/src/services/drive/s3.ts index d01f89cb..f7a4a57e 100644 --- a/packages/backend/src/services/drive/s3.ts +++ b/packages/backend/src/services/drive/s3.ts @@ -1,7 +1,7 @@ import { URL } from "node:url"; -import S3 from "aws-sdk/clients/s3.js"; // TODO: migrate to SDK v3 -import type { Meta } from "@/models/entities/meta.js"; import { getAgentByUrl } from "@/misc/fetch.js"; +import type { Meta } from "@/models/entities/meta.js"; +import S3 from "aws-sdk/clients/s3.js"; // TODO: migrate to SDK v3 export function getS3(meta: Meta) { const u = diff --git a/packages/backend/src/services/drive/upload-from-url.ts b/packages/backend/src/services/drive/upload-from-url.ts index 0638bcab..2afa1458 100644 --- a/packages/backend/src/services/drive/upload-from-url.ts +++ b/packages/backend/src/services/drive/upload-from-url.ts @@ -1,12 +1,12 @@ import { URL } from "node:url"; -import type { User } from "@/models/entities/user.js"; import { createTemp } from "@/misc/create-temp.js"; import { downloadUrl, isPrivateIp } from "@/misc/download-url.js"; -import type { DriveFolder } from "@/models/entities/drive-folder.js"; import type { DriveFile } from "@/models/entities/drive-file.js"; +import type { DriveFolder } from "@/models/entities/drive-folder.js"; +import type { User } from "@/models/entities/user.js"; import { DriveFiles } from "@/models/index.js"; -import { driveLogger } from "./logger.js"; import { addFile } from "./add-file.js"; +import { driveLogger } from "./logger.js"; const logger = driveLogger.createSubLogger("downloader"); diff --git a/packages/backend/src/services/fetch-instance-metadata.ts b/packages/backend/src/services/fetch-instance-metadata.ts index a4cc33bc..b399df24 100644 --- a/packages/backend/src/services/fetch-instance-metadata.ts +++ b/packages/backend/src/services/fetch-instance-metadata.ts @@ -1,12 +1,12 @@ import { URL } from "node:url"; +import { getFetchInstanceMetadataLock } from "@/misc/app-lock.js"; +import { getAgentByUrl, getJson } from "@/misc/fetch.js"; +import type { Instance } from "@/models/entities/instance.js"; +import { Instances } from "@/models/index.js"; +import Logger from "@/services/logger.js"; import { Window } from "happy-dom"; import fetch from "node-fetch"; import tinycolor from "tinycolor2"; -import { getJson, getAgentByUrl } from "@/misc/fetch.js"; -import type { Instance } from "@/models/entities/instance.js"; -import { Instances } from "@/models/index.js"; -import { getFetchInstanceMetadataLock } from "@/misc/app-lock.js"; -import Logger from "@/services/logger.js"; const logger = new Logger("metadata", "cyan"); diff --git a/packages/backend/src/services/fetch-rel-me.ts b/packages/backend/src/services/fetch-rel-me.ts index c9a37d1c..0bb340db 100644 --- a/packages/backend/src/services/fetch-rel-me.ts +++ b/packages/backend/src/services/fetch-rel-me.ts @@ -1,5 +1,5 @@ -import { Window } from "happy-dom"; import config from "@/config/index.js"; +import { Window } from "happy-dom"; async function getRelMeLinks(url: string): Promise { try { diff --git a/packages/backend/src/services/following/create.ts b/packages/backend/src/services/following/create.ts index 3b8f6328..bae65675 100644 --- a/packages/backend/src/services/following/create.ts +++ b/packages/backend/src/services/following/create.ts @@ -1,29 +1,29 @@ -import { publishMainStream, publishUserEvent } from "@/services/stream.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import renderFollow from "@/remote/activitypub/renderer/follow.js"; -import renderAccept from "@/remote/activitypub/renderer/accept.js"; -import renderReject from "@/remote/activitypub/renderer/reject.js"; -import { deliver } from "@/queue/index.js"; -import createFollowRequest from "./requests/create.js"; -import { registerOrFetchInstanceDoc } from "@/services/register-or-fetch-instance-doc.js"; -import Logger from "../logger.js"; -import { IdentifiableError } from "@/misc/identifiable-error.js"; -import type { User } from "@/models/entities/user.js"; -import { - Followings, - Users, - FollowRequests, - Blockings, - Instances, - UserProfiles, -} from "@/models/index.js"; import { genId } from "@/misc/gen-id.js"; -import { createNotification } from "@/services/create-notification.js"; +import { IdentifiableError } from "@/misc/identifiable-error.js"; import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; import type { Packed } from "@/misc/schema.js"; -import { getActiveWebhooks } from "@/misc/webhook-cache.js"; -import { webhookDeliver } from "@/queue/index.js"; import { shouldSilenceInstance } from "@/misc/should-block-instance.js"; +import { getActiveWebhooks } from "@/misc/webhook-cache.js"; +import type { User } from "@/models/entities/user.js"; +import { + Blockings, + FollowRequests, + Followings, + Instances, + UserProfiles, + Users, +} from "@/models/index.js"; +import { deliver } from "@/queue/index.js"; +import { webhookDeliver } from "@/queue/index.js"; +import renderAccept from "@/remote/activitypub/renderer/accept.js"; +import renderFollow from "@/remote/activitypub/renderer/follow.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import renderReject from "@/remote/activitypub/renderer/reject.js"; +import { createNotification } from "@/services/create-notification.js"; +import { registerOrFetchInstanceDoc } from "@/services/register-or-fetch-instance-doc.js"; +import { publishMainStream, publishUserEvent } from "@/services/stream.js"; +import Logger from "../logger.js"; +import createFollowRequest from "./requests/create.js"; const logger = new Logger("following/create"); diff --git a/packages/backend/src/services/following/delete.ts b/packages/backend/src/services/following/delete.ts index e71e23de..7e6e5861 100644 --- a/packages/backend/src/services/following/delete.ts +++ b/packages/backend/src/services/following/delete.ts @@ -1,14 +1,14 @@ -import { publishMainStream, publishUserEvent } from "@/services/stream.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import renderFollow from "@/remote/activitypub/renderer/follow.js"; -import renderUndo from "@/remote/activitypub/renderer/undo.js"; -import renderReject from "@/remote/activitypub/renderer/reject.js"; -import { deliver, webhookDeliver } from "@/queue/index.js"; -import Logger from "../logger.js"; -import { registerOrFetchInstanceDoc } from "@/services/register-or-fetch-instance-doc.js"; -import type { User } from "@/models/entities/user.js"; -import { Followings, Users, Instances } from "@/models/index.js"; import { getActiveWebhooks } from "@/misc/webhook-cache.js"; +import type { User } from "@/models/entities/user.js"; +import { Followings, Instances, Users } from "@/models/index.js"; +import { deliver, webhookDeliver } from "@/queue/index.js"; +import renderFollow from "@/remote/activitypub/renderer/follow.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import renderReject from "@/remote/activitypub/renderer/reject.js"; +import renderUndo from "@/remote/activitypub/renderer/undo.js"; +import { registerOrFetchInstanceDoc } from "@/services/register-or-fetch-instance-doc.js"; +import { publishMainStream, publishUserEvent } from "@/services/stream.js"; +import Logger from "../logger.js"; const logger = new Logger("following/delete"); diff --git a/packages/backend/src/services/following/reject.ts b/packages/backend/src/services/following/reject.ts index 3f461268..16e46b15 100644 --- a/packages/backend/src/services/following/reject.ts +++ b/packages/backend/src/services/following/reject.ts @@ -1,12 +1,12 @@ -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import renderFollow from "@/remote/activitypub/renderer/follow.js"; -import renderReject from "@/remote/activitypub/renderer/reject.js"; -import { deliver, webhookDeliver } from "@/queue/index.js"; -import { publishMainStream, publishUserEvent } from "@/services/stream.js"; -import type { ILocalUser, IRemoteUser } from "@/models/entities/user.js"; -import { Users, FollowRequests, Followings } from "@/models/index.js"; -import { decrementFollowing } from "./delete.js"; import { getActiveWebhooks } from "@/misc/webhook-cache.js"; +import type { ILocalUser, IRemoteUser } from "@/models/entities/user.js"; +import { FollowRequests, Followings, Users } from "@/models/index.js"; +import { deliver, webhookDeliver } from "@/queue/index.js"; +import renderFollow from "@/remote/activitypub/renderer/follow.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import renderReject from "@/remote/activitypub/renderer/reject.js"; +import { publishMainStream, publishUserEvent } from "@/services/stream.js"; +import { decrementFollowing } from "./delete.js"; type Local = | ILocalUser diff --git a/packages/backend/src/services/following/requests/accept-all.ts b/packages/backend/src/services/following/requests/accept-all.ts index 26924337..1808bff2 100644 --- a/packages/backend/src/services/following/requests/accept-all.ts +++ b/packages/backend/src/services/following/requests/accept-all.ts @@ -1,6 +1,6 @@ -import accept from "./accept.js"; import type { User } from "@/models/entities/user.js"; import { FollowRequests, Users } from "@/models/index.js"; +import accept from "./accept.js"; /** * Approve all follow requests for the specified user diff --git a/packages/backend/src/services/following/requests/accept.ts b/packages/backend/src/services/following/requests/accept.ts index 1bc10f60..2a7c03ba 100644 --- a/packages/backend/src/services/following/requests/accept.ts +++ b/packages/backend/src/services/following/requests/accept.ts @@ -1,12 +1,12 @@ -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import renderFollow from "@/remote/activitypub/renderer/follow.js"; -import renderAccept from "@/remote/activitypub/renderer/accept.js"; +import { IdentifiableError } from "@/misc/identifiable-error.js"; +import type { CacheableUser, User } from "@/models/entities/user.js"; +import { FollowRequests, Users } from "@/models/index.js"; import { deliver } from "@/queue/index.js"; +import renderAccept from "@/remote/activitypub/renderer/accept.js"; +import renderFollow from "@/remote/activitypub/renderer/follow.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import { publishMainStream } from "@/services/stream.js"; import { insertFollowingDoc } from "../create.js"; -import type { User, CacheableUser } from "@/models/entities/user.js"; -import { FollowRequests, Users } from "@/models/index.js"; -import { IdentifiableError } from "@/misc/identifiable-error.js"; export default async function ( followee: { diff --git a/packages/backend/src/services/following/requests/cancel.ts b/packages/backend/src/services/following/requests/cancel.ts index 45b8ee06..1b9758c5 100644 --- a/packages/backend/src/services/following/requests/cancel.ts +++ b/packages/backend/src/services/following/requests/cancel.ts @@ -1,11 +1,11 @@ -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import renderFollow from "@/remote/activitypub/renderer/follow.js"; -import renderUndo from "@/remote/activitypub/renderer/undo.js"; -import { deliver } from "@/queue/index.js"; -import { publishMainStream } from "@/services/stream.js"; import { IdentifiableError } from "@/misc/identifiable-error.js"; import type { User } from "@/models/entities/user.js"; -import { Users, FollowRequests } from "@/models/index.js"; +import { FollowRequests, Users } from "@/models/index.js"; +import { deliver } from "@/queue/index.js"; +import renderFollow from "@/remote/activitypub/renderer/follow.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import renderUndo from "@/remote/activitypub/renderer/undo.js"; +import { publishMainStream } from "@/services/stream.js"; export default async function ( followee: { diff --git a/packages/backend/src/services/following/requests/create.ts b/packages/backend/src/services/following/requests/create.ts index 12dfddf3..a3ed22f8 100644 --- a/packages/backend/src/services/following/requests/create.ts +++ b/packages/backend/src/services/following/requests/create.ts @@ -1,12 +1,12 @@ -import { publishMainStream } from "@/services/stream.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import renderFollow from "@/remote/activitypub/renderer/follow.js"; -import { deliver } from "@/queue/index.js"; +import config from "@/config/index.js"; +import { genId } from "@/misc/gen-id.js"; import type { User } from "@/models/entities/user.js"; import { Blockings, FollowRequests, Users } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; +import { deliver } from "@/queue/index.js"; +import renderFollow from "@/remote/activitypub/renderer/follow.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import { createNotification } from "@/services/create-notification.js"; -import config from "@/config/index.js"; +import { publishMainStream } from "@/services/stream.js"; export default async function ( follower: { diff --git a/packages/backend/src/services/i/pin.ts b/packages/backend/src/services/i/pin.ts index 94ebf753..22232770 100644 --- a/packages/backend/src/services/i/pin.ts +++ b/packages/backend/src/services/i/pin.ts @@ -1,14 +1,14 @@ import config from "@/config/index.js"; -import renderAdd from "@/remote/activitypub/renderer/add.js"; -import renderRemove from "@/remote/activitypub/renderer/remove.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import { IdentifiableError } from "@/misc/identifiable-error.js"; -import type { User } from "@/models/entities/user.js"; -import type { Note } from "@/models/entities/note.js"; -import { Notes, UserNotePinings, Users } from "@/models/index.js"; -import type { UserNotePining } from "@/models/entities/user-note-pining.js"; import { genId } from "@/misc/gen-id.js"; +import { IdentifiableError } from "@/misc/identifiable-error.js"; +import type { Note } from "@/models/entities/note.js"; +import type { UserNotePining } from "@/models/entities/user-note-pining.js"; +import type { User } from "@/models/entities/user.js"; +import { Notes, UserNotePinings, Users } from "@/models/index.js"; import { deliverToFollowers } from "@/remote/activitypub/deliver-manager.js"; +import renderAdd from "@/remote/activitypub/renderer/add.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import renderRemove from "@/remote/activitypub/renderer/remove.js"; import { deliverToRelays } from "@/services/relay.js"; /** diff --git a/packages/backend/src/services/i/update.ts b/packages/backend/src/services/i/update.ts index 21b03d98..ec22907b 100644 --- a/packages/backend/src/services/i/update.ts +++ b/packages/backend/src/services/i/update.ts @@ -1,9 +1,9 @@ -import renderUpdate from "@/remote/activitypub/renderer/update.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import { Users } from "@/models/index.js"; import type { User } from "@/models/entities/user.js"; -import { renderPerson } from "@/remote/activitypub/renderer/person.js"; +import { Users } from "@/models/index.js"; import { deliverToFollowers } from "@/remote/activitypub/deliver-manager.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import { renderPerson } from "@/remote/activitypub/renderer/person.js"; +import renderUpdate from "@/remote/activitypub/renderer/update.js"; import { deliverToRelays } from "@/services/relay.js"; export async function publishToFollowers(userId: User["id"]) { diff --git a/packages/backend/src/services/insert-moderation-log.ts b/packages/backend/src/services/insert-moderation-log.ts index 8e2c5b78..9e45ece6 100644 --- a/packages/backend/src/services/insert-moderation-log.ts +++ b/packages/backend/src/services/insert-moderation-log.ts @@ -1,6 +1,6 @@ -import { ModerationLogs } from "@/models/index.js"; import { genId } from "@/misc/gen-id.js"; import type { User } from "@/models/entities/user.js"; +import { ModerationLogs } from "@/models/index.js"; export async function insertModerationLog( moderator: { id: User["id"] }, diff --git a/packages/backend/src/services/instance-actor.ts b/packages/backend/src/services/instance-actor.ts index a8b34ea5..6f21107e 100644 --- a/packages/backend/src/services/instance-actor.ts +++ b/packages/backend/src/services/instance-actor.ts @@ -1,8 +1,8 @@ -import { createSystemUser } from "./create-system-user.js"; +import { Cache } from "@/misc/cache.js"; import type { ILocalUser } from "@/models/entities/user.js"; import { Users } from "@/models/index.js"; -import { Cache } from "@/misc/cache.js"; import { IsNull } from "typeorm"; +import { createSystemUser } from "./create-system-user.js"; const ACTOR_USERNAME = "instance.actor" as const; diff --git a/packages/backend/src/services/logger.ts b/packages/backend/src/services/logger.ts index df4c2e35..54a0440d 100644 --- a/packages/backend/src/services/logger.ts +++ b/packages/backend/src/services/logger.ts @@ -1,9 +1,9 @@ import cluster from "node:cluster"; +import config from "@/config/index.js"; +import { envOption } from "@/env.js"; import chalk from "chalk"; import { default as convertColor } from "color-convert"; import { format as dateFormat } from "date-fns"; -import { envOption } from "@/env.js"; -import config from "@/config/index.js"; import * as SyslogPro from "syslog-pro"; diff --git a/packages/backend/src/services/messages/create.ts b/packages/backend/src/services/messages/create.ts index 506f2999..ed5e0149 100644 --- a/packages/backend/src/services/messages/create.ts +++ b/packages/backend/src/services/messages/create.ts @@ -1,27 +1,27 @@ -import type { CacheableUser, User } from "@/models/entities/user.js"; -import type { UserGroup } from "@/models/entities/user-group.js"; +import { genId } from "@/misc/gen-id.js"; import type { DriveFile } from "@/models/entities/drive-file.js"; +import type { MessagingMessage } from "@/models/entities/messaging-message.js"; +import type { Note } from "@/models/entities/note.js"; +import type { UserGroup } from "@/models/entities/user-group.js"; +import type { CacheableUser, User } from "@/models/entities/user.js"; import { MessagingMessages, - UserGroupJoinings, Mutings, + UserGroupJoinings, Users, } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; -import type { MessagingMessage } from "@/models/entities/messaging-message.js"; -import { - publishMessagingStream, - publishMessagingIndexStream, - publishMainStream, - publishGroupMessagingStream, -} from "@/services/stream.js"; -import { pushNotification } from "@/services/push-notification.js"; -import { Not } from "typeorm"; -import type { Note } from "@/models/entities/note.js"; -import renderNote from "@/remote/activitypub/renderer/note.js"; +import { deliver } from "@/queue/index.js"; import renderCreate from "@/remote/activitypub/renderer/create.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import { deliver } from "@/queue/index.js"; +import renderNote from "@/remote/activitypub/renderer/note.js"; +import { pushNotification } from "@/services/push-notification.js"; +import { + publishGroupMessagingStream, + publishMainStream, + publishMessagingIndexStream, + publishMessagingStream, +} from "@/services/stream.js"; +import { Not } from "typeorm"; export async function createMessage( user: { id: User["id"]; host: User["host"] }, diff --git a/packages/backend/src/services/messages/delete.ts b/packages/backend/src/services/messages/delete.ts index 77caba80..adc36522 100644 --- a/packages/backend/src/services/messages/delete.ts +++ b/packages/backend/src/services/messages/delete.ts @@ -1,14 +1,14 @@ import config from "@/config/index.js"; -import { MessagingMessages, Users } from "@/models/index.js"; import type { MessagingMessage } from "@/models/entities/messaging-message.js"; +import { MessagingMessages, Users } from "@/models/index.js"; +import { deliver } from "@/queue/index.js"; +import renderDelete from "@/remote/activitypub/renderer/delete.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import renderTombstone from "@/remote/activitypub/renderer/tombstone.js"; import { publishGroupMessagingStream, publishMessagingStream, } from "@/services/stream.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import renderDelete from "@/remote/activitypub/renderer/delete.js"; -import renderTombstone from "@/remote/activitypub/renderer/tombstone.js"; -import { deliver } from "@/queue/index.js"; export async function deleteMessage(message: MessagingMessage) { await MessagingMessages.delete(message.id); diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index f63c0fb5..84e4c14e 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -1,70 +1,70 @@ -import * as mfm from "mfm-js"; -import es from "@/db/elasticsearch.js"; -import sonic from "@/db/sonic.js"; -import { - publishMainStream, - publishNotesStream, - publishNoteStream, -} from "@/services/stream.js"; -import DeliverManager from "@/remote/activitypub/deliver-manager.js"; -import renderNote from "@/remote/activitypub/renderer/note.js"; -import renderCreate from "@/remote/activitypub/renderer/create.js"; -import renderAnnounce from "@/remote/activitypub/renderer/announce.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import { resolveUser } from "@/remote/resolve-user.js"; import config from "@/config/index.js"; -import { updateHashtags } from "@/services/update-hashtag.js"; -import { concat } from "@/prelude/array.js"; -import { insertNoteUnread } from "@/services/note/unread.js"; -import { registerOrFetchInstanceDoc } from "@/services/register-or-fetch-instance-doc.js"; -import { extractMentions } from "@/misc/extract-mentions.js"; -import { extractCustomEmojisFromMfm } from "@/misc/extract-custom-emojis-from-mfm.js"; -import { extractHashtags } from "@/misc/extract-hashtags.js"; -import type { IMentionedRemoteUsers } from "@/models/entities/note.js"; -import { Note } from "@/models/entities/note.js"; -import { - Followings, - Mutings, - Users, - NoteWatchings, - Notes, - Instances, - UserProfiles, - MutedNotes, - Channels, - ChannelFollowings, - NoteThreadMutings, -} from "@/models/index.js"; -import type { DriveFile } from "@/models/entities/drive-file.js"; -import type { App } from "@/models/entities/app.js"; -import { Not, In } from "typeorm"; -import type { User, ILocalUser, IRemoteUser } from "@/models/entities/user.js"; -import { genId } from "@/misc/gen-id.js"; -import { activeUsersChart } from "@/services/chart/index.js"; -import type { IPoll } from "@/models/entities/poll.js"; -import { Poll } from "@/models/entities/poll.js"; -import { createNotification } from "@/services/create-notification.js"; -import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; +import es from "@/db/elasticsearch.js"; +import meilisearch from "@/db/meilisearch.js"; +import { db } from "@/db/postgre.js"; +import { redisClient } from "@/db/redis.js"; +import sonic from "@/db/sonic.js"; +import { getAntennas } from "@/misc/antenna-cache.js"; +import { Cache } from "@/misc/cache.js"; import { checkHitAntenna } from "@/misc/check-hit-antenna.js"; import { getWordHardMute } from "@/misc/check-word-mute.js"; -import { addNoteToAntenna } from "@/services/add-note-to-antenna.js"; import { countSameRenotes } from "@/misc/count-same-renotes.js"; -import { deliverToRelays, getCachedRelays } from "../relay.js"; -import type { Channel } from "@/models/entities/channel.js"; -import { normalizeForSearch } from "@/misc/normalize-for-search.js"; -import { getAntennas } from "@/misc/antenna-cache.js"; -import { endedPollNotificationQueue } from "@/queue/queues.js"; -import { webhookDeliver } from "@/queue/index.js"; -import { Cache } from "@/misc/cache.js"; -import type { UserProfile } from "@/models/entities/user-profile.js"; -import { db } from "@/db/postgre.js"; -import { getActiveWebhooks } from "@/misc/webhook-cache.js"; -import { shouldSilenceInstance } from "@/misc/should-block-instance.js"; -import meilisearch from "@/db/meilisearch.js"; -import { redisClient } from "@/db/redis.js"; -import { Mutex } from "redis-semaphore"; -import { langmap } from "@/misc/langmap.js"; import detectLanguage from "@/misc/detect-language.js"; +import { extractCustomEmojisFromMfm } from "@/misc/extract-custom-emojis-from-mfm.js"; +import { extractHashtags } from "@/misc/extract-hashtags.js"; +import { extractMentions } from "@/misc/extract-mentions.js"; +import { genId } from "@/misc/gen-id.js"; +import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; +import { langmap } from "@/misc/langmap.js"; +import { normalizeForSearch } from "@/misc/normalize-for-search.js"; +import { shouldSilenceInstance } from "@/misc/should-block-instance.js"; +import { getActiveWebhooks } from "@/misc/webhook-cache.js"; +import type { App } from "@/models/entities/app.js"; +import type { Channel } from "@/models/entities/channel.js"; +import type { DriveFile } from "@/models/entities/drive-file.js"; +import type { IMentionedRemoteUsers } from "@/models/entities/note.js"; +import { Note } from "@/models/entities/note.js"; +import type { IPoll } from "@/models/entities/poll.js"; +import { Poll } from "@/models/entities/poll.js"; +import type { UserProfile } from "@/models/entities/user-profile.js"; +import type { ILocalUser, IRemoteUser, User } from "@/models/entities/user.js"; +import { + ChannelFollowings, + Channels, + Followings, + Instances, + MutedNotes, + Mutings, + NoteThreadMutings, + NoteWatchings, + Notes, + UserProfiles, + Users, +} from "@/models/index.js"; +import { concat } from "@/prelude/array.js"; +import { webhookDeliver } from "@/queue/index.js"; +import { endedPollNotificationQueue } from "@/queue/queues.js"; +import DeliverManager from "@/remote/activitypub/deliver-manager.js"; +import renderAnnounce from "@/remote/activitypub/renderer/announce.js"; +import renderCreate from "@/remote/activitypub/renderer/create.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import renderNote from "@/remote/activitypub/renderer/note.js"; +import { resolveUser } from "@/remote/resolve-user.js"; +import { addNoteToAntenna } from "@/services/add-note-to-antenna.js"; +import { activeUsersChart } from "@/services/chart/index.js"; +import { createNotification } from "@/services/create-notification.js"; +import { insertNoteUnread } from "@/services/note/unread.js"; +import { registerOrFetchInstanceDoc } from "@/services/register-or-fetch-instance-doc.js"; +import { + publishMainStream, + publishNoteStream, + publishNotesStream, +} from "@/services/stream.js"; +import { updateHashtags } from "@/services/update-hashtag.js"; +import * as mfm from "mfm-js"; +import { Mutex } from "redis-semaphore"; +import { In, Not } from "typeorm"; +import { deliverToRelays, getCachedRelays } from "../relay.js"; const mutedWordsCache = new Cache< { userId: UserProfile["userId"]; mutedWords: UserProfile["mutedWords"] }[] @@ -197,7 +197,7 @@ export default async ( const now = new Date(); if ( !data.createdAt || - isNaN(data.createdAt.getTime()) || + Number.isNaN(data.createdAt.getTime()) || data.createdAt > now ) data.createdAt = now; @@ -315,10 +315,10 @@ export default async ( if ( data.reply && user.id !== data.reply.userId && - !mentionedUsers.some((u) => u.id === data.reply!.userId) + !mentionedUsers.some((u) => u.id === data.reply?.userId) ) { mentionedUsers.push( - await Users.findOneByOrFail({ id: data.reply!.userId }), + await Users.findOneByOrFail({ id: data.reply?.userId }), ); } @@ -333,10 +333,10 @@ export default async ( if ( data.reply && - !data.visibleUsers.some((x) => x.id === data.reply!.userId) + !data.visibleUsers.some((x) => x.id === data.reply?.userId) ) { data.visibleUsers.push( - await Users.findOneByOrFail({ id: data.reply!.userId }), + await Users.findOneByOrFail({ id: data.reply?.userId }), ); } } @@ -545,7 +545,7 @@ export default async ( publishMainStream(data.reply.userId, "reply", packedReply); const webhooks = (await getActiveWebhooks()).filter( - (x) => x.userId === data.reply!.userId && x.on.includes("reply"), + (x) => x.userId === data.reply?.userId && x.on.includes("reply"), ); for (const webhook of webhooks) { webhookDeliver(webhook, "reply", { @@ -773,7 +773,10 @@ async function insertNote( await transactionalEntityManager.insert(Note, insert); let expiresAt: Date | null; - if (!data.poll.expiresAt || isNaN(data.poll.expiresAt.getTime())) { + if ( + !data.poll.expiresAt || + Number.isNaN(data.poll.expiresAt.getTime()) + ) { expiresAt = null; } else { expiresAt = data.poll.expiresAt; diff --git a/packages/backend/src/services/note/delete.ts b/packages/backend/src/services/note/delete.ts index f22fc35e..e3636e0d 100644 --- a/packages/backend/src/services/note/delete.ts +++ b/packages/backend/src/services/note/delete.ts @@ -1,22 +1,22 @@ -import { Brackets, In } from "typeorm"; -import { publishNoteStream } from "@/services/stream.js"; -import renderDelete from "@/remote/activitypub/renderer/delete.js"; -import renderAnnounce from "@/remote/activitypub/renderer/announce.js"; -import renderUndo from "@/remote/activitypub/renderer/undo.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import renderTombstone from "@/remote/activitypub/renderer/tombstone.js"; import config from "@/config/index.js"; -import type { User, ILocalUser, IRemoteUser } from "@/models/entities/user.js"; -import type { Note, IMentionedRemoteUsers } from "@/models/entities/note.js"; -import { Notes, Users, Instances } from "@/models/index.js"; +import meilisearch from "@/db/meilisearch.js"; +import { countSameRenotes } from "@/misc/count-same-renotes.js"; +import type { IMentionedRemoteUsers, Note } from "@/models/entities/note.js"; +import type { ILocalUser, IRemoteUser, User } from "@/models/entities/user.js"; +import { Instances, Notes, Users } from "@/models/index.js"; import { deliverToFollowers, deliverToUser, } from "@/remote/activitypub/deliver-manager.js"; -import { countSameRenotes } from "@/misc/count-same-renotes.js"; +import renderAnnounce from "@/remote/activitypub/renderer/announce.js"; +import renderDelete from "@/remote/activitypub/renderer/delete.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import renderTombstone from "@/remote/activitypub/renderer/tombstone.js"; +import renderUndo from "@/remote/activitypub/renderer/undo.js"; import { registerOrFetchInstanceDoc } from "@/services/register-or-fetch-instance-doc.js"; import { deliverToRelays } from "@/services/relay.js"; -import meilisearch from "@/db/meilisearch.js"; +import { publishNoteStream } from "@/services/stream.js"; +import { Brackets, In } from "typeorm"; /** * 投稿を削除します。 diff --git a/packages/backend/src/services/note/polls/update.ts b/packages/backend/src/services/note/polls/update.ts index 270b4d9b..07398022 100644 --- a/packages/backend/src/services/note/polls/update.ts +++ b/packages/backend/src/services/note/polls/update.ts @@ -1,9 +1,9 @@ -import renderUpdate from "@/remote/activitypub/renderer/update.js"; +import type { Note } from "@/models/entities/note.js"; +import { Notes, Users } from "@/models/index.js"; +import { deliverToFollowers } from "@/remote/activitypub/deliver-manager.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderNote from "@/remote/activitypub/renderer/note.js"; -import { Users, Notes } from "@/models/index.js"; -import type { Note } from "@/models/entities/note.js"; -import { deliverToFollowers } from "@/remote/activitypub/deliver-manager.js"; +import renderUpdate from "@/remote/activitypub/renderer/update.js"; import { deliverToRelays } from "@/services/relay.js"; export async function deliverQuestionUpdate(noteId: Note["id"]) { diff --git a/packages/backend/src/services/note/polls/vote.ts b/packages/backend/src/services/note/polls/vote.ts index 6ade8997..ebffed0d 100644 --- a/packages/backend/src/services/note/polls/vote.ts +++ b/packages/backend/src/services/note/polls/vote.ts @@ -1,10 +1,10 @@ -import { publishNoteStream } from "@/services/stream.js"; -import type { CacheableUser } from "@/models/entities/user.js"; -import type { Note } from "@/models/entities/note.js"; -import { PollVotes, NoteWatchings, Polls, Blockings } from "@/models/index.js"; -import { Not } from "typeorm"; import { genId } from "@/misc/gen-id.js"; +import type { Note } from "@/models/entities/note.js"; +import type { CacheableUser } from "@/models/entities/user.js"; +import { Blockings, NoteWatchings, PollVotes, Polls } from "@/models/index.js"; import { createNotification } from "@/services/create-notification.js"; +import { publishNoteStream } from "@/services/stream.js"; +import { Not } from "typeorm"; export default async function ( user: CacheableUser, diff --git a/packages/backend/src/services/note/reaction/create.ts b/packages/backend/src/services/note/reaction/create.ts index 1ea4b45e..cdbd0369 100644 --- a/packages/backend/src/services/note/reaction/create.ts +++ b/packages/backend/src/services/note/reaction/create.ts @@ -1,25 +1,25 @@ -import { publishNoteStream } from "@/services/stream.js"; -import { renderLike } from "@/remote/activitypub/renderer/like.js"; -import DeliverManager from "@/remote/activitypub/deliver-manager.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import { toDbReaction, decodeReaction } from "@/misc/reaction-lib.js"; -import type { User, IRemoteUser } from "@/models/entities/user.js"; +import { genId } from "@/misc/gen-id.js"; +import { IdentifiableError } from "@/misc/identifiable-error.js"; +import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; +import { decodeReaction, toDbReaction } from "@/misc/reaction-lib.js"; +import type { NoteReaction } from "@/models/entities/note-reaction.js"; import type { Note } from "@/models/entities/note.js"; +import type { IRemoteUser, User } from "@/models/entities/user.js"; import { + Blockings, + Emojis, NoteReactions, - Users, NoteWatchings, Notes, - Emojis, - Blockings, + Users, } from "@/models/index.js"; -import { IsNull, Not } from "typeorm"; -import { genId } from "@/misc/gen-id.js"; +import DeliverManager from "@/remote/activitypub/deliver-manager.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import { renderLike } from "@/remote/activitypub/renderer/like.js"; import { createNotification } from "@/services/create-notification.js"; +import { publishNoteStream } from "@/services/stream.js"; +import { IsNull, Not } from "typeorm"; import deleteReaction from "./delete.js"; -import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; -import type { NoteReaction } from "@/models/entities/note-reaction.js"; -import { IdentifiableError } from "@/misc/identifiable-error.js"; export default async ( user: { id: User["id"]; host: User["host"] }, diff --git a/packages/backend/src/services/note/reaction/delete.ts b/packages/backend/src/services/note/reaction/delete.ts index 15c6d1cf..159d86f4 100644 --- a/packages/backend/src/services/note/reaction/delete.ts +++ b/packages/backend/src/services/note/reaction/delete.ts @@ -1,13 +1,13 @@ -import { publishNoteStream } from "@/services/stream.js"; +import { IdentifiableError } from "@/misc/identifiable-error.js"; +import { decodeReaction } from "@/misc/reaction-lib.js"; +import type { Note } from "@/models/entities/note.js"; +import type { IRemoteUser, User } from "@/models/entities/user.js"; +import { NoteReactions, Notes, Users } from "@/models/index.js"; +import DeliverManager from "@/remote/activitypub/deliver-manager.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import { renderLike } from "@/remote/activitypub/renderer/like.js"; import renderUndo from "@/remote/activitypub/renderer/undo.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import DeliverManager from "@/remote/activitypub/deliver-manager.js"; -import { IdentifiableError } from "@/misc/identifiable-error.js"; -import type { User, IRemoteUser } from "@/models/entities/user.js"; -import type { Note } from "@/models/entities/note.js"; -import { NoteReactions, Users, Notes } from "@/models/index.js"; -import { decodeReaction } from "@/misc/reaction-lib.js"; +import { publishNoteStream } from "@/services/stream.js"; export default async ( user: { id: User["id"]; host: User["host"] }, diff --git a/packages/backend/src/services/note/read.ts b/packages/backend/src/services/note/read.ts index 73c58640..9f91faf2 100644 --- a/packages/backend/src/services/note/read.ts +++ b/packages/backend/src/services/note/read.ts @@ -1,16 +1,16 @@ -import { publishMainStream } from "@/services/stream.js"; +import type { Packed } from "@/misc/schema.js"; +import type { Channel } from "@/models/entities/channel.js"; import type { Note } from "@/models/entities/note.js"; import type { User } from "@/models/entities/user.js"; import { + ChannelFollowings, + Followings, NoteUnreads, Users, - Followings, - ChannelFollowings, } from "@/models/index.js"; -import { Not, IsNull, In } from "typeorm"; -import type { Channel } from "@/models/entities/channel.js"; import { readNotificationByQuery } from "@/server/api/common/read-notification.js"; -import type { Packed } from "@/misc/schema.js"; +import { publishMainStream } from "@/services/stream.js"; +import { In, IsNull, Not } from "typeorm"; /** * Mark notes as read diff --git a/packages/backend/src/services/note/unread.ts b/packages/backend/src/services/note/unread.ts index cb87abe0..6825ee7c 100644 --- a/packages/backend/src/services/note/unread.ts +++ b/packages/backend/src/services/note/unread.ts @@ -1,8 +1,8 @@ +import { genId } from "@/misc/gen-id.js"; import type { Note } from "@/models/entities/note.js"; -import { publishMainStream } from "@/services/stream.js"; import type { User } from "@/models/entities/user.js"; import { Mutings, NoteThreadMutings, NoteUnreads } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; +import { publishMainStream } from "@/services/stream.js"; export async function insertNoteUnread( userId: User["id"], diff --git a/packages/backend/src/services/note/unwatch.ts b/packages/backend/src/services/note/unwatch.ts index b4da5e86..0b2e4228 100644 --- a/packages/backend/src/services/note/unwatch.ts +++ b/packages/backend/src/services/note/unwatch.ts @@ -1,6 +1,6 @@ +import type { Note } from "@/models/entities/note.js"; import type { User } from "@/models/entities/user.js"; import { NoteWatchings } from "@/models/index.js"; -import type { Note } from "@/models/entities/note.js"; export default async (me: User["id"], note: Note) => { await NoteWatchings.delete({ diff --git a/packages/backend/src/services/note/watch.ts b/packages/backend/src/services/note/watch.ts index 2a99dd69..c69efe68 100644 --- a/packages/backend/src/services/note/watch.ts +++ b/packages/backend/src/services/note/watch.ts @@ -1,8 +1,8 @@ -import type { User } from "@/models/entities/user.js"; -import type { Note } from "@/models/entities/note.js"; -import { NoteWatchings } from "@/models/index.js"; import { genId } from "@/misc/gen-id.js"; import type { NoteWatching } from "@/models/entities/note-watching.js"; +import type { Note } from "@/models/entities/note.js"; +import type { User } from "@/models/entities/user.js"; +import { NoteWatchings } from "@/models/index.js"; export default async (me: User["id"], note: Note) => { // 自分の投稿はwatchできない diff --git a/packages/backend/src/services/push-notification.ts b/packages/backend/src/services/push-notification.ts index a207fae3..1e0486ff 100644 --- a/packages/backend/src/services/push-notification.ts +++ b/packages/backend/src/services/push-notification.ts @@ -1,9 +1,9 @@ -import push from "web-push"; import config from "@/config/index.js"; -import { SwSubscriptions } from "@/models/index.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; -import type { Packed } from "@/misc/schema.js"; import { getNoteSummary } from "@/misc/get-note-summary.js"; +import type { Packed } from "@/misc/schema.js"; +import { SwSubscriptions } from "@/models/index.js"; +import push from "web-push"; // Defined also packages/sw/types.ts#L14-L21 type pushNotificationsTypes = { diff --git a/packages/backend/src/services/register-or-fetch-instance-doc.ts b/packages/backend/src/services/register-or-fetch-instance-doc.ts index c0ead081..c56e609e 100644 --- a/packages/backend/src/services/register-or-fetch-instance-doc.ts +++ b/packages/backend/src/services/register-or-fetch-instance-doc.ts @@ -1,8 +1,8 @@ +import { Cache } from "@/misc/cache.js"; +import { toPuny } from "@/misc/convert-host.js"; +import { genId } from "@/misc/gen-id.js"; import type { Instance } from "@/models/entities/instance.js"; import { Instances } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; -import { toPuny } from "@/misc/convert-host.js"; -import { Cache } from "@/misc/cache.js"; const cache = new Cache("registerOrFetchInstanceDoc", 60 * 60); diff --git a/packages/backend/src/services/relay.ts b/packages/backend/src/services/relay.ts index fdc42616..20d93808 100644 --- a/packages/backend/src/services/relay.ts +++ b/packages/backend/src/services/relay.ts @@ -1,17 +1,17 @@ -import { IsNull } from "typeorm"; +import { Cache } from "@/misc/cache.js"; +import { genId } from "@/misc/gen-id.js"; +import type { Relay } from "@/models/entities/relay.js"; +import type { ILocalUser, User } from "@/models/entities/user.js"; +import { Relays, Users } from "@/models/index.js"; +import { deliver } from "@/queue/index.js"; import { renderFollowRelay } from "@/remote/activitypub/renderer/follow-relay.js"; import { - renderActivity, attachLdSignature, + renderActivity, } from "@/remote/activitypub/renderer/index.js"; import renderUndo from "@/remote/activitypub/renderer/undo.js"; -import { deliver } from "@/queue/index.js"; -import type { ILocalUser, User } from "@/models/entities/user.js"; -import { Users, Relays } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; -import { Cache } from "@/misc/cache.js"; -import type { Relay } from "@/models/entities/relay.js"; import { createSystemUser } from "@/services/create-system-user.js"; +import { IsNull } from "typeorm"; const ACTOR_USERNAME = "relay.actor" as const; diff --git a/packages/backend/src/services/send-email.ts b/packages/backend/src/services/send-email.ts index ccc6b365..7874af13 100644 --- a/packages/backend/src/services/send-email.ts +++ b/packages/backend/src/services/send-email.ts @@ -1,7 +1,7 @@ -import * as nodemailer from "nodemailer"; +import config from "@/config/index.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; import Logger from "@/services/logger.js"; -import config from "@/config/index.js"; +import * as nodemailer from "nodemailer"; export const logger = new Logger("email"); diff --git a/packages/backend/src/services/stream.ts b/packages/backend/src/services/stream.ts index f59674ad..518f3535 100644 --- a/packages/backend/src/services/stream.ts +++ b/packages/backend/src/services/stream.ts @@ -1,13 +1,12 @@ -import { redisClient } from "@/db/redis.js"; -import type { User } from "@/models/entities/user.js"; -import type { Note } from "@/models/entities/note.js"; -import type { UserList } from "@/models/entities/user-list.js"; -import type { UserGroup } from "@/models/entities/user-group.js"; import config from "@/config/index.js"; +import { redisClient } from "@/db/redis.js"; import type { Antenna } from "@/models/entities/antenna.js"; import type { Channel } from "@/models/entities/channel.js"; +import type { Note } from "@/models/entities/note.js"; +import type { UserGroup } from "@/models/entities/user-group.js"; +import type { UserList } from "@/models/entities/user-list.js"; +import type { User } from "@/models/entities/user.js"; import type { - StreamChannels, AdminStreamTypes, AntennaStreamTypes, BroadcastTypes, @@ -19,6 +18,7 @@ import type { MessagingIndexStreamTypes, MessagingStreamTypes, NoteStreamTypes, + StreamChannels, UserListStreamTypes, UserStreamTypes, } from "@/server/api/stream/types.js"; diff --git a/packages/backend/src/services/suspend-user.ts b/packages/backend/src/services/suspend-user.ts index f72b8ffc..919f6d0a 100644 --- a/packages/backend/src/services/suspend-user.ts +++ b/packages/backend/src/services/suspend-user.ts @@ -1,11 +1,11 @@ -import renderDelete from "@/remote/activitypub/renderer/delete.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import { deliver } from "@/queue/index.js"; import config from "@/config/index.js"; import type { User } from "@/models/entities/user.js"; -import { Users, Followings } from "@/models/index.js"; -import { Not, IsNull } from "typeorm"; +import { Followings, Users } from "@/models/index.js"; +import { deliver } from "@/queue/index.js"; +import renderDelete from "@/remote/activitypub/renderer/delete.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import { publishInternalEvent } from "@/services/stream.js"; +import { IsNull, Not } from "typeorm"; export async function doPostSuspend(user: { id: User["id"]; diff --git a/packages/backend/src/services/unsuspend-user.ts b/packages/backend/src/services/unsuspend-user.ts index 69447a4a..944ef18b 100644 --- a/packages/backend/src/services/unsuspend-user.ts +++ b/packages/backend/src/services/unsuspend-user.ts @@ -1,12 +1,12 @@ -import renderDelete from "@/remote/activitypub/renderer/delete.js"; -import renderUndo from "@/remote/activitypub/renderer/undo.js"; -import { renderActivity } from "@/remote/activitypub/renderer/index.js"; -import { deliver } from "@/queue/index.js"; import config from "@/config/index.js"; import type { User } from "@/models/entities/user.js"; -import { Users, Followings } from "@/models/index.js"; -import { Not, IsNull } from "typeorm"; +import { Followings, Users } from "@/models/index.js"; +import { deliver } from "@/queue/index.js"; +import renderDelete from "@/remote/activitypub/renderer/delete.js"; +import { renderActivity } from "@/remote/activitypub/renderer/index.js"; +import renderUndo from "@/remote/activitypub/renderer/undo.js"; import { publishInternalEvent } from "@/services/stream.js"; +import { IsNull, Not } from "typeorm"; export async function doPostUnsuspend(user: User) { publishInternalEvent("userChangeSuspendedState", { diff --git a/packages/backend/src/services/update-hashtag.ts b/packages/backend/src/services/update-hashtag.ts index a2b61664..8f1c8f61 100644 --- a/packages/backend/src/services/update-hashtag.ts +++ b/packages/backend/src/services/update-hashtag.ts @@ -1,8 +1,8 @@ +import { genId } from "@/misc/gen-id.js"; +import { normalizeForSearch } from "@/misc/normalize-for-search.js"; +import type { Hashtag } from "@/models/entities/hashtag.js"; import type { User } from "@/models/entities/user.js"; import { Hashtags, Users } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; -import type { Hashtag } from "@/models/entities/hashtag.js"; -import { normalizeForSearch } from "@/misc/normalize-for-search.js"; export async function updateHashtags( user: { id: User["id"]; host: User["host"] }, diff --git a/packages/backend/src/services/user-cache.ts b/packages/backend/src/services/user-cache.ts index ed700185..699d5edd 100644 --- a/packages/backend/src/services/user-cache.ts +++ b/packages/backend/src/services/user-cache.ts @@ -1,11 +1,11 @@ +import { redisClient, subscriber } from "@/db/redis.js"; +import { Cache } from "@/misc/cache.js"; import type { CacheableLocalUser, CacheableUser, ILocalUser, } from "@/models/entities/user.js"; import { Users } from "@/models/index.js"; -import { Cache } from "@/misc/cache.js"; -import { redisClient, subscriber } from "@/db/redis.js"; export const userByIdCache = new Cache("userById", 60 * 30); export const localUserByNativeTokenCache = new Cache( diff --git a/packages/backend/src/services/user-list/push.ts b/packages/backend/src/services/user-list/push.ts index db01b0a9..77181bf7 100644 --- a/packages/backend/src/services/user-list/push.ts +++ b/packages/backend/src/services/user-list/push.ts @@ -1,11 +1,11 @@ -import { publishUserListStream } from "@/services/stream.js"; -import type { User } from "@/models/entities/user.js"; -import type { UserList } from "@/models/entities/user-list.js"; -import { UserListJoinings, Users } from "@/models/index.js"; -import type { UserListJoining } from "@/models/entities/user-list-joining.js"; -import { genId } from "@/misc/gen-id.js"; import { fetchProxyAccount } from "@/misc/fetch-proxy-account.js"; +import { genId } from "@/misc/gen-id.js"; +import type { UserListJoining } from "@/models/entities/user-list-joining.js"; +import type { UserList } from "@/models/entities/user-list.js"; +import type { User } from "@/models/entities/user.js"; +import { UserListJoinings, Users } from "@/models/index.js"; import createFollowing from "@/services/following/create.js"; +import { publishUserListStream } from "@/services/stream.js"; export async function pushUserToUserList(target: User, list: UserList) { await UserListJoinings.insert({ diff --git a/packages/backend/src/services/validate-email-for-account.ts b/packages/backend/src/services/validate-email-for-account.ts index 2bb5e93e..419203f5 100644 --- a/packages/backend/src/services/validate-email-for-account.ts +++ b/packages/backend/src/services/validate-email-for-account.ts @@ -1,6 +1,6 @@ -import { validate as validateEmail } from "deep-email-validator"; -import { UserProfiles } from "@/models/index.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; +import { UserProfiles } from "@/models/index.js"; +import { validate as validateEmail } from "deep-email-validator"; export async function validateEmailForAccount(emailAddress: string): Promise<{ available: boolean; diff --git a/packages/client/src/account.ts b/packages/client/src/account.ts index 5844c5bd..249845f3 100644 --- a/packages/client/src/account.ts +++ b/packages/client/src/account.ts @@ -1,12 +1,12 @@ -import type * as firefish from "firefish-js"; -import { defineAsyncComponent } from "vue"; -import { i18n } from "./i18n"; import { apiUrl } from "@/config"; import { alert, api, popup, popupMenu, waiting } from "@/os"; import { $i } from "@/reactiveAccount"; import icon from "@/scripts/icon"; import { del, get, set } from "@/scripts/idb-proxy"; import { reloadChannel, unisonReload } from "@/scripts/unison-reload"; +import type * as firefish from "firefish-js"; +import { defineAsyncComponent } from "vue"; +import { i18n } from "./i18n"; // TODO: 他のタブと永続化されたstateを同期 diff --git a/packages/client/src/components/index.ts b/packages/client/src/components/index.ts index 6cf61617..9909424b 100644 --- a/packages/client/src/components/index.ts +++ b/packages/client/src/components/index.ts @@ -1,22 +1,22 @@ import type { App } from "vue"; -import Mfm from "./global/MkMisskeyFlavoredMarkdown.vue"; import MkA from "./global/MkA.vue"; import MkAcct from "./global/MkAcct.vue"; -import MkAvatar from "./global/MkAvatar.vue"; -import MkEmoji from "./global/MkEmoji.vue"; -import MkUserName from "./global/MkUserName.vue"; -import MkEllipsis from "./global/MkEllipsis.vue"; -import MkTime from "./global/MkTime.vue"; -import MkUrl from "./global/MkUrl.vue"; -import I18n from "./global/i18n"; -import RouterView from "./global/RouterView.vue"; -import MkLoading from "./global/MkLoading.vue"; -import MkError from "./global/MkError.vue"; import MkAd from "./global/MkAd.vue"; +import MkAvatar from "./global/MkAvatar.vue"; +import MkEllipsis from "./global/MkEllipsis.vue"; +import MkEmoji from "./global/MkEmoji.vue"; +import MkError from "./global/MkError.vue"; +import MkLoading from "./global/MkLoading.vue"; +import Mfm from "./global/MkMisskeyFlavoredMarkdown.vue"; import MkPageHeader from "./global/MkPageHeader.vue"; import MkSpacer from "./global/MkSpacer.vue"; import MkStickyContainer from "./global/MkStickyContainer.vue"; +import MkTime from "./global/MkTime.vue"; +import MkUrl from "./global/MkUrl.vue"; +import MkUserName from "./global/MkUserName.vue"; +import RouterView from "./global/RouterView.vue"; +import I18n from "./global/i18n"; export default function (app: App) { app.component("I18n", I18n); diff --git a/packages/client/src/components/mfm.ts b/packages/client/src/components/mfm.ts index 260be20e..fa70e36b 100644 --- a/packages/client/src/components/mfm.ts +++ b/packages/client/src/components/mfm.ts @@ -1,19 +1,19 @@ -import { defineComponent, h } from "vue"; -import * as mfm from "mfm-js"; -import type { VNode } from "vue"; -import MkUrl from "@/components/global/MkUrl.vue"; +import MkCode from "@/components/MkCode.vue"; +import MkFormula from "@/components/MkFormula.vue"; +import MkGoogle from "@/components/MkGoogle.vue"; import MkLink from "@/components/MkLink.vue"; import MkMention from "@/components/MkMention.vue"; -import MkEmoji from "@/components/global/MkEmoji.vue"; -import { concat } from "@/scripts/array"; -import MkFormula from "@/components/MkFormula.vue"; -import MkCode from "@/components/MkCode.vue"; -import MkGoogle from "@/components/MkGoogle.vue"; import MkSparkle from "@/components/MkSparkle.vue"; import MkA from "@/components/global/MkA.vue"; +import MkEmoji from "@/components/global/MkEmoji.vue"; +import MkUrl from "@/components/global/MkUrl.vue"; import { host } from "@/config"; +import { concat } from "@/scripts/array"; import { reducedMotion } from "@/scripts/reduced-motion"; import { defaultStore } from "@/store"; +import * as mfm from "mfm-js"; +import { defineComponent, h } from "vue"; +import type { VNode } from "vue"; export default defineComponent({ props: { @@ -61,7 +61,7 @@ export default defineComponent({ const validNumber = (n: string | null | undefined) => { if (n == null) return null; const parsed = parseFloat(n); - return !isNaN(parsed) && isFinite(parsed) && parsed > 0; + return !Number.isNaN(parsed) && Number.isFinite(parsed) && parsed > 0; }; // const validEase = (e: string | null | undefined) => { // if (e == null) return null; diff --git a/packages/client/src/directives/follow-append.ts b/packages/client/src/directives/follow-append.ts index 8c713f64..bf7223b8 100644 --- a/packages/client/src/directives/follow-append.ts +++ b/packages/client/src/directives/follow-append.ts @@ -1,5 +1,5 @@ -import type { Directive } from "vue"; import { getScrollContainer, getScrollPosition } from "@/scripts/scroll"; +import type { Directive } from "vue"; export default { mounted(src, binding, vn) { diff --git a/packages/client/src/directives/hotkey.ts b/packages/client/src/directives/hotkey.ts index 9e148cc0..9bdfe476 100644 --- a/packages/client/src/directives/hotkey.ts +++ b/packages/client/src/directives/hotkey.ts @@ -1,5 +1,5 @@ -import type { Directive } from "vue"; import { makeHotkey } from "@/scripts/hotkey"; +import type { Directive } from "vue"; export default { mounted(el, binding) { diff --git a/packages/client/src/directives/index.ts b/packages/client/src/directives/index.ts index 1758e536..0a08f13f 100644 --- a/packages/client/src/directives/index.ts +++ b/packages/client/src/directives/index.ts @@ -1,17 +1,17 @@ import type { App } from "vue"; -import userPreview from "./user-preview"; -import size from "./size"; -import getSize from "./get-size"; -import ripple from "./ripple"; -import tooltip from "./tooltip"; -import hotkey from "./hotkey"; -import appear from "./appear"; -import anim from "./anim"; -import clickAnime from "./click-anime"; -import panel from "./panel"; import adaptiveBorder from "./adaptive-border"; +import anim from "./anim"; +import appear from "./appear"; +import clickAnime from "./click-anime"; import focus from "./focus"; +import getSize from "./get-size"; +import hotkey from "./hotkey"; +import panel from "./panel"; +import ripple from "./ripple"; +import size from "./size"; +import tooltip from "./tooltip"; +import userPreview from "./user-preview"; import vibrate from "./vibrate"; export default function (app: App) { diff --git a/packages/client/src/directives/ripple.ts b/packages/client/src/directives/ripple.ts index bf364d12..efbc5ee5 100644 --- a/packages/client/src/directives/ripple.ts +++ b/packages/client/src/directives/ripple.ts @@ -1,6 +1,6 @@ -import type { Ref } from "vue"; import Ripple from "@/components/MkRipple.vue"; import { popup } from "@/os"; +import type { Ref } from "vue"; export default { mounted(el: HTMLElement, binding: Ref) { diff --git a/packages/client/src/directives/tooltip.ts b/packages/client/src/directives/tooltip.ts index 0b29b655..23172a02 100644 --- a/packages/client/src/directives/tooltip.ts +++ b/packages/client/src/directives/tooltip.ts @@ -1,11 +1,11 @@ // TODO: useTooltip関数使うようにしたい // ただディレクティブ内でonUnmountedなどのcomposition api使えるのか不明 -import type { Directive } from "vue"; -import { defineAsyncComponent, ref } from "vue"; -import { isTouchUsing } from "@/scripts/touch"; import { alert, popup } from "@/os"; import { mainRouter } from "@/router"; +import { isTouchUsing } from "@/scripts/touch"; +import type { Directive } from "vue"; +import { defineAsyncComponent, ref } from "vue"; const start = isTouchUsing ? "touchstart" : "mouseover"; const end = isTouchUsing ? "touchend" : "mouseleave"; diff --git a/packages/client/src/directives/user-preview.ts b/packages/client/src/directives/user-preview.ts index dbbdb8b0..6cbe97d9 100644 --- a/packages/client/src/directives/user-preview.ts +++ b/packages/client/src/directives/user-preview.ts @@ -1,6 +1,6 @@ +import { popup } from "@/os"; import type { Directive } from "vue"; import { defineAsyncComponent, ref } from "vue"; -import { popup } from "@/os"; export class UserPreview { private el; diff --git a/packages/client/src/directives/vibrate.ts b/packages/client/src/directives/vibrate.ts index 45bb6e76..f62e2a74 100644 --- a/packages/client/src/directives/vibrate.ts +++ b/packages/client/src/directives/vibrate.ts @@ -1,5 +1,5 @@ -import type { Directive } from "vue"; import { vibrate } from "@/scripts/vibrate"; +import type { Directive } from "vue"; export default { mounted(el, binding) { diff --git a/packages/client/src/filters/user.ts b/packages/client/src/filters/user.ts index 487ce215..08b5e3be 100644 --- a/packages/client/src/filters/user.ts +++ b/packages/client/src/filters/user.ts @@ -1,6 +1,6 @@ +import { url } from "@/config"; import type * as firefish from "firefish-js"; import * as Acct from "firefish-js/built/acct"; -import { url } from "@/config"; export const acct = (user: firefish.Acct) => { return Acct.toString(user); diff --git a/packages/client/src/i18n.ts b/packages/client/src/i18n.ts index 5b0a7f9e..31a6686f 100644 --- a/packages/client/src/i18n.ts +++ b/packages/client/src/i18n.ts @@ -1,6 +1,6 @@ -import { markRaw } from "vue"; import { locale } from "@/config"; import { I18n } from "@/scripts/i18n"; +import { markRaw } from "vue"; export const i18n = markRaw(new I18n(locale)); diff --git a/packages/client/src/init.ts b/packages/client/src/init.ts index 6aded592..97907b09 100644 --- a/packages/client/src/init.ts +++ b/packages/client/src/init.ts @@ -22,6 +22,7 @@ if (accounts) { } // #endregion +import { set } from "@/scripts/idb-proxy"; import { compareVersions } from "compare-versions"; import { computed, @@ -31,7 +32,6 @@ import { version as vueVersion, watch, } from "vue"; -import { set } from "@/scripts/idb-proxy"; import { login, refreshAccount, signout, updateAccount } from "@/account"; import components from "@/components"; diff --git a/packages/client/src/navbar.ts b/packages/client/src/navbar.ts index 55cfab5b..7a120c52 100644 --- a/packages/client/src/navbar.ts +++ b/packages/client/src/navbar.ts @@ -1,4 +1,3 @@ -import { computed, reactive } from "vue"; import { ui } from "@/config"; import { i18n } from "@/i18n"; import * as os from "@/os"; @@ -6,6 +5,7 @@ import { $i } from "@/reactiveAccount"; import icon from "@/scripts/icon"; import { search } from "@/scripts/search"; import { unisonReload } from "@/scripts/unison-reload"; +import { computed, reactive } from "vue"; export const navbarItemDef = reactive({ notifications: { diff --git a/packages/client/src/nirax.ts b/packages/client/src/nirax.ts index 800d4704..665304b8 100644 --- a/packages/client/src/nirax.ts +++ b/packages/client/src/nirax.ts @@ -1,10 +1,10 @@ // NIRAX --- A lightweight router +import { pleaseLogin } from "@/scripts/please-login"; +import { safeURIDecode } from "@/scripts/safe-uri-decode"; import { EventEmitter } from "eventemitter3"; import type { Component, ShallowRef } from "vue"; import { shallowRef } from "vue"; -import { safeURIDecode } from "@/scripts/safe-uri-decode"; -import { pleaseLogin } from "@/scripts/please-login"; interface RouteDef { path: string; @@ -93,8 +93,8 @@ export class Router extends EventEmitter<{ } public resolve(path: string): Resolved | null { - let queryString: string | null = null, - hash: string | null = null; + let queryString: string | null = null; + let hash: string | null = null; if (path[0] === "/") path = path.substring(1); if (path.includes("#")) { hash = path.substring(path.indexOf("#") + 1); diff --git a/packages/client/src/os.ts b/packages/client/src/os.ts index d367dc2f..90f4bac2 100644 --- a/packages/client/src/os.ts +++ b/packages/client/src/os.ts @@ -1,18 +1,18 @@ // TODO: なんでもかんでもos.tsに突っ込むのやめたいのでよしなに分割する +import MkDialog from "@/components/MkDialog.vue"; +import MkPostFormDialog from "@/components/MkPostFormDialog.vue"; +import MkToast from "@/components/MkToast.vue"; +import MkWaitingDialog from "@/components/MkWaitingDialog.vue"; +import { url, apiUrl } from "@/config"; +import { $i } from "@/reactiveAccount"; +import type { MenuItem } from "@/types/menu"; import { EventEmitter } from "eventemitter3"; import * as firefish from "firefish-js"; import insertTextAtCursor from "insert-text-at-cursor"; import type { Component, Ref } from "vue"; import { defineAsyncComponent, markRaw, ref } from "vue"; import { i18n } from "./i18n"; -import MkDialog from "@/components/MkDialog.vue"; -import MkPostFormDialog from "@/components/MkPostFormDialog.vue"; -import MkToast from "@/components/MkToast.vue"; -import MkWaitingDialog from "@/components/MkWaitingDialog.vue"; -import { apiUrl, url } from "@/config"; -import { $i } from "@/reactiveAccount"; -import type { MenuItem } from "@/types/menu"; export const pendingApiRequestsCount = ref(0); @@ -118,7 +118,7 @@ export const apiWithDialog = (( promiseDialog(promise, null, (err) => { alert({ type: "error", - text: err.message + "\n" + (err as any).id, + text: `${err.message}\n${(err as any).id}`, }); }); @@ -196,7 +196,7 @@ export function claimZIndex( let uniqueId = 0; export function getUniqueId(): string { - return uniqueId++ + ""; + return `${uniqueId++}`; } export async function popup( @@ -776,10 +776,10 @@ type AwaitType = T extends Promise : T extends (...args: any[]) => Promise ? V : T; -let openingEmojiPicker: AwaitType> | null = null, - activeTextarea: HTMLTextAreaElement | HTMLInputElement | null = null; +let openingEmojiPicker: AwaitType> | null = null; +let activeTextarea: HTMLTextAreaElement | HTMLInputElement | null = null; export async function openEmojiPicker( - src?: HTMLElement, + src: HTMLElement, opts, initialTextarea: typeof activeTextarea, ) { @@ -837,7 +837,7 @@ export async function openEmojiPicker( insertTextAtCursor(activeTextarea, emoji); }, closed: () => { - openingEmojiPicker!.dispose(); + openingEmojiPicker?.dispose(); openingEmojiPicker = null; observer.disconnect(); }, diff --git a/packages/client/src/pizzax.ts b/packages/client/src/pizzax.ts index a16c8067..489a740e 100644 --- a/packages/client/src/pizzax.ts +++ b/packages/client/src/pizzax.ts @@ -1,10 +1,10 @@ // PIZZAX --- A lightweight store +import { $i } from "@/reactiveAccount"; import type { Ref } from "vue"; import { onUnmounted, ref, watch } from "vue"; import { api } from "./os"; import { stream } from "./stream"; -import { $i } from "@/reactiveAccount"; type StateDef = Record< string, diff --git a/packages/client/src/plugin.ts b/packages/client/src/plugin.ts index c38aaa36..2789cc79 100644 --- a/packages/client/src/plugin.ts +++ b/packages/client/src/plugin.ts @@ -1,4 +1,3 @@ -import { Interpreter, Parser, utils, values } from "@syuilo/aiscript"; import { inputText } from "@/os"; import { createAiScriptEnv } from "@/scripts/aiscript/api"; import { @@ -8,6 +7,7 @@ import { postFormActions, userActions, } from "@/store"; +import { Interpreter, Parser, utils, values } from "@syuilo/aiscript"; const parser = new Parser(); const pluginContexts = new Map(); diff --git a/packages/client/src/reactiveAccount.ts b/packages/client/src/reactiveAccount.ts index 46ff2499..c192cdb7 100644 --- a/packages/client/src/reactiveAccount.ts +++ b/packages/client/src/reactiveAccount.ts @@ -1,5 +1,5 @@ -import { reactive } from "vue"; import type { Account } from "@/account"; +import { reactive } from "vue"; const accountData = localStorage.getItem("account"); diff --git a/packages/client/src/router.ts b/packages/client/src/router.ts index abc61368..b7fed0a0 100644 --- a/packages/client/src/router.ts +++ b/packages/client/src/router.ts @@ -1,10 +1,10 @@ -import type { AsyncComponentLoader } from "vue"; -import { defineAsyncComponent, inject } from "vue"; import { iAmEmojiMod, iAmModerator } from "@/account"; import { Router } from "@/nirax"; import MkError from "@/pages/_error_.vue"; import MkLoading from "@/pages/_loading_.vue"; import { $i } from "@/reactiveAccount"; +import type { AsyncComponentLoader } from "vue"; +import { defineAsyncComponent, inject } from "vue"; // import { api } from "@/os"; // function getGuestTimelineStatus() { diff --git a/packages/client/src/scripts/aiscript/api.ts b/packages/client/src/scripts/aiscript/api.ts index e0eed05c..d6beee58 100644 --- a/packages/client/src/scripts/aiscript/api.ts +++ b/packages/client/src/scripts/aiscript/api.ts @@ -1,6 +1,6 @@ -import { utils, values } from "@syuilo/aiscript"; import * as os from "@/os"; import { $i } from "@/reactiveAccount"; +import { utils, values } from "@syuilo/aiscript"; export function createAiScriptEnv(opts) { let apiRequests = 0; diff --git a/packages/client/src/scripts/autocomplete.ts b/packages/client/src/scripts/autocomplete.ts index 18e56ba3..9ffd7119 100644 --- a/packages/client/src/scripts/autocomplete.ts +++ b/packages/client/src/scripts/autocomplete.ts @@ -1,8 +1,8 @@ +import { popup } from "@/os"; +import { toASCII } from "punycode/"; +import getCaretCoordinates from "textarea-caret"; import type { Ref } from "vue"; import { defineAsyncComponent, nextTick, ref } from "vue"; -import getCaretCoordinates from "textarea-caret"; -import { toASCII } from "punycode/"; -import { popup } from "@/os"; export class Autocomplete { private suggestion: { @@ -91,8 +91,8 @@ export class Autocomplete { emojiIndex !== -1 && text .split(/:[a-z0-9_+\-]+:/) - .pop()! - .includes(":"); + .pop() + ?.includes(":"); let opened = false; diff --git a/packages/client/src/scripts/chiptune2.ts b/packages/client/src/scripts/chiptune2.ts index 2f62428f..5904f37f 100644 --- a/packages/client/src/scripts/chiptune2.ts +++ b/packages/client/src/scripts/chiptune2.ts @@ -309,9 +309,9 @@ ChiptuneJsPlayer.prototype.createLibopenmptNode = async function ( } return; } - let framesRendered = 0, - ended = false, - error = false; + let framesRendered = 0; + let ended = false; + let error = false; const currentPattern = processNode.player.libopenmpt._openmpt_module_get_current_pattern( diff --git a/packages/client/src/scripts/detect-language.ts b/packages/client/src/scripts/detect-language.ts index 6147247d..15763d5a 100644 --- a/packages/client/src/scripts/detect-language.ts +++ b/packages/client/src/scripts/detect-language.ts @@ -1,5 +1,5 @@ -import { detect } from "tinyld"; import * as mfm from "mfm-js"; +import { detect } from "tinyld"; export default function detectLanguage(text: string): string { const nodes = mfm.parse(text); diff --git a/packages/client/src/scripts/emojilist.ts b/packages/client/src/scripts/emojilist.ts index 8a2ade12..c26ab2af 100644 --- a/packages/client/src/scripts/emojilist.ts +++ b/packages/client/src/scripts/emojilist.ts @@ -1,8 +1,8 @@ +import { defaultStore } from "@/store"; +import keywordSet from "emojilib"; +import individualData from "unicode-emoji-json/data-by-emoji.json"; import data from "unicode-emoji-json/data-by-group.json"; import emojiComponents from "unicode-emoji-json/data-emoji-components.json"; -import individualData from "unicode-emoji-json/data-by-emoji.json"; -import keywordSet from "emojilib"; -import { defaultStore } from "@/store"; export interface UnicodeEmojiDef { emoji: string; diff --git a/packages/client/src/scripts/extract-url-from-mfm.ts b/packages/client/src/scripts/extract-url-from-mfm.ts index 0c580b6d..0c32e81b 100644 --- a/packages/client/src/scripts/extract-url-from-mfm.ts +++ b/packages/client/src/scripts/extract-url-from-mfm.ts @@ -1,5 +1,5 @@ -import * as mfm from "mfm-js"; import { unique } from "@/scripts/array"; +import * as mfm from "mfm-js"; // unique without hash // [ http://a/#1, http://a/#2, http://b/#3 ] => [ http://a/#1, http://b/#3 ] diff --git a/packages/client/src/scripts/gen-search-query.ts b/packages/client/src/scripts/gen-search-query.ts index 21870e69..6facff31 100644 --- a/packages/client/src/scripts/gen-search-query.ts +++ b/packages/client/src/scripts/gen-search-query.ts @@ -1,8 +1,9 @@ -import * as Acct from "firefish-js/built/acct"; import { host as localHost } from "@/config"; +import * as Acct from "firefish-js/built/acct"; export async function genSearchQuery(v: any, q: string) { - let host: string, userId: string; + let host: string; + let userId: string; if (q.split(" ").some((x) => x.startsWith("@"))) { for (const at of q .split(" ") diff --git a/packages/client/src/scripts/get-note-menu.ts b/packages/client/src/scripts/get-note-menu.ts index f8858bae..0fb61480 100644 --- a/packages/client/src/scripts/get-note-menu.ts +++ b/packages/client/src/scripts/get-note-menu.ts @@ -1,16 +1,16 @@ -import type { Ref } from "vue"; -import { defineAsyncComponent } from "vue"; -import type * as firefish from "firefish-js"; -import { $i } from "@/reactiveAccount"; +import { url } from "@/config"; import { i18n } from "@/i18n"; import { instance } from "@/instance"; import * as os from "@/os"; +import { $i } from "@/reactiveAccount"; import copyToClipboard from "@/scripts/copy-to-clipboard"; -import { url } from "@/config"; -import { noteActions } from "@/store"; -import { shareAvailable } from "@/scripts/share-available"; import { getUserMenu } from "@/scripts/get-user-menu"; import icon from "@/scripts/icon"; +import { shareAvailable } from "@/scripts/share-available"; +import { noteActions } from "@/store"; +import type * as firefish from "firefish-js"; +import type { Ref } from "vue"; +import { defineAsyncComponent } from "vue"; export function getNoteMenu(props: { note: firefish.entities.Note; @@ -209,7 +209,7 @@ export function getNoteMenu(props: { } else { os.alert({ type: "error", - text: err.message + "\n" + err.id, + text: `${err.message}\n${err.id}`, }); } }, diff --git a/packages/client/src/scripts/get-user-menu.ts b/packages/client/src/scripts/get-user-menu.ts index e9a6ca56..75ba2c53 100644 --- a/packages/client/src/scripts/get-user-menu.ts +++ b/packages/client/src/scripts/get-user-menu.ts @@ -1,15 +1,15 @@ -import * as Acct from "firefish-js/built/acct"; -import { defineAsyncComponent } from "vue"; -import { i18n } from "@/i18n"; -import copyToClipboard from "@/scripts/copy-to-clipboard"; -import { host } from "@/config"; -import * as os from "@/os"; -import { userActions } from "@/store"; import { iAmModerator } from "@/account"; +import { host } from "@/config"; +import { i18n } from "@/i18n"; +import type { Router } from "@/nirax"; +import * as os from "@/os"; import { $i } from "@/reactiveAccount"; import { mainRouter } from "@/router"; -import type { Router } from "@/nirax"; +import copyToClipboard from "@/scripts/copy-to-clipboard"; import icon from "@/scripts/icon"; +import { userActions } from "@/store"; +import * as Acct from "firefish-js/built/acct"; +import { defineAsyncComponent } from "vue"; export function getUserMenu(user, router: Router = mainRouter) { const meId = $i ? $i.id : null; diff --git a/packages/client/src/scripts/helpMenu.ts b/packages/client/src/scripts/helpMenu.ts index 2291afa7..7333e23c 100644 --- a/packages/client/src/scripts/helpMenu.ts +++ b/packages/client/src/scripts/helpMenu.ts @@ -1,11 +1,11 @@ -import XTutorial from "@/components/MkTutorialDialog.vue"; import XCheatSheet from "@/components/MkCheatSheetDialog.vue"; -import { defaultStore } from "@/store"; -import { instance } from "@/instance"; +import XTutorial from "@/components/MkTutorialDialog.vue"; import { host } from "@/config"; -import * as os from "@/os"; import { i18n } from "@/i18n"; +import { instance } from "@/instance"; +import * as os from "@/os"; import icon from "@/scripts/icon"; +import { defaultStore } from "@/store"; import type { MenuItem } from "@/types/menu"; const instanceSpecificItems: MenuItem[] = []; diff --git a/packages/client/src/scripts/hotkey.ts b/packages/client/src/scripts/hotkey.ts index 4aa6f1b0..01ace094 100644 --- a/packages/client/src/scripts/hotkey.ts +++ b/packages/client/src/scripts/hotkey.ts @@ -83,7 +83,7 @@ export const makeHotkey = (keymap: Keymap) => { return (ev: KeyboardEvent) => { if (document.activeElement) { - if (ignoreElemens.some((el) => document.activeElement!.matches(el))) + if (ignoreElemens.some((el) => document.activeElement?.matches(el))) return; if (document.activeElement.attributes.contenteditable) return; } diff --git a/packages/client/src/scripts/hpml/evaluator.ts b/packages/client/src/scripts/hpml/evaluator.ts index ba06a874..04b179ef 100644 --- a/packages/client/src/scripts/hpml/evaluator.ts +++ b/packages/client/src/scripts/hpml/evaluator.ts @@ -1,16 +1,16 @@ -import autobind from "autobind-decorator"; +import { version } from "@/config"; +import * as os from "@/os"; import { Interpreter, utils, values } from "@syuilo/aiscript"; +import autobind from "autobind-decorator"; import type { Ref } from "vue"; import { markRaw, ref, unref } from "vue"; -import { collectPageVars } from "../collect-page-vars"; -import { createAiScriptEnv } from "../aiscript/api"; -import { initAiLib, initHpmlLib } from "./lib"; -import type { Expr, Variable } from "./expr"; -import { isLiteralValue } from "./expr"; import { HpmlError, HpmlScope } from "."; import type { Fn, PageVar, envVarsDef } from "."; -import * as os from "@/os"; -import { version } from "@/config"; +import { createAiScriptEnv } from "../aiscript/api"; +import { collectPageVars } from "../collect-page-vars"; +import type { Expr, Variable } from "./expr"; +import { isLiteralValue } from "./expr"; +import { initAiLib, initHpmlLib } from "./lib"; /** * Hpml evaluator diff --git a/packages/client/src/scripts/hpml/index.ts b/packages/client/src/scripts/hpml/index.ts index a1201431..224ad29a 100644 --- a/packages/client/src/scripts/hpml/index.ts +++ b/packages/client/src/scripts/hpml/index.ts @@ -2,10 +2,10 @@ * Hpml */ +import icon from "@/scripts/icon"; import autobind from "autobind-decorator"; import type { Hpml } from "./evaluator"; import { funcDefs } from "./lib"; -import icon from "@/scripts/icon"; export interface Fn { slots: string[]; diff --git a/packages/client/src/scripts/hpml/lib.ts b/packages/client/src/scripts/hpml/lib.ts index 0a2226be..097cc2cb 100644 --- a/packages/client/src/scripts/hpml/lib.ts +++ b/packages/client/src/scripts/hpml/lib.ts @@ -1,9 +1,9 @@ +import icon from "@/scripts/icon"; import { utils, values } from "@syuilo/aiscript"; import seedrandom from "seedrandom"; +import type { Fn, HpmlScope } from "."; import type { Hpml } from "./evaluator"; import type { Expr } from "./expr"; -import type { Fn, HpmlScope } from "."; -import icon from "@/scripts/icon"; /* TODO: https://www.chartjs.org/docs/latest/configuration/canvas-background.html#color // https://stackoverflow.com/questions/38493564/chart-area-background-color-chartjs diff --git a/packages/client/src/scripts/hpml/type-checker.ts b/packages/client/src/scripts/hpml/type-checker.ts index fd9d7205..7299528d 100644 --- a/packages/client/src/scripts/hpml/type-checker.ts +++ b/packages/client/src/scripts/hpml/type-checker.ts @@ -1,9 +1,9 @@ import autobind from "autobind-decorator"; +import { envVarsDef } from "."; +import type { PageVar, Type } from "."; import type { Expr, Variable } from "./expr"; import { isLiteralValue } from "./expr"; import { funcDefs } from "./lib"; -import { envVarsDef } from "."; -import type { PageVar, Type } from "."; interface TypeError { arg: number; diff --git a/packages/client/src/scripts/init-chart.ts b/packages/client/src/scripts/init-chart.ts index 56fd1e35..d282f8df 100644 --- a/packages/client/src/scripts/init-chart.ts +++ b/packages/client/src/scripts/init-chart.ts @@ -1,3 +1,4 @@ +import { defaultStore } from "@/store"; import { ArcElement, BarController, @@ -16,11 +17,10 @@ import { Title, Tooltip, } from "chart.js"; +import "chartjs-adapter-date-fns"; +import { MatrixController, MatrixElement } from "chartjs-chart-matrix"; import gradient from "chartjs-plugin-gradient"; import zoomPlugin from "chartjs-plugin-zoom"; -import { MatrixController, MatrixElement } from "chartjs-chart-matrix"; -import { defaultStore } from "@/store"; -import "chartjs-adapter-date-fns"; export function initChart() { Chart.register( diff --git a/packages/client/src/scripts/katex-macro.ts b/packages/client/src/scripts/katex-macro.ts index fdf6a0bd..826d9f53 100644 --- a/packages/client/src/scripts/katex-macro.ts +++ b/packages/client/src/scripts/katex-macro.ts @@ -61,8 +61,8 @@ function parseSingleKaTeXMacro(src: string): [string, KaTeXMacro] { currentPos = skipSpaces(currentPos); while (currentPos < src.length - 1) { - let numbersignPos = -1, - isEscaped = false; + let numbersignPos = -1; + let isEscaped = false; for (let i = currentPos; i < src.length - 1; ++i) { if (src[i] !== "\\" && src[i] !== "#") { @@ -210,15 +210,15 @@ function expandKaTeXMacroOnce( --maxNumberOfExpansions; // search for a custom macro - let checkedPos = beginPos - 1, - macroName = "", - macroBackslashPos = 0, - // for macros w/o args: unused - // w/ args: the first open bracket ("(", "{", or "[") after cmd name - macroArgBeginPos = 0, - // for macros w/o args: the end of cmd name - // w/ args: the closing bracket of the last arg - macroArgEndPos = 0; + let checkedPos = beginPos - 1; + let macroName = ""; + let macroBackslashPos = 0; + // for macros w/o args: unused + // w/ args: the first open bracket ("(", "{", or "[") after cmd name + let macroArgBeginPos = 0; + // for macros w/o args: the end of cmd name + // w/ args: the closing bracket of the last arg + let macroArgEndPos = 0; while (checkedPos < endPos) { checkedPos = src.indexOf("\\", checkedPos + 1); diff --git a/packages/client/src/scripts/lookup-user.ts b/packages/client/src/scripts/lookup-user.ts index a0e89ca5..4cd9878d 100644 --- a/packages/client/src/scripts/lookup-user.ts +++ b/packages/client/src/scripts/lookup-user.ts @@ -1,6 +1,6 @@ -import * as Acct from "firefish-js/built/acct"; import { i18n } from "@/i18n"; import * as os from "@/os"; +import * as Acct from "firefish-js/built/acct"; export async function lookupUser() { const { canceled, result } = await os.inputText({ diff --git a/packages/client/src/scripts/media-proxy.ts b/packages/client/src/scripts/media-proxy.ts index 6fafe2cd..e29ec467 100644 --- a/packages/client/src/scripts/media-proxy.ts +++ b/packages/client/src/scripts/media-proxy.ts @@ -1,5 +1,5 @@ -import { query } from "@/scripts/url"; import { url } from "@/config"; +import { query } from "@/scripts/url"; export function getProxiedImageUrl(imageUrl: string, type?: "preview"): string { return `${url}/proxy/image.webp?${query({ diff --git a/packages/client/src/scripts/please-login.ts b/packages/client/src/scripts/please-login.ts index b8421172..95c00e2f 100644 --- a/packages/client/src/scripts/please-login.ts +++ b/packages/client/src/scripts/please-login.ts @@ -1,8 +1,8 @@ -import { defineAsyncComponent } from "vue"; -import { $i } from "@/reactiveAccount"; import { i18n } from "@/i18n"; import { popup } from "@/os"; +import { $i } from "@/reactiveAccount"; import { vibrate } from "@/scripts/vibrate"; +import { defineAsyncComponent } from "vue"; export function pleaseLogin(path?: string) { if ($i) return; diff --git a/packages/client/src/scripts/popout.ts b/packages/client/src/scripts/popout.ts index 54aa4222..d27428d2 100644 --- a/packages/client/src/scripts/popout.ts +++ b/packages/client/src/scripts/popout.ts @@ -1,5 +1,5 @@ -import { appendQuery } from "./url"; import * as config from "@/config"; +import { appendQuery } from "./url"; export function popout(path: string, w?: HTMLElement) { let url = diff --git a/packages/client/src/scripts/popup-position.ts b/packages/client/src/scripts/popup-position.ts index 45bcd4db..905e7bc7 100644 --- a/packages/client/src/scripts/popup-position.ts +++ b/packages/client/src/scripts/popup-position.ts @@ -20,7 +20,8 @@ export function calcPopupPosition( } const calcPosWhenTop = () => { - let left: number, top: number; + let left: number; + let top: number; if (props.anchorElement) { left = @@ -41,7 +42,8 @@ export function calcPopupPosition( }; const calcPosWhenBottom = () => { - let left: number, top: number; + let left: number; + let top: number; if (props.anchorElement) { left = @@ -66,7 +68,8 @@ export function calcPopupPosition( }; const calcPosWhenLeft = () => { - let left: number, top: number; + let left: number; + let top: number; if (props.anchorElement) { left = rect.left + window.pageXOffset - contentWidth - props.innerMargin; @@ -87,7 +90,8 @@ export function calcPopupPosition( }; const calcPosWhenRight = () => { - let left: number, top: number; + let left: number; + let top: number; if (props.anchorElement) { left = diff --git a/packages/client/src/scripts/preprocess.ts b/packages/client/src/scripts/preprocess.ts index 867a9909..9481ac48 100644 --- a/packages/client/src/scripts/preprocess.ts +++ b/packages/client/src/scripts/preprocess.ts @@ -1,6 +1,6 @@ -import * as mfm from "mfm-js"; -import { defaultStore } from "@/store"; import { expandKaTeXMacro } from "@/scripts/katex-macro"; +import { defaultStore } from "@/store"; +import * as mfm from "mfm-js"; export default function (text: string): string { if (defaultStore.state.enableCustomKaTeXMacro) { diff --git a/packages/client/src/scripts/reaction-picker.ts b/packages/client/src/scripts/reaction-picker.ts index 353a032d..5b5b6134 100644 --- a/packages/client/src/scripts/reaction-picker.ts +++ b/packages/client/src/scripts/reaction-picker.ts @@ -1,6 +1,6 @@ +import { popup } from "@/os"; import type { Ref } from "vue"; import { defineAsyncComponent, ref } from "vue"; -import { popup } from "@/os"; class ReactionPicker { private src: Ref = ref(null); @@ -8,10 +8,6 @@ class ReactionPicker { private onChosen?: (reaction: string) => void; private onClosed?: () => void; - constructor() { - // nop - } - public async init() { await popup( defineAsyncComponent( @@ -24,14 +20,14 @@ class ReactionPicker { }, { done: (reaction) => { - this.onChosen!(reaction); + this.onChosen?.(reaction); }, close: () => { this.manualShowing.value = false; }, closed: () => { this.src.value = null; - this.onClosed!(); + this.onClosed?.(); }, }, ); diff --git a/packages/client/src/scripts/search.ts b/packages/client/src/scripts/search.ts index 7b757713..b330c467 100644 --- a/packages/client/src/scripts/search.ts +++ b/packages/client/src/scripts/search.ts @@ -1,7 +1,7 @@ -import * as os from "@/os"; import { i18n } from "@/i18n"; -import { mainRouter } from "@/router"; import { instance } from "@/instance"; +import * as os from "@/os"; +import { mainRouter } from "@/router"; export async function search() { const { canceled, result: query } = await os.inputText({ diff --git a/packages/client/src/scripts/select-file.ts b/packages/client/src/scripts/select-file.ts index da78cf49..bbf30cc2 100644 --- a/packages/client/src/scripts/select-file.ts +++ b/packages/client/src/scripts/select-file.ts @@ -1,11 +1,11 @@ -import { ref } from "vue"; -import type { DriveFile } from "firefish-js/built/entities"; -import * as os from "@/os"; -import { stream } from "@/stream"; import { i18n } from "@/i18n"; -import { defaultStore } from "@/store"; -import { uploadFile } from "@/scripts/upload"; +import * as os from "@/os"; import icon from "@/scripts/icon"; +import { uploadFile } from "@/scripts/upload"; +import { defaultStore } from "@/store"; +import { stream } from "@/stream"; +import type { DriveFile } from "firefish-js/built/entities"; +import { ref } from "vue"; function select( src: any, diff --git a/packages/client/src/scripts/shuffle.ts b/packages/client/src/scripts/shuffle.ts index f10f1e59..f1741529 100644 --- a/packages/client/src/scripts/shuffle.ts +++ b/packages/client/src/scripts/shuffle.ts @@ -2,8 +2,8 @@ * 配列をシャッフル (破壊的) */ export function shuffle(array: T): T { - let currentIndex = array.length, - randomIndex; + let currentIndex = array.length; + let randomIndex; // While there remain elements to shuffle. while (currentIndex !== 0) { diff --git a/packages/client/src/scripts/theme.ts b/packages/client/src/scripts/theme.ts index abdabfd1..71e2624c 100644 --- a/packages/client/src/scripts/theme.ts +++ b/packages/client/src/scripts/theme.ts @@ -1,6 +1,6 @@ -import { ref } from "vue"; -import tinycolor from "tinycolor2"; import { globalEvents } from "@/events"; +import tinycolor from "tinycolor2"; +import { ref } from "vue"; export interface Theme { id: string; @@ -11,8 +11,8 @@ export interface Theme { props: Record; } -import lightTheme from "@/themes/_light.json5"; import darkTheme from "@/themes/_dark.json5"; +import lightTheme from "@/themes/_light.json5"; import { deepClone } from "./clone"; export const themeProps = Object.keys(lightTheme.props).filter( diff --git a/packages/client/src/scripts/upload.ts b/packages/client/src/scripts/upload.ts index 37f3c8fa..fac327da 100644 --- a/packages/client/src/scripts/upload.ts +++ b/packages/client/src/scripts/upload.ts @@ -1,11 +1,11 @@ -import { reactive, ref } from "vue"; -import type * as firefish from "firefish-js"; -import { readAndCompressImage } from "browser-image-resizer"; -import { defaultStore } from "@/store"; import { apiUrl } from "@/config"; -import { $i } from "@/reactiveAccount"; -import { alert } from "@/os"; import { i18n } from "@/i18n"; +import { alert } from "@/os"; +import { $i } from "@/reactiveAccount"; +import { defaultStore } from "@/store"; +import { readAndCompressImage } from "browser-image-resizer"; +import type * as firefish from "firefish-js"; +import { reactive, ref } from "vue"; interface Uploading { id: string; diff --git a/packages/client/src/scripts/use-chart-tooltip.ts b/packages/client/src/scripts/use-chart-tooltip.ts index 5d50fd41..082549e7 100644 --- a/packages/client/src/scripts/use-chart-tooltip.ts +++ b/packages/client/src/scripts/use-chart-tooltip.ts @@ -1,6 +1,6 @@ -import { onDeactivated, onUnmounted, ref } from "vue"; -import * as os from "@/os"; import MkChartTooltip from "@/components/MkChartTooltip.vue"; +import * as os from "@/os"; +import { onDeactivated, onUnmounted, ref } from "vue"; export function useChartTooltip( opts: { position: "top" | "middle" } = { position: "top" }, diff --git a/packages/client/src/scripts/use-note-capture.ts b/packages/client/src/scripts/use-note-capture.ts index 27d1821b..3244e070 100644 --- a/packages/client/src/scripts/use-note-capture.ts +++ b/packages/client/src/scripts/use-note-capture.ts @@ -1,9 +1,9 @@ +import * as os from "@/os"; +import { $i } from "@/reactiveAccount"; +import { stream } from "@/stream"; +import type * as firefish from "firefish-js"; import type { Ref } from "vue"; import { onUnmounted } from "vue"; -import type * as firefish from "firefish-js"; -import { stream } from "@/stream"; -import { $i } from "@/reactiveAccount"; -import * as os from "@/os"; export function useNoteCapture(props: { rootEl: Ref; diff --git a/packages/client/src/scripts/use-tooltip.ts b/packages/client/src/scripts/use-tooltip.ts index c14d766b..c26bdd97 100644 --- a/packages/client/src/scripts/use-tooltip.ts +++ b/packages/client/src/scripts/use-tooltip.ts @@ -6,13 +6,13 @@ export function useTooltip( onShow: (showing: Ref) => void, delay = 300, ): void { - let isHovering = false, - // iOS(Androidも?)では、要素をタップした直後に(おせっかいで)mouseoverイベントを発火させたりするため、それを無視するためのフラグ - // 無視しないと、画面に触れてないのにツールチップが出たりし、ユーザビリティが損なわれる - // TODO: 一度でもタップすると二度とマウスでツールチップ出せなくなるのをどうにかする 定期的にfalseに戻すとか...? - shouldIgnoreMouseover = false, - timeoutId: number, - changeShowingState: (() => void) | null; + let isHovering = false; + // iOS(Androidも?)では、要素をタップした直後に(おせっかいで)mouseoverイベントを発火させたりするため、それを無視するためのフラグ + // 無視しないと、画面に触れてないのにツールチップが出たりし、ユーザビリティが損なわれる + // TODO: 一度でもタップすると二度とマウスでツールチップ出せなくなるのをどうにかする 定期的にfalseに戻すとか...? + let shouldIgnoreMouseover = false; + let timeoutId: number; + let changeShowingState: (() => void) | null; const open = () => { close(); diff --git a/packages/client/src/stream.ts b/packages/client/src/stream.ts index f0dd1879..a1a9fbf7 100644 --- a/packages/client/src/stream.ts +++ b/packages/client/src/stream.ts @@ -1,7 +1,7 @@ -import * as firefish from "firefish-js"; -import { markRaw } from "vue"; import { url } from "@/config"; import { $i } from "@/reactiveAccount"; +import * as firefish from "firefish-js"; +import { markRaw } from "vue"; export const stream = markRaw( new firefish.Stream( diff --git a/packages/client/src/theme-store.ts b/packages/client/src/theme-store.ts index 866ba064..a60d8e8c 100644 --- a/packages/client/src/theme-store.ts +++ b/packages/client/src/theme-store.ts @@ -1,6 +1,6 @@ -import type { Theme } from "./scripts/theme"; import { api } from "@/os"; import { $i } from "@/reactiveAccount"; +import type { Theme } from "./scripts/theme"; const lsCacheKey = $i ? `themes:${$i.id}` : ""; diff --git a/packages/client/src/ui/_common_/sw-inject.ts b/packages/client/src/ui/_common_/sw-inject.ts index afc1aee8..3341b20d 100644 --- a/packages/client/src/ui/_common_/sw-inject.ts +++ b/packages/client/src/ui/_common_/sw-inject.ts @@ -1,8 +1,8 @@ -import { post } from "@/os"; import { login } from "@/account"; +import { post } from "@/os"; import { $i } from "@/reactiveAccount"; -import { getAccountFromId } from "@/scripts/get-account-from-id"; import { mainRouter } from "@/router"; +import { getAccountFromId } from "@/scripts/get-account-from-id"; export function swInject() { navigator.serviceWorker.addEventListener("message", (ev) => { diff --git a/packages/client/src/ui/deck/deck-store.ts b/packages/client/src/ui/deck/deck-store.ts index cbe6f4f9..3cf753ba 100644 --- a/packages/client/src/ui/deck/deck-store.ts +++ b/packages/client/src/ui/deck/deck-store.ts @@ -1,9 +1,9 @@ -import { throttle } from "throttle-debounce"; -import { markRaw } from "vue"; -import type { notificationTypes } from "firefish-js"; -import { Storage } from "../../pizzax"; import { api } from "@/os"; import { deepClone } from "@/scripts/clone"; +import type { notificationTypes } from "firefish-js"; +import { throttle } from "throttle-debounce"; +import { markRaw } from "vue"; +import { Storage } from "../../pizzax"; interface ColumnWidget { name: string; diff --git a/packages/client/src/widgets/widget.ts b/packages/client/src/widgets/widget.ts index 9f33cecf..ba0fd00a 100644 --- a/packages/client/src/widgets/widget.ts +++ b/packages/client/src/widgets/widget.ts @@ -1,8 +1,8 @@ -import { reactive, watch } from "vue"; -import { throttle } from "throttle-debounce"; -import type { Form, GetFormResultType } from "@/scripts/form"; import * as os from "@/os"; import { deepClone } from "@/scripts/clone"; +import type { Form, GetFormResultType } from "@/scripts/form"; +import { throttle } from "throttle-debounce"; +import { reactive, watch } from "vue"; export interface Widget

> { id: string; diff --git a/packages/client/vite.config.ts b/packages/client/vite.config.ts index ad9dc2c2..76c29ff2 100644 --- a/packages/client/vite.config.ts +++ b/packages/client/vite.config.ts @@ -2,10 +2,10 @@ import * as fs from "fs"; import pluginVue from "@vitejs/plugin-vue"; import { defineConfig } from "vite"; +import viteCompression from "vite-plugin-compression"; import locales from "../../locales"; import meta from "../../package.json"; import pluginJson5 from "./vite.json5"; -import viteCompression from "vite-plugin-compression"; const extensions = [ ".ts", diff --git a/packages/client/vite.json5.ts b/packages/client/vite.json5.ts index 8653c66d..82a7b2c4 100644 --- a/packages/client/vite.json5.ts +++ b/packages/client/vite.json5.ts @@ -1,9 +1,9 @@ // Original: https://github.com/rollup/plugins/tree/8835dd2aed92f408d7dc72d7cc25a9728e16face/packages/json +import { RollupJsonOptions } from "@rollup/plugin-json"; +import { createFilter, dataToEsm } from "@rollup/pluginutils"; import JSON5 from "json5"; import { Plugin } from "rollup"; -import { createFilter, dataToEsm } from "@rollup/pluginutils"; -import { RollupJsonOptions } from "@rollup/plugin-json"; interface Json5SyntaxError extends SyntaxError { lineNumber: number;