Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dkovacevic committed Jul 11, 2023
1 parent 7305091 commit 090521e
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions backend/src/main/java/com/wire/bots/roman/Sender.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,21 @@ private UUID sendPicture(IncomingMessage message, UUID botId) throws Exception {

wireClient.send(preview);

AssetBase asset;
ImageAsset image;
if (message.attachment.meta != null) {
asset = new ImageAsset(preview.getMessageId(), null, attachment.mimeType);
setAssetMetadata(asset, message.attachment.meta);
image = new ImageAsset(preview.getMessageId(), new byte[0], attachment.mimeType);
setAssetMetadata(image, message.attachment.meta);
} else if (message.attachment.data != null) {
final byte[] bytes = Base64.getDecoder().decode(message.attachment.data);
asset = new ImageAsset(messageId, bytes, attachment.mimeType);
asset.setMessageId(messageId);
uploadAssetData(wireClient, asset);
image = new ImageAsset(messageId, bytes, attachment.mimeType);
image.setMessageId(messageId);
uploadAssetData(wireClient, image);
} else {
throw new Exception("Meta or Data need to be set");
}

wireClient.send(asset);
return asset.getMessageId();
wireClient.send(image);
return image.getMessageId();
}
}

Expand Down Expand Up @@ -225,10 +225,7 @@ public Conversation getConversation(UUID botId) throws IOException, CryptoExcept
}
}

private void setAssetMetadata(AssetBase asset, @Nullable AssetMeta meta) {
if (meta == null)
return;

private void setAssetMetadata(AssetBase asset, AssetMeta meta) {
asset.setAssetKey(meta.assetId);
asset.setAssetToken(meta.assetToken);
asset.setSha256(Base64.getDecoder().decode(meta.sha256));
Expand Down

0 comments on commit 090521e

Please sign in to comment.