Commit graph

926 commits

Author SHA1 Message Date
b11e4053db
server: use named export for acceptFollowRequest 2022-12-22 16:52:52 -05:00
e2ef800708
server: dont use replace for file types
No point in using replace if we already know which character we want to replace.
2022-12-22 14:46:21 +01:00
a7048f17f7
server: simplify duplicated code 2022-12-22 14:45:20 +01:00
33f0b24c56
server: add v2 routes to notes endpoints 2022-12-22 11:02:04 +01:00
7685b92511
improve fetching of endpoint arguments
including support for route parameters (e.g. '/v2/note/:noteId' giving us a 'noteId' value)

Co-authored-by: Johann150 <johann.galle@protonmail.com>
2022-12-22 11:02:04 +01:00
8276bd3bdc
generate OpenAPI spec for v2 endpoints 2022-12-22 11:02:04 +01:00
aed2752470
server: make v2 meta endpoint support GET 2022-12-22 11:01:56 +01:00
4a3b91d658
server: add additional API v2 options to endpoints
* improve type definitions for v2 method
The method has to be lowercase because it is used as an index to get
the respective method of the router.

Co-authored-by: Johann150 <johann.galle@protonmail.com>
2022-12-22 11:00:46 +01:00
9317d25078
server: expire notifications after 3 months
closes FoundKeyGang/FoundKey#292

