@@ -9,6 +9,7 @@ import (
|
||||
"git.aiterp.net/rpdata/api/internal/auth"
|
||||
"git.aiterp.net/rpdata/api/models"
|
||||
"git.aiterp.net/rpdata/api/models/characters"
|
||||
"git.aiterp.net/rpdata/api/models/logs"
|
||||
)
|
||||
|
||||
// Queries
|
||||
@@ -59,6 +60,8 @@ func (r *mutationResolver) AddCharacter(ctx context.Context, input input.Charact
|
||||
author = *input.Author
|
||||
}
|
||||
|
||||
logs.ScheduleFullUpdate()
|
||||
|
||||
return characters.Add(input.Nick, input.Name, shortName, author, description)
|
||||
}
|
||||
|
||||
@@ -77,6 +80,8 @@ func (r *mutationResolver) AddCharacterNick(ctx context.Context, input input.Cha
|
||||
return models.Character{}, errors.New("You are not permitted to edit this character")
|
||||
}
|
||||
|
||||
logs.ScheduleFullUpdate()
|
||||
|
||||
return characters.AddNick(character, input.Nick)
|
||||
}
|
||||
|
||||
@@ -91,6 +96,8 @@ func (r *mutationResolver) RemoveCharacterNick(ctx context.Context, input input.
|
||||
return models.Character{}, errors.New("You are not permitted to edit this character")
|
||||
}
|
||||
|
||||
logs.ScheduleFullUpdate()
|
||||
|
||||
return characters.RemoveNick(character, input.Nick)
|
||||
}
|
||||
|
||||
|
||||
+28
-1
@@ -52,7 +52,14 @@ func (r *mutationResolver) AddPost(ctx context.Context, input input.PostAddInput
|
||||
return models.Post{}, err
|
||||
}
|
||||
|
||||
return posts.Add(log, input.Time, input.Kind, input.Nick, input.Text)
|
||||
post, err := posts.Add(log, input.Time, input.Kind, input.Nick, input.Text)
|
||||
if err != nil {
|
||||
return models.Post{}, err
|
||||
}
|
||||
|
||||
go logs.UpdateCharacters(log)
|
||||
|
||||
return post, nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) EditPost(ctx context.Context, input input.PostEditInput) (models.Post, error) {
|
||||
@@ -66,6 +73,17 @@ func (r *mutationResolver) EditPost(ctx context.Context, input input.PostEditInp
|
||||
return models.Post{}, errors.New("Post not found")
|
||||
}
|
||||
|
||||
if input.Nick != nil {
|
||||
go func() {
|
||||
log, err := logs.FindID(post.LogID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
logs.UpdateCharacters(log)
|
||||
}()
|
||||
}
|
||||
|
||||
return posts.Edit(post, input.Time, input.Kind, input.Nick, input.Text)
|
||||
}
|
||||
|
||||
@@ -94,5 +112,14 @@ func (r *mutationResolver) RemovePost(ctx context.Context, input input.PostRemov
|
||||
return models.Post{}, errors.New("Post not found (before removing, of course)")
|
||||
}
|
||||
|
||||
go func() {
|
||||
log, err := logs.FindID(post.LogID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
logs.UpdateCharacters(log)
|
||||
}()
|
||||
|
||||
return posts.Remove(post)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user