Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Signal-Server
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
GitHub Mirror
Signal
Signal-Server
Commits
010eadcd
Unverified
Commit
010eadcd
authored
Oct 3, 2023
by
Jonathan Klabunde Tomer
Committed by
GitHub
Oct 3, 2023
Browse files
Options
Downloads
Patches
Plain Diff
UnlinkDeviceCommand improvements
parent
c43e0b54
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
service/src/main/java/org/whispersystems/textsecuregcm/workers/UnlinkDeviceCommand.java
+31
-20
31 additions, 20 deletions
...persystems/textsecuregcm/workers/UnlinkDeviceCommand.java
with
31 additions
and
20 deletions
service/src/main/java/org/whispersystems/textsecuregcm/workers/UnlinkDeviceCommand.java
+
31
−
20
View file @
010eadcd
...
@@ -9,7 +9,10 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
...
@@ -9,7 +9,10 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import
io.dropwizard.Application
;
import
io.dropwizard.Application
;
import
io.dropwizard.cli.EnvironmentCommand
;
import
io.dropwizard.cli.EnvironmentCommand
;
import
io.dropwizard.setup.Environment
;
import
io.dropwizard.setup.Environment
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.UUID
;
import
net.sourceforge.argparse4j.impl.Arguments
;
import
net.sourceforge.argparse4j.inf.Namespace
;
import
net.sourceforge.argparse4j.inf.Namespace
;
import
net.sourceforge.argparse4j.inf.Subparser
;
import
net.sourceforge.argparse4j.inf.Subparser
;
import
org.whispersystems.textsecuregcm.WhisperServerConfiguration
;
import
org.whispersystems.textsecuregcm.WhisperServerConfiguration
;
...
@@ -32,8 +35,9 @@ public class UnlinkDeviceCommand extends EnvironmentCommand<WhisperServerConfigu
...
@@ -32,8 +35,9 @@ public class UnlinkDeviceCommand extends EnvironmentCommand<WhisperServerConfigu
super
.
configure
(
subparser
);
super
.
configure
(
subparser
);
subparser
.
addArgument
(
"-d"
,
"--deviceId"
)
subparser
.
addArgument
(
"-d"
,
"--deviceId"
)
.
dest
(
"deviceId"
)
.
dest
(
"deviceId
s
"
)
.
type
(
Long
.
class
)
.
type
(
Long
.
class
)
.
action
(
Arguments
.
append
())
.
required
(
true
);
.
required
(
true
);
subparser
.
addArgument
(
"-u"
,
"--uuid"
)
subparser
.
addArgument
(
"-u"
,
"--uuid"
)
...
@@ -48,18 +52,23 @@ public class UnlinkDeviceCommand extends EnvironmentCommand<WhisperServerConfigu
...
@@ -48,18 +52,23 @@ public class UnlinkDeviceCommand extends EnvironmentCommand<WhisperServerConfigu
final
WhisperServerConfiguration
configuration
)
throws
Exception
{
final
WhisperServerConfiguration
configuration
)
throws
Exception
{
environment
.
getObjectMapper
().
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
environment
.
getObjectMapper
().
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
final
CommandStopListener
commandStopListener
=
new
CommandStopListener
(
configuration
.
getCommandStopListener
());
try
{
commandStopListener
.
start
();
final
UUID
aci
=
UUID
.
fromString
(
namespace
.
getString
(
"uuid"
).
trim
());
final
UUID
aci
=
UUID
.
fromString
(
namespace
.
getString
(
"uuid"
).
trim
());
final
l
ong
deviceId
=
namespace
.
getL
ong
(
"deviceId"
);
final
List
<
L
ong
>
deviceId
s
=
namespace
.
getL
ist
(
"deviceId
s
"
);
final
CommandDependencies
deps
=
CommandDependencies
.
build
(
"unlink-device"
,
environment
,
configuration
);
final
CommandDependencies
deps
=
CommandDependencies
.
build
(
"unlink-device"
,
environment
,
configuration
);
Account
account
=
deps
.
accountsManager
().
getByAccountIdentifier
(
aci
)
Account
account
=
deps
.
accountsManager
().
getByAccountIdentifier
(
aci
)
.
orElseThrow
(()
->
new
IllegalArgumentException
(
"account id "
+
aci
+
" does not exist"
));
.
orElseThrow
(()
->
new
IllegalArgumentException
(
"account id "
+
aci
+
" does not exist"
));
if
(
deviceId
==
Device
.
MASTER_ID
)
{
if
(
deviceId
s
.
contains
(
Device
.
MASTER_ID
)
)
{
throw
new
IllegalArgumentException
(
"cannot delete primary device"
);
throw
new
IllegalArgumentException
(
"cannot delete primary device"
);
}
}
for
(
long
deviceId
:
deviceIds
)
{
/** see {@link org.whispersystems.textsecuregcm.controllers.DeviceController#removeDevice} */
/** see {@link org.whispersystems.textsecuregcm.controllers.DeviceController#removeDevice} */
System
.
out
.
format
(
"Removing device %s::%d\n"
,
aci
,
deviceId
);
System
.
out
.
format
(
"Removing device %s::%d\n"
,
aci
,
deviceId
);
account
=
deps
.
accountsManager
().
update
(
account
,
a
->
a
.
removeDevice
(
deviceId
));
account
=
deps
.
accountsManager
().
update
(
account
,
a
->
a
.
removeDevice
(
deviceId
));
...
@@ -74,7 +83,9 @@ public class UnlinkDeviceCommand extends EnvironmentCommand<WhisperServerConfigu
...
@@ -74,7 +83,9 @@ public class UnlinkDeviceCommand extends EnvironmentCommand<WhisperServerConfigu
deps
.
clientPresenceManager
().
disconnectPresence
(
aci
,
deviceId
);
deps
.
clientPresenceManager
().
disconnectPresence
(
aci
,
deviceId
);
System
.
out
.
format
(
"Device %s::%d successfully removed\n"
,
aci
,
deviceId
);
System
.
out
.
format
(
"Device %s::%d successfully removed\n"
,
aci
,
deviceId
);
}
}
finally
{
commandStopListener
.
stop
();
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment