MCPcopy Create free account
hub / github.com/OpenCSGs/csghub-server / Spaces

Method Spaces

component/user.go:227–253  ·  view source on GitHub ↗
(ctx context.Context, req *types.UserSpacesReq)

Source from the content-addressed store, hash-verified

225}
226
227func (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
255func (c *UserComponent) AddLikes(ctx context.Context, req *types.UserLikesRequest) error {
256 user, err := c.us.FindByUsername(ctx, req.CurrentUser)

Callers

nothing calls this directly

Calls 3

ErrorMethod · 0.80
UserSpacesMethod · 0.80
IsExistMethod · 0.45

Tested by

no test coverage detected