MCPcopy Create free account
hub / github.com/daodst/chat / QueryAccountData

Method QueryAccountData

userapi/internal/api.go:377–412  ·  view source on GitHub ↗
(ctx context.Context, req *api.QueryAccountDataRequest, res *api.QueryAccountDataResponse)

Source from the content-addressed store, hash-verified

375}
376
377func (a *UserInternalAPI) QueryAccountData(ctx context.Context, req *api.QueryAccountDataRequest, res *api.QueryAccountDataResponse) error {
378 local, domain, err := gomatrixserverlib.SplitID('@', req.UserID)
379 if err != nil {
380 return err
381 }
382 if domain != a.ServerName {
383 return fmt.Errorf("cannot query account data of remote users: got %s want %s", domain, a.ServerName)
384 }
385 if req.DataType != "" {
386 var data json.RawMessage
387 data, err = a.DB.GetAccountDataByType(ctx, local, req.RoomID, req.DataType)
388 if err != nil {
389 return err
390 }
391 res.RoomAccountData = make(map[string]map[string]json.RawMessage)
392 res.GlobalAccountData = make(map[string]json.RawMessage)
393 if data != nil {
394 if req.RoomID != "" {
395 if _, ok := res.RoomAccountData[req.RoomID]; !ok {
396 res.RoomAccountData[req.RoomID] = make(map[string]json.RawMessage)
397 }
398 res.RoomAccountData[req.RoomID][req.DataType] = data
399 } else {
400 res.GlobalAccountData[req.DataType] = data
401 }
402 }
403 return nil
404 }
405 global, rooms, err := a.DB.GetAccountData(ctx, local)
406 if err != nil {
407 return err
408 }
409 res.RoomAccountData = rooms
410 res.GlobalAccountData = global
411 return nil
412}
413
414func (a *UserInternalAPI) QueryAccessToken(ctx context.Context, req *api.QueryAccessTokenRequest, res *api.QueryAccessTokenResponse) error {
415 if req.AppServiceUserID != "" {

Callers 1

QueryPushRulesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected