use of org.whispersystems.signalservice.api.messages.multidevice.StickerPackOperationMessage in project Signal-Android by WhisperSystems.
the class MultiDeviceStickerPackSyncJob method onRun.
@Override
protected void onRun() throws Exception {
if (!Recipient.self().isRegistered()) {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
Log.i(TAG, "Not multi device, aborting...");
return;
}
List<StickerPackOperationMessage> operations = new LinkedList<>();
try (StickerPackRecordReader reader = new StickerPackRecordReader(SignalDatabase.stickers().getInstalledStickerPacks())) {
StickerPackRecord pack;
while ((pack = reader.getNext()) != null) {
byte[] packIdBytes = Hex.fromStringCondensed(pack.getPackId());
byte[] packKeyBytes = Hex.fromStringCondensed(pack.getPackKey());
operations.add(new StickerPackOperationMessage(packIdBytes, packKeyBytes, StickerPackOperationMessage.Type.INSTALL));
}
}
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
messageSender.sendSyncMessage(SignalServiceSyncMessage.forStickerPackOperations(operations), UnidentifiedAccessUtil.getAccessForSync(context));
}
use of org.whispersystems.signalservice.api.messages.multidevice.StickerPackOperationMessage in project Signal-Android by WhisperSystems.
the class MultiDeviceStickerPackOperationJob method onRun.
@Override
protected void onRun() throws Exception {
if (!TextSecurePreferences.isMultiDevice(context)) {
Log.i(TAG, "Not multi device, aborting...");
return;
}
byte[] packIdBytes = Hex.fromStringCondensed(packId);
byte[] packKeyBytes = Hex.fromStringCondensed(packKey);
StickerPackOperationMessage.Type remoteType;
switch(type) {
case INSTALL:
remoteType = StickerPackOperationMessage.Type.INSTALL;
break;
case REMOVE:
remoteType = StickerPackOperationMessage.Type.REMOVE;
break;
default:
throw new AssertionError("No matching type?");
}
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
StickerPackOperationMessage stickerPackOperation = new StickerPackOperationMessage(packIdBytes, packKeyBytes, remoteType);
messageSender.sendSyncMessage(SignalServiceSyncMessage.forStickerPackOperations(Collections.singletonList(stickerPackOperation)), UnidentifiedAccessUtil.getAccessForSync(context));
}
use of org.whispersystems.signalservice.api.messages.multidevice.StickerPackOperationMessage in project Signal-Android by WhisperSystems.
the class SignalServiceMessageSender method createMultiDeviceStickerPackOperationContent.
private Content createMultiDeviceStickerPackOperationContent(List<StickerPackOperationMessage> stickerPackOperations) {
Content.Builder container = Content.newBuilder();
SyncMessage.Builder syncMessage = createSyncMessageBuilder();
for (StickerPackOperationMessage stickerPackOperation : stickerPackOperations) {
SyncMessage.StickerPackOperation.Builder builder = SyncMessage.StickerPackOperation.newBuilder();
if (stickerPackOperation.getPackId().isPresent()) {
builder.setPackId(ByteString.copyFrom(stickerPackOperation.getPackId().get()));
}
if (stickerPackOperation.getPackKey().isPresent()) {
builder.setPackKey(ByteString.copyFrom(stickerPackOperation.getPackKey().get()));
}
if (stickerPackOperation.getType().isPresent()) {
switch(stickerPackOperation.getType().get()) {
case INSTALL:
builder.setType(SyncMessage.StickerPackOperation.Type.INSTALL);
break;
case REMOVE:
builder.setType(SyncMessage.StickerPackOperation.Type.REMOVE);
break;
}
}
syncMessage.addStickerPackOperation(builder);
}
return container.setSyncMessage(syncMessage).build();
}
use of org.whispersystems.signalservice.api.messages.multidevice.StickerPackOperationMessage in project Signal-Android by signalapp.
the class SignalServiceMessageSender method createMultiDeviceStickerPackOperationContent.
private Content createMultiDeviceStickerPackOperationContent(List<StickerPackOperationMessage> stickerPackOperations) {
Content.Builder container = Content.newBuilder();
SyncMessage.Builder syncMessage = createSyncMessageBuilder();
for (StickerPackOperationMessage stickerPackOperation : stickerPackOperations) {
SyncMessage.StickerPackOperation.Builder builder = SyncMessage.StickerPackOperation.newBuilder();
if (stickerPackOperation.getPackId().isPresent()) {
builder.setPackId(ByteString.copyFrom(stickerPackOperation.getPackId().get()));
}
if (stickerPackOperation.getPackKey().isPresent()) {
builder.setPackKey(ByteString.copyFrom(stickerPackOperation.getPackKey().get()));
}
if (stickerPackOperation.getType().isPresent()) {
switch(stickerPackOperation.getType().get()) {
case INSTALL:
builder.setType(SyncMessage.StickerPackOperation.Type.INSTALL);
break;
case REMOVE:
builder.setType(SyncMessage.StickerPackOperation.Type.REMOVE);
break;
}
}
syncMessage.addStickerPackOperation(builder);
}
return container.setSyncMessage(syncMessage).build();
}
use of org.whispersystems.signalservice.api.messages.multidevice.StickerPackOperationMessage in project Signal-Android by signalapp.
the class MultiDeviceStickerPackSyncJob method onRun.
@Override
protected void onRun() throws Exception {
if (!Recipient.self().isRegistered()) {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
Log.i(TAG, "Not multi device, aborting...");
return;
}
List<StickerPackOperationMessage> operations = new LinkedList<>();
try (StickerPackRecordReader reader = new StickerPackRecordReader(SignalDatabase.stickers().getInstalledStickerPacks())) {
StickerPackRecord pack;
while ((pack = reader.getNext()) != null) {
byte[] packIdBytes = Hex.fromStringCondensed(pack.getPackId());
byte[] packKeyBytes = Hex.fromStringCondensed(pack.getPackKey());
operations.add(new StickerPackOperationMessage(packIdBytes, packKeyBytes, StickerPackOperationMessage.Type.INSTALL));
}
}
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
messageSender.sendSyncMessage(SignalServiceSyncMessage.forStickerPackOperations(operations), UnidentifiedAccessUtil.getAccessForSync(context));
}
Aggregations