Fix federated following/unfollowing regression
parent
c100b8e1e0
commit
0925235a96
|
@ -46,8 +46,9 @@ func Follow(ctx context.Context, follow ap.Follow) {
|
|||
// Process a Undo follow activity
|
||||
// I haven't tried this yet so hopefully it works
|
||||
func Unfollow(ctx context.Context, unfollow ap.Undo) {
|
||||
follow := unfollow.Object.(*ap.Follow)
|
||||
// Actor is the user performing the undo follow
|
||||
actorIRI := unfollow.Actor.GetID()
|
||||
actorIRI := follow.Actor.GetID()
|
||||
actorUser, err := personIRIToUser(ctx, actorIRI)
|
||||
if err != nil {
|
||||
log.Warn("Couldn't find actor user for follow", err)
|
||||
|
@ -55,7 +56,7 @@ func Unfollow(ctx context.Context, unfollow ap.Undo) {
|
|||
}
|
||||
|
||||
// Object is the user being unfollowed
|
||||
objectIRI := unfollow.Object.GetID()
|
||||
objectIRI := follow.Object.GetID()
|
||||
objectUser, err := personIRIToUser(ctx, objectIRI)
|
||||
// Must be a local user
|
||||
if strings.Contains(objectUser.Name, "@") || err != nil {
|
||||
|
@ -64,11 +65,4 @@ func Unfollow(ctx context.Context, unfollow ap.Undo) {
|
|||
}
|
||||
|
||||
user_model.UnfollowUser(actorUser.ID, objectUser.ID)
|
||||
|
||||
// Send back an Accept activity
|
||||
accept := ap.AcceptNew(objectIRI, unfollow)
|
||||
accept.Actor = ap.Person{ID: objectIRI}
|
||||
accept.To = ap.ItemCollection{ap.IRI(actorIRI.String() + "/inbox")}
|
||||
accept.Object = unfollow
|
||||
Send(objectUser, accept)
|
||||
}
|
||||
|
|
|
@ -43,10 +43,15 @@ func personIRIToUser(ctx context.Context, personIRI ap.IRI) (*user_model.User, e
|
|||
}
|
||||
|
||||
user, err := user_model.GetUserByName(ctx, name)
|
||||
if err != nil || !strings.Contains(name, "@") {
|
||||
if err != nil && !strings.Contains(name, "@") {
|
||||
return user, err
|
||||
}
|
||||
FederatedUserNew(personIRI)
|
||||
|
||||
err = FederatedUserNew(personIRI)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return user_model.GetUserByName(ctx, name)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue