mirror of
https://github.com/mautrix/signal.git
synced 2025-03-14 14:15:36 +00:00
client: unlink device when logging out
This commit is contained in:
parent
dceab3c8b3
commit
3db54fd574
2 changed files with 18 additions and 0 deletions
|
@ -90,6 +90,10 @@ func (s *SignalClient) LogoutRemote(ctx context.Context) {
|
|||
if err != nil {
|
||||
zerolog.Ctx(ctx).Err(err).Msg("Failed to stop receive loops for logout")
|
||||
}
|
||||
err = s.Client.Unlink(ctx)
|
||||
if err != nil {
|
||||
zerolog.Ctx(ctx).Err(err).Msg("Failed to unlink device")
|
||||
}
|
||||
err = s.Main.Store.DeleteDevice(context.TODO(), &s.Client.Store.DeviceData)
|
||||
if err != nil {
|
||||
zerolog.Ctx(ctx).Err(err).Msg("Failed to delete device from store")
|
||||
|
|
|
@ -385,6 +385,20 @@ func (cli *Client) RegisterCapabilities(ctx context.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (cli *Client) Unlink(ctx context.Context) error {
|
||||
username, password := cli.Store.BasicAuthCreds()
|
||||
resp, err := web.SendHTTPRequest(ctx, http.MethodDelete, fmt.Sprintf("/v1/devices/%d", cli.Store.DeviceID), &web.HTTPReqOpt{
|
||||
Username: &username,
|
||||
Password: &password,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
} else if resp.StatusCode >= 400 {
|
||||
return fmt.Errorf("unexpected status code %d", resp.StatusCode)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func confirmDevice(
|
||||
ctx context.Context,
|
||||
username string,
|
||||
|
|
Loading…
Add table
Reference in a new issue