mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 06:03:51 +03:00
Panic on error, use correct function names
This commit is contained in:
parent
9dcbe0177e
commit
ed1af14ceb
1 changed files with 7 additions and 10 deletions
|
@ -214,28 +214,25 @@ func RepositoryInbox(ctx *context.APIContext) {
|
||||||
|
|
||||||
users, err := searchUsersByPerson(remoteStargazer, person)
|
users, err := searchUsersByPerson(remoteStargazer, person)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Errorf("Search failed: %v", err)
|
panic(fmt.Errorf("searching for user failed: %v", err))
|
||||||
}
|
}
|
||||||
|
if len(users) == 0 {
|
||||||
log.Info("local found users: %v", usersCount)
|
|
||||||
|
|
||||||
if usersCount == 0 {
|
|
||||||
// create user
|
// create user
|
||||||
// ToDo: We need a remote server with federation enabled to properly test this
|
// ToDo: We need a remote server with federation enabled to properly test this
|
||||||
|
|
||||||
email, err := generateUUIDMail(person)
|
email, err := generateUUIDMail(person)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Errorf("Generate user failed: %v", err)
|
panic(fmt.Errorf("generate user failed: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
username, err := getUserName(person)
|
username, err := generateRemoteUserName(person)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Errorf("Generate user failed: %v", err)
|
panic(fmt.Errorf("generate user failed: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
password, err := generateRandomPassword()
|
password, err := generateRandomPassword()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Errorf("Generate password failed: %v", err)
|
panic(fmt.Errorf("generate password failed: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
user := &user_model.User{
|
user := &user_model.User{
|
||||||
|
@ -256,7 +253,7 @@ func RepositoryInbox(ctx *context.APIContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := user_model.CreateUser(ctx, user, overwriteDefault); err != nil {
|
if err := user_model.CreateUser(ctx, user, overwriteDefault); err != nil {
|
||||||
panic(fmt.Errorf("CreateUser: %w", err))
|
panic(fmt.Errorf("createUser: %w", err))
|
||||||
}
|
}
|
||||||
log.Info("User created!")
|
log.Info("User created!")
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue