Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dima Krasner
Sharkey
Commits
9b05b6ef
Unverified
Commit
9b05b6ef
authored
5 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
Improve readability
parent
54a87b25
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/queue/processors/inbox.ts
+30
-30
30 additions, 30 deletions
src/queue/processors/inbox.ts
with
30 additions
and
30 deletions
src/queue/processors/inbox.ts
+
30
−
30
View file @
9b05b6ef
...
...
@@ -36,41 +36,41 @@ export default async (job: Bull.Job): Promise<void> => {
if
(
keyIdLower
.
startsWith
(
'
acct:
'
))
{
logger
.
warn
(
`Old keyId is no longer supported.
${
keyIdLower
}
`
);
return
;
}
else
{
// アクティビティ内のホストの検証
const
host
=
toPuny
(
new
URL
(
signature
.
keyId
).
hostname
);
try
{
ValidateActivity
(
activity
,
host
);
}
catch
(
e
)
{
logger
.
warn
(
e
.
message
);
return
;
}
}
// ブロックしてたら中断
// TODO: いちいちデータベースにアクセスするのはコスト高そうなのでどっかにキャッシュしておく
const
meta
=
await
fetchMeta
();
if
(
meta
.
blockedHosts
.
includes
(
host
))
{
logger
.
info
(
`Blocked request:
${
host
}
`
);
return
;
}
// アクティビティ内のホストの検証
const
host
=
toPuny
(
new
URL
(
signature
.
keyId
).
hostname
);
try
{
ValidateActivity
(
activity
,
host
);
}
catch
(
e
)
{
logger
.
warn
(
e
.
message
);
return
;
}
const
_key
=
await
UserPublickeys
.
findOne
({
keyId
:
signature
.
keyId
});
// ブロックしてたら中断
// TODO: いちいちデータベースにアクセスするのはコスト高そうなのでどっかにキャッシュしておく
const
meta
=
await
fetchMeta
();
if
(
meta
.
blockedHosts
.
includes
(
host
))
{
logger
.
info
(
`Blocked request:
${
host
}
`
);
return
;
}
if
(
_key
)
{
// 登録済みユーザー
user
=
await
Users
.
findOne
(
_key
.
userId
)
as
IRemoteUser
;
key
=
_key
;
}
else
{
// 未登録ユーザーの場合はリモート解決
user
=
await
resolvePerson
(
activity
.
actor
)
as
IRemoteUser
;
if
(
user
==
null
)
{
throw
new
Error
(
'
failed to resolve user
'
);
}
const
_key
=
await
UserPublickeys
.
findOne
({
keyId
:
signature
.
keyId
});
key
=
await
UserPublickeys
.
findOne
(
user
.
id
).
then
(
ensure
);
if
(
_key
)
{
// 登録済みユーザー
user
=
await
Users
.
findOne
(
_key
.
userId
)
as
IRemoteUser
;
key
=
_key
;
}
else
{
// 未登録ユーザーの場合はリモート解決
user
=
await
resolvePerson
(
activity
.
actor
)
as
IRemoteUser
;
if
(
user
==
null
)
{
throw
new
Error
(
'
failed to resolve user
'
);
}
key
=
await
UserPublickeys
.
findOne
(
user
.
id
).
then
(
ensure
);
}
// Update Person activityの場合は、ここで署名検証/更新処理まで実施して終了
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment