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

add sendMessage() api for exporting data to saved-messages #2555

Closed
wants to merge 4 commits into from

Conversation

r10s
Copy link
Member

@r10s r10s commented May 5, 2023

sendMessage takes an object with blob, fileName, text as parameters, currently, the message is always sent to the saved-messages chat, for the future, we consider to allow sending to the webxdc's source chat as well, therefore the broader name

TODO:

  • settle api, maybe return a promise so we can let the user confirm when it comes to sending to another chat

at webxdc/webxdc-test#9 there is a test for the sendMessage api

targets deltachat/deltachat-core-rust#4350

@github-actions
Copy link

github-actions bot commented May 5, 2023

To test the changes in this pull request, install this apk:
📦 app-preview.apk

@Simon-Laux
Copy link
Member

Simon-Laux commented May 6, 2023

I think returning a promise makes sense, so apps could show a progress/busy spinner and hide it again once the export is complete.

Also I'm not sure about naming the function sendMessage, does it work now without a file? (code says no), also the naming kinda implies that it is send to the chat. maybe sth like "exportFile" or "exportFileToChat"

try {
JSONObject jsonObject = new JSONObject(payload);
byte[] data = Base64.decode(jsonObject.getString("__blobBase64"), Base64.NO_WRAP | Base64.NO_PADDING);
String[] fileName = jsonObject.getString("fileName").split("\\.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks dangerous, maybe use https://docs.oracle.com/javase/6/docs/api/java/lang/String.html#split%28java.lang.String,%20int%29 to split at most in two strings, and probably also check the case where the filename has no dot "." (no extension) at all

@github-actions
Copy link

To test the changes in this pull request, install this apk:
📦 app-preview.apk

@adbenitez
Copy link
Member

closing in favor of #2571

@adbenitez adbenitez closed this May 29, 2023
@adbenitez adbenitez deleted the export-from-webxdc branch October 11, 2023 14:32
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

Successfully merging this pull request may close these issues.

None yet

3 participants