spark-server/internal/module/friend/logic/pin.go
2026-09-18 14:50:41 +08:00

26 lines
627 B
Go

package logic
import (
"context"
"spark-server/internal/pkg/errs"
)
func (s *Service) Pin(ctx context.Context, userID, friendID int64) error {
return s.setPinned(ctx, userID, friendID, true)
}
func (s *Service) Unpin(ctx context.Context, userID, friendID int64) error {
return s.setPinned(ctx, userID, friendID, false)
}
func (s *Service) setPinned(ctx context.Context, userID, friendID int64, pinned bool) error {
if !s.ready() || userID <= 0 {
return errs.ErrUnauthorized
}
if err := s.requireFriend(ctx, userID, friendID); err != nil {
return err
}
return s.repo.SetPinned(ctx, userID, friendID, pinned)
}