Handle mentions when receiving from dbus

This commit is contained in:
AsamK 2024-01-22 18:40:39 +01:00
parent ac2343b142
commit ca1a852b44
2 changed files with 21 additions and 6 deletions

View file

@ -568,7 +568,7 @@
"name":"org.asamk.Signal", "name":"org.asamk.Signal",
"allDeclaredMethods":true, "allDeclaredMethods":true,
"allDeclaredClasses":true, "allDeclaredClasses":true,
"methods":[{"name":"getContactName","parameterTypes":["java.lang.String"] }, {"name":"getSelfNumber","parameterTypes":[] }, {"name":"sendGroupMessageReaction","parameterTypes":["java.lang.String","boolean","java.lang.String","long","byte[]"] }, {"name":"sendMessage","parameterTypes":["java.lang.String","java.util.List","java.lang.String"] }, {"name":"sendMessageReaction","parameterTypes":["java.lang.String","boolean","java.lang.String","long","java.util.List"] }, {"name":"subscribeReceive","parameterTypes":[] }, {"name":"unsubscribeReceive","parameterTypes":[] }] "methods":[{"name":"getContactName","parameterTypes":["java.lang.String"] }, {"name":"getGroup","parameterTypes":["byte[]"] }, {"name":"getSelfNumber","parameterTypes":[] }, {"name":"sendGroupMessageReaction","parameterTypes":["java.lang.String","boolean","java.lang.String","long","byte[]"] }, {"name":"sendMessage","parameterTypes":["java.lang.String","java.util.List","java.lang.String"] }, {"name":"sendMessageReaction","parameterTypes":["java.lang.String","boolean","java.lang.String","long","java.util.List"] }, {"name":"subscribeReceive","parameterTypes":[] }, {"name":"unsubscribeReceive","parameterTypes":[] }]
}, },
{ {
"name":"org.asamk.Signal$Configuration", "name":"org.asamk.Signal$Configuration",
@ -663,7 +663,8 @@
{ {
"name":"org.asamk.SignalControl", "name":"org.asamk.SignalControl",
"allDeclaredMethods":true, "allDeclaredMethods":true,
"allDeclaredClasses":true "allDeclaredClasses":true,
"methods":[{"name":"listAccounts","parameterTypes":[] }]
}, },
{ {
"name":"org.asamk.SignalControl$Error$Failure", "name":"org.asamk.SignalControl$Error$Failure",
@ -1815,7 +1816,8 @@
{ {
"name":"org.freedesktop.dbus.interfaces.Properties", "name":"org.freedesktop.dbus.interfaces.Properties",
"allDeclaredMethods":true, "allDeclaredMethods":true,
"allDeclaredClasses":true "allDeclaredClasses":true,
"methods":[{"name":"GetAll","parameterTypes":["java.lang.String"] }]
}, },
{ {
"name":"org.freedesktop.dbus.interfaces.Properties$PropertiesChanged", "name":"org.freedesktop.dbus.interfaces.Properties$PropertiesChanged",

View file

@ -849,7 +849,7 @@ public class DbusManagerImpl implements Manager {
Optional.empty(), Optional.empty(),
Optional.empty(), Optional.empty(),
List.of(), List.of(),
List.of(), getMentions(extras),
List.of(), List.of(),
List.of())), List.of())),
Optional.empty(), Optional.empty(),
@ -893,7 +893,7 @@ public class DbusManagerImpl implements Manager {
Optional.empty(), Optional.empty(),
Optional.empty(), Optional.empty(),
List.of(), List.of(),
List.of(), getMentions(extras),
List.of(), List.of(),
List.of()))), List.of()))),
Optional.empty(), Optional.empty(),
@ -970,7 +970,7 @@ public class DbusManagerImpl implements Manager {
Optional.empty(), Optional.empty(),
Optional.empty(), Optional.empty(),
List.of(), List.of(),
List.of(), getMentions(extras),
List.of(), List.of(),
List.of())), List.of())),
Optional.empty(), Optional.empty(),
@ -1039,6 +1039,19 @@ public class DbusManagerImpl implements Manager {
}).toList(); }).toList();
} }
private List<MessageEnvelope.Data.Mention> getMentions(final Map<String, Variant<?>> extras) {
if (!extras.containsKey("mentions")) {
return List.of();
}
final List<DBusMap<String, Variant<?>>> mentions = getValue(extras, "mentions");
return mentions.stream()
.map(a -> new MessageEnvelope.Data.Mention(new RecipientAddress(null, getValue(a, "recipient")),
getValue(a, "start"),
getValue(a, "length")))
.toList();
}
@Override @Override
public InputStream retrieveAttachment(final String id) throws IOException { public InputStream retrieveAttachment(final String id) throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();