Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-22 09:54:24 +01:00

Panic on error, use correct function names

This commit is contained in:
erik 2023-12-05 14:54:03 +01:00 committed by Michael Jerger
parent 9dcbe0177e
commit ed1af14ceb

View file

@ -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 {