Changelog: Added
2022-12-21 21:46:45 +01:00
fc36bb8880
server: reduce code duplication in check-expired queue job 2022-12-21 21:46:27 +01:00
711bb8be7d
fixup: add missing redirect argument 2022-12-21 21:23:23 +01:00
275136cf8b
allow redirects in API ap/* endpoints 2022-12-21 20:45:55 +01:00
aa33708b90
server: handle redirects in signed get
part of FoundKeyGang/FoundKey#288

Changelog: Fixed
2022-12-20 22:07:24 +01:00
99c459a21a
server: better upload limit error
Ref: FoundKeyGang/FoundKey#293
2022-12-19 21:29:29 +01:00
bd68096ea9
server: refactor API error 2022-12-19 21:24:39 +01:00
6c7f1774e3
server: fix thread mutes not applying to renotes
Changelog: Fixed
2022-12-15 21:20:24 +01:00
af43df15ca
reduce duplication in secureRndstr 2022-12-15 20:46:17 +01:00
5f83383ab8
fix import error in tests 2022-12-15 20:45:55 +01:00
8c759dde6c
server: fix error about duplicate resolve 2022-12-15 19:44:55 +01:00
16d091497a
server: use extractDbHost instead of toPuny, translate comments
Also swapped logical or for nullish coalescing operator in some places.
2022-12-15 00:32:15 +01:00
ef53ec276a
activitypub: simplify some URI/id related checks
followup on previous commit
2022-12-15 00:31:23 +01:00
3582fd8260
activitypub: centrally check id matches URL in resolver
This makes some duplicated checks in models/note and models/person
unnecessary.
2022-12-15 00:29:39 +01:00
9f1670d5fd
server: fix default not found error image 2022-12-14 19:05:41 +01:00
ff31b8b06d server: remove bios and cli
The BIOS and CLI functionality were mainly for debugging purposes.
If a user has to use those to resolve an issue with the server, that
really should be fixed at the source instead.

Closes: FoundKeyGang/FoundKey#283
Changelog: Removed
2022-12-14 17:59:25 +00:00
ffff2ae5ef
server: fix missing import
closes FoundKeyGang/FoundKey#286
2022-12-14 18:08:44 +01:00
ccc8bf0289
chore: fix more miscellaneous lints 2022-12-13 23:09:32 +01:00
a231b36d59
chore: fix lint about unused variables in entities 2022-12-13 23:09:32 +01:00
8e9c65fab0
chore: fix some import related lints 2022-12-13 23:09:31 +01:00
78a3051313
remove unneeded TODO 2022-12-13 16:46:29 -05:00
78717e85d3
server: change JSON.parse/stringify to structuredClone
structuredClone is more typesafe than using JSON.parse and
JSON.stringify.

Now that Node 18.x is the new baseline, this should be safe to use now.

See https://developer.mozilla.org/en-US/docs/Web/API/structuredClone
for details.
2022-12-13 16:45:38 -05:00
a9d3cae511
server: add return type to extractApMentions 2022-12-13 16:31:15 -05:00
bd27b7ca3a
server: add typing for renderFollowRelay 2022-12-13 16:06:18 -05:00
e28a9eb8e8
use tsc --noEmit for backend and client
See https://github.com/misskey-dev/misskey/pull/9316
2022-12-13 16:02:06 -05:00
e5a4c5d2d0
chore: update @typescript-eslint packages 2022-12-13 15:57:26 -05:00
6bba55c196
sw: add TypeScript type checking
This implements the upstream changes from
https://github.com/misskey-dev/misskey/pull/9314 but updated to our
version of ESLint.

Also updates TypeScript to 4.9.4 for all packages.
2022-12-13 15:42:08 -05:00
1d469f3c34
fix import typo 2022-12-13 15:12:29 -05:00
3f0228e14c
server: use color-convert KEYWORD instead of extracting parameter type 2022-12-13 15:11:29 -05:00
5ea744b1b2
server: use configurable images 2022-12-13 20:54:49 +01:00
ae6ba05306
add config for error images
Changelog: Added
2022-12-13 20:54:49 +01:00
d4d1e03479
server: fix errors for replies and state when note doesnt exist 2022-12-13 20:35:46 +01:00
030394b30d
refactor: remove default export for boot 2022-12-11 14:42:55 -05:00
768d9bbdfb
refactor: remove default export for perform 2022-12-11 18:23:19 +01:00
3ef1a4b0f9
refactor: remove default export for Resolver 2022-12-11 18:23:07 +01:00
ae59ce51b0
refactor: remove default export for DbResolver 2022-12-11 18:16:48 +01:00
14a9b9bedd
refactor: remove default export for request 2022-12-11 18:16:45 +01:00
985a13f47f
refactor: remove default export for DeliverManager 2022-12-11 17:56:25 +01:00
507b328fdf
activitypub: also forward resolver to resolveNote 2022-12-10 11:23:10 +01:00
3cf673960b server: Fix typing for user token
Also fix a comment in the User model that wrongly states that the token
is null if the user is local, when it's the opposite.
2022-12-08 23:20:41 -05:00
cbfd866122 server: make fetcher key non-null 2022-12-08 23:19:39 -05:00
b23a8dbaed server: translate comments 2022-12-08 23:18:45 -05:00
80a73a7510 server: remove unused imports from suspend-user.ts 2022-12-08 23:18:45 -05:00
3dec9a47f0 server: fix various type errors in services 2022-12-08 23:18:45 -05:00
b8fb7a38cc server: improve Logger typing information and docs 2022-12-08 23:18:45 -05:00
fdc682e810 server: remove sendEmailNotification
The functions have their bodies completely comented out,
which means they are doing nothing.
2022-12-08 23:18:45 -05:00
fde751df8f
fix: properly supply resolver (2) 2022-12-08 19:06:55 +01:00
1faf1035f9
server: handle users getting deleted somewhere else
I don't know why but several jobs got stuck in my inbox queue because
of errors like 'Could not find any entity of type "User" matching...'.
2022-12-08 18:12:24 +01:00
e2ce599aca
fix: properly supply resolver 2022-12-08 18:12:05 +01:00
350f21d955
server: fix typing for skippedInstances query 2022-12-07 16:41:34 -05:00
873e21f090
chore: update eslint 2022-12-07 16:27:53 -05:00
2afe54c121
eslint: allow backticks to avoid escaping single/double quotes 2022-12-07 16:27:39 -05:00
b66f7550ab
server: auto-fix lints 2022-12-07 13:39:21 -05:00
18664dbca3
server: add missing paren
How did this not break yet?
2022-12-07 18:29:04 +01:00
0f3f42eb39
remove rndstr dependency
This dependency was unused in the client.

The use of it in the server can be replaced entirely by the
secureRndstr function, with some slight modifications.

That function could probably be refactored a bit more as well.
2022-12-07 18:08:09 +01:00
d3f1ad9a88 chore: remove unused packages 2022-12-06 23:18:27 +01:00
1aa3898db5 server: remove unused import 2022-12-06 23:12:45 +01:00
b023741f50 server: remove integrations field from user 2022-12-06 23:00:08 +01:00
4cc5b734e7 activitypub: remove integration fields from person and nodeinfo 2022-12-06 21:49:19 +01:00
5d32872999 server: remove integration API routes 2022-12-06 21:48:31 +01:00
b4b1204f77 server: remove integration-related fields from meta 2022-12-06 21:47:59 +01:00
c1a51547a9 BREAKING: server: remove wildcard blocking and instead block subdomains (#269)
Co-authored-by: Francis Dinh <normandy@biribiri.dev>
Reviewed-on: FoundKeyGang/FoundKey#269
Changelog: Changed
2022-12-05 17:55:38 +00:00
4e74d26e45 backend: fix ratelimit typo
Changelog: Fixed
2022-12-05 15:49:33 +01:00
a421dd401c
activitypub: refactor to always apply recursion limit
Refactor to remove as many "new Resolver" as possible.
2022-12-04 21:11:44 +01:00
c4211761e6
server: refactor resolveSelf to just return the webfinger href
Since the href seems to be the only attribute that is used, and I didn't
want to add a full type definition this was the easier option.
2022-12-04 21:11:43 +01:00
03b673165f
server: refactor "authUser" functions into separate file
They did not really fit into the DbResolver because they may fetch data
from remote instances even though DbResolver is only supposed to access
the database.
2022-12-04 21:11:35 +01:00
de18c8306d
server: fix token-permissions migration
The table that is affected here was not properly purged of old entries. It only holds
data that is needed while a 3rd party authorization is in progress but not finished.

The code that typeorm generated for this migration is a bit wonky because it should
probably have dropped one column and created another one. But if we clear out all entries
it should work regardless and I'm feeling lazy right now. :P
2022-12-04 19:05:02 +01:00
11e4a8cb9b
remove erroneous space 2022-12-04 15:34:05 +01:00
946e862ecd
server: implement OAuth 2.0 Authorization Code grant
Changelog: Added
Reviewed-on: FoundKeyGang/FoundKey#205
2022-12-04 14:06:36 +01:00
97052b1f61
server: refactor fromHtml attribute handling
Also try to recognize owncast hashtag links.
2022-12-04 03:43:22 +01:00
cda9197700
server: increase nodeinfo caching
Changelog: Changed
2022-12-04 03:26:50 +01:00
2dde8273e2 implement separate web workers
Reviewed-on: FoundKeyGang/FoundKey#252
2022-12-03 13:33:23 +00:00
de927e1f30 server: handle invalid URLs in comparison 2022-12-03 10:38:33 +00:00
bdcec2b8a7 server: implement OAuth discovery (RFC 8414) 2022-12-03 10:38:33 +00:00
5291f29581 implement OAuth PKCE
This implements Proof Key for Code Exchange a.k.a. RFC 7636.
2022-12-03 10:38:33 +00:00
15b3ab6d13 check redirect URIs 2022-12-03 10:38:33 +00:00
79e3c20189 server: allow to grant tokens with more restricted privileges
This also simplifies API authentication a bit by not having to fetch
the App that is related to a token.

The restriction of 1 token per app is also lifted. This was not a
constraint in the database but it was enforced by the code and
kinda wrong schema the auth_session table had.
2022-12-03 10:38:32 +00:00
2f2e6a58a4 docs: read scope descriptions from locale strings 2022-12-03 10:38:32 +00:00
c65fdebe26 server: add missing auth/deny endpoint
This endpoint is hinted at in the client, but is not actually defined
in the backend. This commit defines it.
2022-12-03 10:38:32 +00:00
418c88bb8f expire AuthSessions after 15 min 2022-12-03 10:38:32 +00:00
2b19b34196 update OpenAPI docs to OAuth 2022-12-03 10:38:32 +00:00
7db7fdd9e2 add API route for OAuth access token retrieval 2022-12-03 10:38:32 +00:00
a13e956af0 make authorization token granting OAuth 2.0 compatible
This is basically a shim on top of the existing API.
Instead of the 3rd party, the web UI generates the authorization session.

The data that the API returns is slightly adjusted so that only one
API call is necessary instead of two.
2022-12-03 10:38:32 +00:00
18cf228f89
server: readd "fetch meta only once in skippedInstances""
This reverts commit e446a11bb7.

Turns out this wasn't really the source of the referenced issue and
someone was able to run with the original commit fine, so adding this
back for now.
2022-12-03 05:13:30 -05:00
bdf2e14a73
server: fix TypeError in registerOrFetchInstanceDoc
Changelog: Fixed
2022-12-03 04:01:51 -05:00
e446a11bb7
Revert "server: fetch meta only once in skippedInstances"
This reverts commit 81d63720f2 since it
seems to cause a ReferenceError for some reason.

Ref: https://toot.site/@jeder/109447151582516733
2022-12-03 02:13:18 -05:00
194fff3603
activitypub: hashtags no longer displaying as links
Some hashtags sent from Mastodon were erroneously displayed as links.
This is because Mastodon seems to mangle hashtags containing non-ASCII
codepoints (such as e.g. umlauts). This lead to the previous code which
depended on the list of hashtags to not recognize a hashtag. Instead,
the `rel="tag"` microformat is recognized instead.

This makes the `htmlToMfm` wrapper function unnecessary so it was removed.

Changelog: Fixed
2022-12-02 19:31:57 +01:00
b4080d788d
slight refactoring & translating japanese 2022-12-02 19:00:58 +01:00
e49b8d0ef3
server: remove unnecessary apLogger aliases 2022-12-02 18:58:19 +01:00
7d3d0f858c
increment versions in package.json 2022-12-02 16:59:47 +01:00
81d63720f2
server: fetch meta only once in skippedInstances 2022-12-02 09:26:14 -05:00
5e6b51094e
server: fix instance skipping
This should actually make instance skipping work properly since
shouldBlockInstance is now properly awaited on now.
2022-12-02 09:10:56 -05:00
9ad37a12f8
server: fix rendering of Follow activity when removing follow
closes FoundKeyGang/FoundKey#263

Changelog: Fixed
2022-12-01 21:49:38 +01:00
e10700a2be Merge pull request 'server: add wildcard matching to blocked hosts' (#260) from wildcard-block-v2 into main
Reviewed-on: FoundKeyGang/FoundKey#260
2022-12-01 20:12:18 +00:00
721a327192
fixup: remove unused import 2022-12-01 20:46:46 +01:00
936cbf900b
use default argument value
This unifies the style with the other function in that file and fixes
the lint "no-param-reassign".
2022-12-01 20:32:57 +01:00
b3e34795c0
require punycode conversion beforehand for admins 2022-12-01 12:07:43 -05:00
a35c98bbd5
server: encode non-ascii domains in punycode in matchHost 2022-12-01 11:34:11 -05:00
075e251822
server: add wildcard matching to blocked hosts
This adds in wildcard matching. For instance:
- `*.bad.tld` will match: `very.bad.tld`
- `bad.*` will match: `bad.something`
- `*.bad.*` will match: `very.bad.evil`

Changelog: Changed
2022-12-01 11:29:02 -05:00
Derek Schmidt
11a6e706f4
server: Use shared resolver in featured and question accept 2022-12-01 04:40:14 -05:00
Derek Schmidt
d3af00a912
server: Add recursion limit to resolver
Changelog: Security
2022-12-01 04:40:07 -05:00
973bd4532b Merge pull request 'server: always enable push notifications' (#235) from enable-push-notifs into main
Reviewed-on: FoundKeyGang/FoundKey#235
Changelog: Changed
2022-11-29 21:51:10 +00:00
5733f127ca
backend: update re2 to 1.17.8
This should fix Node 19 compatibility.

Fixes: FoundKeyGang/FoundKey#238
2022-11-28 12:02:24 -05:00
8130a2a9b1
server: remove deeplIsPro setting
This setting is unnecessary because DeepL free keys can be detected
easily according to <https://www.deepl.com/docs-api/api-access/authentication/>:
> DeepL API Free authentication keys can be identified easily by the suffix ":fx"

Changelog: Removed
2022-11-27 12:12:56 +01:00
9fd23b5dae
server: remove quote urls, 3rd try
First try was 66a7c62342 but classList is
not in parse5 DOM. Second try was 7ee6a09cf2
but forgot the contents of this commit.
2022-11-27 09:30:51 +01:00
6600f6e52e fixup: make cluster limit into a per-mode warning rather than error 2022-11-26 13:28:39 +01:00
d0c504ec85
server: fix unknown variable in signin endpoint 2022-11-25 19:09:08 +01:00
062cba1b3c
server: fix undefined variable for instance actor 2022-11-25 19:05:37 +01:00
48a60b03ea
BREAKING: implement separate web workers
There are now separate web and queue workers.

The configuration entry `clusterLimit` has been replaced by
`clusterLimits` which allows separate configuration of web and
queue workers.

Changelog: Changed
2022-11-25 12:56:49 +01:00
f817d45210
update eslint and typescript-eslint 2022-11-25 02:07:21 -05:00
b67799ad3f
BREAKING: Remove support for Node 16.x and upgrade to TypeScript 4.9
Now that Node 18 is the new LTS version of Node, it should be safe to
support ES2022 features. The install docs have already been updated to
recommend Node 18.x in 41a710854e.

This will break support on Node 16.x and earlier.

Also update TypeScript to 4.9 which contains various typechecking
improvements: https://devblogs.microsoft.com/typescript/announcing-typescript-4-9/

Ref: FoundKeyGang/FoundKey#238
Changelog: Changed
2022-11-25 02:07:21 -05:00
01fa4332c2
server: set vapid keys on initial setup 2022-11-21 22:30:34 +01:00
563f3672a9
server: always enable push notifications
The thing that previously presumably hindered this was that the VAPID
keys had to be set up. Previously admins had to do this, but this is a bad
idea for multiple reasons:
1) The meaning of "public key" and "private key" was not well documented
in the settings.
2) Giving out a private key over the API, even just for admins, sounds
like a bad idea.

Co-authored-by: Francis Dinh <normandy@biribiri.dev>
2022-11-21 22:00:53 +01:00
7ee6a09cf2
fix errors from quote string removal
The parse5 tree does not have the full DOM methods and attributes.
2022-11-21 19:43:56 +01:00
9e2553909e
server: use time constants 2022-11-20 23:15:40 +01:00
66a7c62342 activitypub: remove akkoma quote URLs
Changelog: Fixed
2022-11-20 20:48:15 +00:00
512351746f Merge pull request 'Add LibreTranslate support' (#224) from libretranslate into main
Reviewed-on: FoundKeyGang/FoundKey#224
Changelog: Added
2022-11-20 16:21:17 +00:00
kabo2468
b7f32be512
server: don't nyaize quoted lines
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
Changelog: Changed
2022-11-20 11:15:03 +01:00
aefb11959f
fix: translator settings on admin/meta endpoint 2022-11-20 10:37:50 +01:00
8cde66b8ac
backend: Add LibreTranslate support 2022-11-19 23:00:33 -05:00
7ffe2181a9
server: use host parameter in note search without elasticsearch
Changelog: Fixed
2022-11-19 17:33:27 +01:00
4183c429e6
server: rewrite skipped instances query in raw SQL
This should hopefully improve performance somewhat.

Reviewed-on: FoundKeyGang/FoundKey#230
Changelog: Changed
2022-11-18 22:02:47 +01:00
28aa440bcc
server: correctly await promises when updating server info
When not awaiting promises, truncating the table and inserting again
can sometimes not work due to race conditions.
2022-11-18 20:52:19 +01:00
71b3b5a60c backend: implement not forwarding block activities (#212)
Fixes FoundKeyGang/FoundKey#211

Commits pulled from https://github.com/misskey-dev/misskey/pull/7799

Changelog: Added
Co-authored-by: FloatingGhost <hannah@coffee-and-dreams.uk>
Co-authored-by: Johann150 <johann.galle@protonmail.com>
Co-authored-by: Francis Dinh <normandy@biribiri.dev>
Reviewed-on: FoundKeyGang/FoundKey#212
2022-11-17 21:24:38 +00:00
110c645a97 Merge pull request 'backend: fix activitypub.ts lints' (#236) from refactor/activitypub-ts into main
Reviewed-on: FoundKeyGang/FoundKey#236
2022-11-17 19:48:08 +00:00
ddeb5b25f1
translate comments in chart core 2022-11-17 20:23:17 +01:00
c0d5678039
backend: fix lints in various misc modules
Mostly adding return types and also fixing a type error.
2022-11-16 19:48:16 -05:00
629b865789
backend: add return type to getAntennas 2022-11-16 19:44:20 -05:00
021d523d5f
backend: fix activitypub.ts lints 2022-11-16 19:38:32 -05:00
848b9bcdf1
backend: partially revert repo url change in nodeinfo 2022-11-16 17:58:55 -05:00
b18c9b27a6
backend: minor cleanup of nodeinfo.ts
Copy over the MONTH constant from the client code and the time constants
for active{Halfyear,Month}.

Also instead of adding and deleting `respository` from the nodeinfo for
version 2.0, only add in the repository URL in the 2.1 endpoint.
2022-11-16 17:52:13 -05:00
b958be77b6
fixup server: refactor meta caching
fix: setting meta does not keep cache synced.
fix: handle initially empty meta table.
2022-11-16 20:36:22 +01:00
9f6be8d557
server: refactor meta caching
This removes the "caching" that re-fetches the instance meta information
from the database every 10 seconds.
2022-11-14 22:12:32 +01:00
9d9b2da6cc
fix parameter for cache fetcher 2022-11-13 20:31:24 +01:00
d1ec058d5c
server: refactor Cache to hold fetcher as attribute
Instead of having to pass the fetcher every time you want to fetch
something, the fetcher is stored in an attribute of the Cache.
2022-11-13 19:39:30 +01:00
131c12a30b
server: refactor prefetchEmojis
Exiting earlier might slightly improve performance.
2022-11-13 18:24:15 +01:00
8d6476af2a
server: remove localUserByIdCache
The same data is stored in userByIdCache. Whether a user is local or not
can easily be determined from the cached object.
2022-11-13 18:03:22 +01:00
57299f0df6
server: simplify caching for instance actor 2022-11-13 17:14:33 +01:00
b0489abd7f
translate japanese comments 2022-11-13 13:47:22 +01:00
a3468491a7
fix import 2022-11-12 18:51:57 +01:00
486be564e8
server: improve comments 2022-11-12 17:39:36 +01:00
c49f529ccb
server: use DeliverManager for user deletion 2022-11-12 15:23:49 +01:00