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

Method PerformDeviceCreation

userapi/internal/api.go:148–165  ·  view source on GitHub ↗
(ctx context.Context, req *api.PerformDeviceCreationRequest, res *api.PerformDeviceCreationResponse)

Source from the content-addressed store, hash-verified

146}
147
148func (a *UserInternalAPI) PerformDeviceCreation(ctx context.Context, req *api.PerformDeviceCreationRequest, res *api.PerformDeviceCreationResponse) error {
149 util.GetLogger(ctx).WithFields(logrus.Fields{
150 "localpart": req.Localpart,
151 "device_id": req.DeviceID,
152 "display_name": req.DeviceDisplayName,
153 }).Info("PerformDeviceCreation")
154 dev, err := a.DB.CreateDevice(ctx, req.Localpart, req.DeviceID, req.AccessToken, req.DeviceDisplayName, req.IPAddr, req.UserAgent)
155 if err != nil {
156 return err
157 }
158 res.DeviceCreated = true
159 res.Device = dev
160 if req.NoDeviceListUpdate {
161 return nil
162 }
163 // create empty device keys and upload them to trigger device list changes
164 return a.deviceListUpdate(dev.UserID, []string{dev.ID})
165}
166
167func (a *UserInternalAPI) PerformDeviceDeletion(ctx context.Context, req *api.PerformDeviceDeletionRequest, res *api.PerformDeviceDeletionResponse) error {
168 util.GetLogger(ctx).WithField("user_id", req.UserID).WithField("devices", req.DeviceIDs).Info("PerformDeviceDeletion")

Callers

nothing calls this directly

Calls 1

deviceListUpdateMethod · 0.95

Tested by

no test coverage detected