2022-06-19 15:39:22 +00:00
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package activitypub
|
|
|
|
|
|
|
|
import (
|
|
|
|
"code.gitea.io/gitea/models/auth"
|
|
|
|
user_model "code.gitea.io/gitea/models/user"
|
|
|
|
|
2022-07-11 22:27:57 +00:00
|
|
|
ap "github.com/go-ap/activitypub"
|
2022-06-19 15:39:22 +00:00
|
|
|
)
|
|
|
|
|
2022-07-14 03:10:03 +00:00
|
|
|
func FederatedUserNew(IRI ap.IRI) error {
|
|
|
|
name, err := personIRIToName(IRI)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-06-19 15:39:22 +00:00
|
|
|
user := &user_model.User{
|
|
|
|
Name: name,
|
2022-07-14 03:10:03 +00:00
|
|
|
Email: name, // TODO: change this to something else to prevent collisions with normal users, maybe fetch email using Gitea API
|
2022-06-19 15:39:22 +00:00
|
|
|
LoginType: auth.Federated,
|
|
|
|
Website: IRI.String(),
|
|
|
|
}
|
|
|
|
return user_model.CreateUser(user)
|
|
|
|
}
|