Skip to content

Commit

Permalink
fix: repost a reposted post
Browse files Browse the repository at this point in the history
  • Loading branch information
dexfs committed Apr 14, 2024
1 parent 090f68d commit ded836b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/application/usecases/createrepost.usecase.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
"errors"
"github.com/dexfs/go-twitter-clone/internal/domain"
"github.com/dexfs/go-twitter-clone/internal/domain/interfaces"
)
Expand Down Expand Up @@ -33,6 +34,11 @@ func (uc *CreateRepostUseCase) Execute(input CreateRepostUseCaseInput) (CreateRe
return CreateRepostUseCaseOutput{}, err
}

reposted := uc.postRepo.HasPostBeenRepostedByUser(input.PostID, input.UserID)
if reposted {
return CreateRepostUseCaseOutput{}, errors.New("it is not possible repost a repost post")
}

post, err := uc.postRepo.FindByID(input.PostID)
if err != nil {
return CreateRepostUseCaseOutput{}, err
Expand Down

0 comments on commit ded836b

Please sign in to comment.