feat(follow): refactor is followed

This commit is contained in:
LinkinStars 2023-05-29 11:14:57 +08:00
parent a0b5f882ad
commit 184a04c245
2 changed files with 7 additions and 3 deletions

View File

@ -110,8 +110,13 @@ func (ar *FollowRepo) GetFollowIDs(ctx context.Context, userID, objectKey string
}
// IsFollowed check user if follow object or not
func (ar *FollowRepo) IsFollowed(ctx context.Context, userID, objectID string) (bool, error) {
activityType, _, _, err := ar.activityRepo.GetActivityTypeByObjID(ctx, objectID, "follow")
func (ar *FollowRepo) IsFollowed(ctx context.Context, userID, objectID string) (followed bool, err error) {
objectKey, err := obj.GetObjectTypeStrByObjectID(objectID)
if err != nil {
return false, err
}
activityType, err := ar.activityRepo.GetActivityTypeByObjKey(ctx, objectKey, "follow")
if err != nil {
return false, err
}

View File

@ -30,7 +30,6 @@ func (vr *VoteRepo) GetVoteStatus(ctx context.Context, objectID, userID string)
at := &entity.Activity{}
activityType, _, _, err := vr.activityRepo.GetActivityTypeByObjID(ctx, objectID, action)
if err != nil {
log.Error(err)
return ""
}
has, err := vr.data.DB.Context(ctx).Where("object_id =? AND cancelled=0 AND activity_type=? AND user_id=?", objectID, activityType, userID).Get(at)