Add HTTP /v1 MVC, TCP send path, groups with server-side member-avatar collage, object-storage upload, and friends/favorites around the architecture-v3 layout. Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
626 B
Go
32 lines
626 B
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"spark-server/internal/pkg/errs"
|
|
)
|
|
|
|
func (s *Service) CanSend(ctx context.Context, fromUserID, toUserID int64) error {
|
|
if !s.ready() || fromUserID <= 0 || toUserID <= 0 {
|
|
return errs.ErrForbidden
|
|
}
|
|
if fromUserID == toUserID {
|
|
return errs.ErrForbidden
|
|
}
|
|
if _, err := s.repo.GetRelation(ctx, fromUserID, toUserID); err != nil {
|
|
if errors.Is(err, errs.ErrNotFound) {
|
|
return errs.ErrForbidden
|
|
}
|
|
return err
|
|
}
|
|
blocked, err := s.repo.BlockedEither(ctx, fromUserID, toUserID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if blocked {
|
|
return errs.ErrForbidden
|
|
}
|
|
return nil
|
|
}
|