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
e23cf77f
Unverified
Commit
e23cf77f
authored
1 year ago
by
Namekuji
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
fetch person again (#10514)
parent
0f328e84
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/backend/src/core/activitypub/ApInboxService.ts
+6
-2
6 additions, 2 deletions
packages/backend/src/core/activitypub/ApInboxService.ts
packages/backend/src/server/api/endpoints/i/move.ts
+17
-13
17 additions, 13 deletions
packages/backend/src/server/api/endpoints/i/move.ts
with
23 additions
and
15 deletions
packages/backend/src/core/activitypub/ApInboxService.ts
+
6
−
2
View file @
e23cf77f
...
...
@@ -736,13 +736,17 @@ export class ApInboxService {
// fetch the new and old accounts
const
targetUri
=
getApHrefNullable
(
activity
.
target
);
if
(
!
targetUri
)
return
'
skip: invalid activity target
'
;
cons
t
new_acc
=
await
this
.
apPersonService
.
resolvePerson
(
targetUri
);
cons
t
old_acc
=
await
this
.
apPersonService
.
resolvePerson
(
actor
.
uri
);
le
t
new_acc
=
await
this
.
apPersonService
.
resolvePerson
(
targetUri
);
le
t
old_acc
=
await
this
.
apPersonService
.
resolvePerson
(
actor
.
uri
);
// update them if they're remote
if
(
new_acc
.
uri
)
await
this
.
apPersonService
.
updatePerson
(
new_acc
.
uri
);
if
(
old_acc
.
uri
)
await
this
.
apPersonService
.
updatePerson
(
old_acc
.
uri
);
// retrieve updated users
new_acc
=
await
this
.
apPersonService
.
resolvePerson
(
targetUri
);
old_acc
=
await
this
.
apPersonService
.
resolvePerson
(
actor
.
uri
);
// check if alsoKnownAs of the new account is valid
let
isValidMove
=
true
;
if
(
old_acc
.
uri
)
{
...
...
This diff is collapsed.
Click to expand it.
packages/backend/src/server/api/endpoints/i/move.ts
+
17
−
13
View file @
e23cf77f
...
...
@@ -42,7 +42,7 @@ export const meta = {
id
:
'
4362f8dc-731f-4ad8-a694-be2a88922a24
'
,
},
rootForbidden
:
{
message
:
'
The root cant migrate.
'
,
message
:
'
The root can
\'
t migrate.
'
,
code
:
'
NOT_ROOT_FORBIDDEN
'
,
id
:
'
4362e8dc-731f-4ad8-a694-be2a88922a24
'
,
},
...
...
@@ -92,42 +92,46 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
private
apPersonService
:
ApPersonService
,
)
{
super
(
meta
,
paramDef
,
async
(
ps
,
me
)
=>
{
//
C
heck parameter
//
c
heck parameter
if
(
!
ps
.
moveToAccount
)
throw
new
ApiError
(
meta
.
errors
.
noSuchMoveTarget
);
//
A
bort if user is the root
//
a
bort if user is the root
if
(
me
.
isRoot
)
throw
new
ApiError
(
meta
.
errors
.
rootForbidden
);
//
A
bort if user has already moved
//
a
bort if user has already moved
if
(
me
.
movedToUri
)
throw
new
ApiError
(
meta
.
errors
.
alreadyMoved
);
let
unfiltered
=
ps
.
moveToAccount
;
if
(
!
unfiltered
)
throw
new
ApiError
(
meta
.
errors
.
noSuchMoveTarget
);
//
P
arse user's input into the destination account
//
p
arse user's input into the destination account
if
(
unfiltered
.
startsWith
(
'
acct:
'
))
unfiltered
=
unfiltered
.
substring
(
5
);
if
(
unfiltered
.
startsWith
(
'
@
'
))
unfiltered
=
unfiltered
.
substring
(
1
);
if
(
!
unfiltered
.
includes
(
'
@
'
))
throw
new
ApiError
(
meta
.
errors
.
notRemote
);
const
userAddress
=
unfiltered
.
split
(
'
@
'
);
//
R
etrieve the destination account
const
remoteM
oveTo
=
await
this
.
remoteUserResolveService
.
resolveUser
(
userAddress
[
0
],
userAddress
[
1
]).
catch
((
e
)
=>
{
//
r
etrieve the destination account
let
m
oveTo
=
await
this
.
remoteUserResolveService
.
resolveUser
(
userAddress
[
0
],
userAddress
[
1
]).
catch
((
e
)
=>
{
this
.
apiLoggerService
.
logger
.
warn
(
`failed to resolve remote user:
${
e
}
`
);
throw
new
ApiError
(
meta
.
errors
.
noSuchMoveTarget
);
});
const
moveTo
=
await
this
.
getterService
.
getRemoteUser
(
remoteMoveTo
.
id
);
if
(
!
moveTo
.
uri
)
throw
new
ApiError
(
meta
.
errors
.
uriNull
);
await
this
.
apPersonService
.
updatePerson
(
moveTo
.
uri
);
// Only allow moving to a remote account
const
remoteMoveTo
=
await
this
.
getterService
.
getRemoteUser
(
moveTo
.
id
);
if
(
!
remoteMoveTo
.
uri
)
throw
new
ApiError
(
meta
.
errors
.
uriNull
);
// update local db
await
this
.
apPersonService
.
updatePerson
(
remoteMoveTo
.
uri
);
// retrieve updated user
moveTo
=
await
this
.
apPersonService
.
resolvePerson
(
remoteMoveTo
.
uri
);
// only allow moving to a remote account
if
(
this
.
userEntityService
.
isLocalUser
(
moveTo
))
throw
new
ApiError
(
meta
.
errors
.
notRemote
);
let
allowed
=
false
;
const
fromUrl
=
`
${
this
.
config
.
url
}
/users/
${
me
.
id
}
`
;
//
M
ake sure that the user has indicated the old account as an alias
//
m
ake sure that the user has indicated the old account as an alias
moveTo
.
alsoKnownAs
?.
forEach
((
elem
)
=>
{
if
(
fromUrl
.
includes
(
elem
))
allowed
=
true
;
});
//
A
bort if unintended
//
a
bort if unintended
if
(
!
(
allowed
&&
moveTo
.
uri
&&
fromUrl
))
throw
new
ApiError
(
meta
.
errors
.
remoteAccountForbids
);
return
await
this
.
accountMoveService
.
moveToRemote
(
me
,
moveTo
);
...
...
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