Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

users cannot send to groups except when they are responding #5

Open
Trolldemorted opened this issue Dec 1, 2017 · 1 comment
Open

Comments

@Trolldemorted
Copy link

signal4j does not offer (?) a way to send messages to groups, if the user knows only the groupid, because signal4j won't tell you the group's members.

In the sample plugins this works nicely as they only respond to group messages and thus get a handle to the group object, but a plugin that wants to send messages without receiving some does not.

I have added a new sendMessage overload to SignalService to have a dirty workaround:

public void sendMessage(String groupId, String content) throws IOException {
    byte[] id = Base64.decode(groupId);
    Group group = store.getDataStore().getGroup(new GroupId(id));
    SignalServiceDataMessage message = SignalServiceDataMessage.newBuilder()
        .withTimestamp(System.currentTimeMillis())
        .asGroupMessage(SignalServiceGroup.newBuilder(Type.DELIVER)
            .withId(group.getId().getId())
            .build())
        .withBody(content)
        .withExpiration(group.getMessageExpirationTime())
        .build();
   sendMessage(group.getMembers(), message);
}

What did you intend?

@Turakar
Copy link
Owner

Turakar commented Mar 30, 2018

I intend that you keep the Group object as a handle for later reference instead of the group id. However, I understand that this would need an additional serialization process outside the library. Maybe it would be better to provide a function for getting the associated Group object from the groupId, maybe in DataStore. Additional methods for User etc. should be taken in consideration.

This would allow an application to only save the ids.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants