mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
parent
3c3d3e92dd
commit
debcabd014
3 changed files with 23 additions and 9 deletions
|
@ -27,7 +27,7 @@ public interface Signal extends DBusInterface {
|
||||||
|
|
||||||
List<String> getGroupMembers(byte[] groupId);
|
List<String> getGroupMembers(byte[] groupId);
|
||||||
|
|
||||||
void updateGroup(byte[] groupId, String name, List<String> members, String avatar) throws IOException, EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException;
|
byte[] updateGroup(byte[] groupId, String name, List<String> members, String avatar) throws IOException, EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException;
|
||||||
|
|
||||||
class MessageReceived extends DBusSignal {
|
class MessageReceived extends DBusSignal {
|
||||||
private long timestamp;
|
private long timestamp;
|
||||||
|
|
|
@ -460,11 +460,7 @@ public class Main {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "updateGroup":
|
case "updateGroup":
|
||||||
if (dBusConn != null) {
|
if (dBusConn == null && !m.isRegistered()) {
|
||||||
System.err.println("updateGroup is not yet implemented via dbus");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (!m.isRegistered()) {
|
|
||||||
System.err.println("User is not registered.");
|
System.err.println("User is not registered.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -474,8 +470,23 @@ public class Main {
|
||||||
if (ns.getString("group") != null) {
|
if (ns.getString("group") != null) {
|
||||||
groupId = decodeGroupId(ns.getString("group"));
|
groupId = decodeGroupId(ns.getString("group"));
|
||||||
}
|
}
|
||||||
byte[] newGroupId = m.sendUpdateGroupMessage(groupId, ns.getString("name"), ns.<String>getList("member"), ns.getString("avatar"));
|
|
||||||
if (groupId == null) {
|
if (groupId == null) {
|
||||||
|
groupId = new byte[0];
|
||||||
|
}
|
||||||
|
String groupName = ns.getString("name");
|
||||||
|
if (groupName == null) {
|
||||||
|
groupName = "";
|
||||||
|
}
|
||||||
|
List<String> groupMembers = ns.<String>getList("member");
|
||||||
|
if (groupMembers == null) {
|
||||||
|
groupMembers = new ArrayList<String>();
|
||||||
|
}
|
||||||
|
String groupAvatar = ns.getString("avatar");
|
||||||
|
if (groupAvatar == null) {
|
||||||
|
groupAvatar = "";
|
||||||
|
}
|
||||||
|
byte[] newGroupId = ts.updateGroup(groupId, groupName, groupMembers, groupAvatar);
|
||||||
|
if (groupId.length != newGroupId.length) {
|
||||||
System.out.println("Creating new group \"" + Base64.encodeBytes(newGroupId) + "\" …");
|
System.out.println("Creating new group \"" + Base64.encodeBytes(newGroupId) + "\" …");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -836,7 +836,10 @@ class Manager implements Signal {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateGroup(byte[] groupId, String name, List<String> members, String avatar) throws IOException, EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException {
|
public byte[] updateGroup(byte[] groupId, String name, List<String> members, String avatar) throws IOException, EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException {
|
||||||
|
if (groupId.length == 0) {
|
||||||
|
groupId = null;
|
||||||
|
}
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
name = null;
|
name = null;
|
||||||
}
|
}
|
||||||
|
@ -846,7 +849,7 @@ class Manager implements Signal {
|
||||||
if (avatar.isEmpty()) {
|
if (avatar.isEmpty()) {
|
||||||
avatar = null;
|
avatar = null;
|
||||||
}
|
}
|
||||||
sendUpdateGroupMessage(groupId, name, members, avatar);
|
return sendUpdateGroupMessage(groupId, name, members, avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void requestSyncGroups() throws IOException {
|
private void requestSyncGroups() throws IOException {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue