@@ -258,11 +258,6 @@ func (r *postRepository) Delete(ctx context.Context, post models.Post) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = q.DeletePost(ctx, post.ID)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = q.ShiftPostsAfter(ctx, psqlcore.ShiftPostsAfterParams{
|
err = q.ShiftPostsAfter(ctx, psqlcore.ShiftPostsAfterParams{
|
||||||
ShiftOffset: -1,
|
ShiftOffset: -1,
|
||||||
LogShortID: post.LogID,
|
LogShortID: post.LogID,
|
||||||
@@ -272,6 +267,11 @@ func (r *postRepository) Delete(ctx context.Context, post models.Post) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = q.DeletePost(ctx, post.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
err = tx.Commit()
|
err = tx.Commit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
+8
-1
@@ -56,7 +56,7 @@ func (s *AuthService) FindKey(ctx context.Context, id string) (*models.Key, erro
|
|||||||
return s.keys.Find(ctx, id)
|
return s.keys.Find(ctx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindKey finds a key by id.
|
// FindUser finds a user by id.
|
||||||
func (s *AuthService) FindUser(ctx context.Context, id string) (*models.User, error) {
|
func (s *AuthService) FindUser(ctx context.Context, id string) (*models.User, error) {
|
||||||
return s.users.Find(ctx, id)
|
return s.users.Find(ctx, id)
|
||||||
}
|
}
|
||||||
@@ -154,6 +154,13 @@ func (s *AuthService) TokenFromContext(ctx context.Context) *models.Token {
|
|||||||
return token
|
return token
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SpinOffContext adds the auth token to a background context.
|
||||||
|
func (s *AuthService) SpinOffContext(ctx context.Context) context.Context {
|
||||||
|
token := s.TokenFromContext(ctx)
|
||||||
|
|
||||||
|
return context.WithValue(context.Background(), contextKey, &token)
|
||||||
|
}
|
||||||
|
|
||||||
// RequestWithToken either returns the request, or the request with a new context that
|
// RequestWithToken either returns the request, or the request with a new context that
|
||||||
// has the token.
|
// has the token.
|
||||||
func (s *AuthService) RequestWithToken(r *http.Request) *http.Request {
|
func (s *AuthService) RequestWithToken(r *http.Request) *http.Request {
|
||||||
|
|||||||
@@ -484,6 +484,7 @@ func (s *LogService) EditPost(ctx context.Context, id string, update models.Post
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx = s.authService.SpinOffContext(ctx)
|
||||||
go func() {
|
go func() {
|
||||||
l, err := s.logs.Find(context.Background(), post.LogID)
|
l, err := s.logs.Find(context.Background(), post.LogID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user