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

Method InputAccountData

userapi/internal/api.go:60–89  ·  view source on GitHub ↗
(ctx context.Context, req *api.InputAccountDataRequest, res *api.InputAccountDataResponse)

Source from the content-addressed store, hash-verified

58}
59
60func (a *UserInternalAPI) InputAccountData(ctx context.Context, req *api.InputAccountDataRequest, res *api.InputAccountDataResponse) error {
61 local, domain, err := gomatrixserverlib.SplitID('@', req.UserID)
62 if err != nil {
63 return err
64 }
65 if domain != a.ServerName {
66 return fmt.Errorf("cannot query profile of remote users: got %s want %s", domain, a.ServerName)
67 }
68 if req.DataType == "" {
69 return fmt.Errorf("data type must not be empty")
70 }
71 if err := a.DB.SaveAccountData(ctx, local, req.RoomID, req.DataType, req.AccountData); err != nil {
72 util.GetLogger(ctx).WithError(err).Error("a.DB.SaveAccountData failed")
73 return fmt.Errorf("failed to save account data: %w", err)
74 }
75 var ignoredUsers *synctypes.IgnoredUsers
76 if req.DataType == "m.ignored_user_list" {
77 ignoredUsers = &synctypes.IgnoredUsers{}
78 _ = json.Unmarshal(req.AccountData, ignoredUsers)
79 }
80 if err := a.SyncProducer.SendAccountData(req.UserID, eventutil.AccountData{
81 RoomID: req.RoomID,
82 Type: req.DataType,
83 IgnoredUsers: ignoredUsers,
84 }); err != nil {
85 util.GetLogger(ctx).WithError(err).Error("a.SyncProducer.SendAccountData failed")
86 return fmt.Errorf("failed to send account data to output: %w", err)
87 }
88 return nil
89}
90
91func (a *UserInternalAPI) PerformAccountCreation(ctx context.Context, req *api.PerformAccountCreationRequest, res *api.PerformAccountCreationResponse) error {
92 acc, err := a.DB.CreateAccount(ctx, req.Localpart, req.Password, req.AppServiceID, req.AccountType)

Callers 1

PerformPushRulesPutMethod · 0.95

Calls 2

SendAccountDataMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected