mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Refactor addDeviceLink method
This commit is contained in:
parent
e5a67d6ce1
commit
ff162cb44d
9 changed files with 24 additions and 19 deletions
|
@ -7,6 +7,7 @@ import org.asamk.signal.commands.exceptions.CommandException;
|
|||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.api.DeviceLinkUrl;
|
||||
import org.asamk.signal.manager.api.InvalidDeviceLinkException;
|
||||
import org.asamk.signal.output.OutputWriter;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -45,7 +46,8 @@ public class AddDeviceCommand implements JsonRpcLocalCommand {
|
|||
}
|
||||
|
||||
try {
|
||||
m.addDeviceLink(linkUri);
|
||||
var deviceLinkUrl = DeviceLinkUrl.parseDeviceLinkUri(linkUri);
|
||||
m.addDeviceLink(deviceLinkUrl);
|
||||
} catch (IOException e) {
|
||||
logger.error("Add device link failed", e);
|
||||
throw new IOErrorException("Add device link failed", e);
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.asamk.signal.manager.api.AttachmentInvalidException;
|
|||
import org.asamk.signal.manager.api.Configuration;
|
||||
import org.asamk.signal.manager.api.Contact;
|
||||
import org.asamk.signal.manager.api.Device;
|
||||
import org.asamk.signal.manager.api.DeviceLinkUrl;
|
||||
import org.asamk.signal.manager.api.Group;
|
||||
import org.asamk.signal.manager.api.GroupId;
|
||||
import org.asamk.signal.manager.api.GroupInviteLinkUrl;
|
||||
|
@ -199,8 +200,8 @@ public class DbusManagerImpl implements Manager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addDeviceLink(final URI linkUri) throws IOException, InvalidDeviceLinkException {
|
||||
signal.addDevice(linkUri.toString());
|
||||
public void addDeviceLink(final DeviceLinkUrl linkUri) throws IOException, InvalidDeviceLinkException {
|
||||
signal.addDevice(linkUri.createDeviceLinkUri().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.asamk.Signal;
|
|||
import org.asamk.signal.BaseConfig;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.api.AttachmentInvalidException;
|
||||
import org.asamk.signal.manager.api.DeviceLinkUrl;
|
||||
import org.asamk.signal.manager.api.GroupId;
|
||||
import org.asamk.signal.manager.api.GroupInviteLinkUrl;
|
||||
import org.asamk.signal.manager.api.GroupLinkState;
|
||||
|
@ -173,7 +174,8 @@ public class DbusSignalImpl implements Signal {
|
|||
@Override
|
||||
public void addDevice(String uri) {
|
||||
try {
|
||||
m.addDeviceLink(new URI(uri));
|
||||
var deviceLinkUrl = DeviceLinkUrl.parseDeviceLinkUri(new URI(uri));
|
||||
m.addDeviceLink(deviceLinkUrl);
|
||||
} catch (IOException | InvalidDeviceLinkException e) {
|
||||
throw new Error.Failure(e.getClass().getSimpleName() + " Add device link failed. " + e.getMessage());
|
||||
} catch (URISyntaxException e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue