A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
feat(follow): refactor is followed
LinkinStars184a04c245fc
diff --git a/internal/repo/activity_common/follow.go b/internal/repo/activity_common/follow.goindex fdcf5fbd..11b5763c 100644--- a/internal/repo/activity_common/follow.go+++ b/internal/repo/activity_common/follow.go@@ -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}diff --git a/internal/repo/activity_common/vote.go b/internal/repo/activity_common/vote.goindex d9986cab..56c33798 100644--- a/internal/repo/activity_common/vote.go+++ b/internal/repo/activity_common/vote.go@@ -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)