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 command to get an attachment #1080

Merged
merged 7 commits into from
Nov 1, 2022

Conversation

ced-b
Copy link
Contributor

@ced-b ced-b commented Oct 31, 2022

As gone over in #1078 here is a separate pull request on pulling attachment data.

The following command line command will write the Base64 string to the console:

signal-cli attachment --file-id=eBOlTUfsV4aD7KKXBnKr --file-name=cat.gif --content-type=image/gif

The following JSON RPC request will pull up the attachment in the following format:

{
    "jsonrpc": "2.0",
    "method": "attachment",
    "params": {
        "fileId": "eBOlTUfsV4aD7KKXBnKr",
        "fileName": "cat.gif",
        "contentType": "image/gif"
    }
}

Response:

{"jsonrpc":"2.0","result":{"dataBase64":"BASE64"}}

The actual command implementation was simple. However, the trick was to get access to the actual attachment through the attachment store. The best way I found was through the Manager instance passed to the command. To not have to expose all the guts of the manager etc. I wired this through the AttachmentHelper and to the AttachmentStore. Where this got a bit messy is the DbusManagerImpl as this would need to expose the function to get an attachment, but I did not see anything in that class for handling attachments really. Maybe you have a better idea of how to implement this.

Copy link
Owner

@AsamK AsamK left a comment

Choose a reason for hiding this comment

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

Looks good in general, I've added some comments for specifics.

Also please add the command to the man page: https://github.com/AsamK/signal-cli/blob/master/man/signal-cli.1.adoc

@ced-b
Copy link
Contributor Author

ced-b commented Nov 1, 2022

@AsamK I'm just writing the doc but I'm not sure that calling the parameter recipient makes fully sense. Would it be originator?

I guess generally the external number is referred to as recipient so maybe it's fine, but just wanted to throw that out.

@AsamK
Copy link
Owner

AsamK commented Nov 1, 2022

@AsamK I'm just writing the doc but I'm not sure that calling the parameter recipient makes fully sense. Would it be originator?

I guess generally the external number is referred to as recipient so maybe it's fine, but just wanted to throw that out.

Yeah, recipient is not the best name here, but it's also used in the other commands. So I thiink it's ok to use it here as well to keep it consistent.

Copy link
Owner

@AsamK AsamK left a comment

Choose a reason for hiding this comment

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

Thanks a lot, looks good!

@AsamK AsamK merged commit 2e4d346 into AsamK:master Nov 1, 2022
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

2 participants