(ctx context.Context, req *types.UserSpacesReq)
| 225 | } |
| 226 | |
| 227 | func (c *UserComponent) Spaces(ctx context.Context, req *types.UserSpacesReq) ([]types.Space, int, error) { |
| 228 | userExists, err := c.us.IsExist(ctx, req.Owner) |
| 229 | if err != nil { |
| 230 | newError := fmt.Errorf("failed to check for the presence of the user,error:%w", err) |
| 231 | slog.Error(newError.Error()) |
| 232 | return nil, 0, newError |
| 233 | } |
| 234 | |
| 235 | if !userExists { |
| 236 | return nil, 0, errors.New("user not exists") |
| 237 | } |
| 238 | |
| 239 | if req.CurrentUser != "" { |
| 240 | cuserExists, err := c.us.IsExist(ctx, req.CurrentUser) |
| 241 | if err != nil { |
| 242 | newError := fmt.Errorf("failed to check for the presence of current user,error:%w", err) |
| 243 | slog.Error(newError.Error()) |
| 244 | return nil, 0, newError |
| 245 | } |
| 246 | |
| 247 | if !cuserExists { |
| 248 | return nil, 0, errors.New("current user not exists") |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | return c.spaceComponent.UserSpaces(ctx, req) |
| 253 | } |
| 254 | |
| 255 | func (c *UserComponent) AddLikes(ctx context.Context, req *types.UserLikesRequest) error { |
| 256 | user, err := c.us.FindByUsername(ctx, req.CurrentUser) |
nothing calls this directly
no test coverage detected