Skip to content

Conversation

@gabriel-indik
Copy link
Contributor

When sending a message or transferring a blob, the recipient ID can now contain an additional identifier. Also, the sender can be explicitly included which may also contain an additional identifier.

Example:
POST /api/v1/messages

Payload:

{
    "recipient": "org-b/ns-a",
    "sender": "org-a/ns-x",
    "message": "test 1-2-3"
}

Response:

{
    "requestId": "cee8e73e-4a97-4be7-abc8-f82de1e62939"
}

Sender receives event:

{
    "id": "58e7a4b8-046e-478b-a82c-daa9eb9aae01",
    "type": "message-delivered",
    "message": "test 1-2-3",
    "sender": "org-a/ns-y",
    "recipient": "org-b/ns-x",
    "requestId": "cee8e73e-4a97-4be7-abc8-f82de1e62939"
}

Recipient receives event:

{
    "id": "8d3351a8-bb83-4ce2-906d-4d099f8e2492",
    "type": "message-received",
    "sender": "org-a/ns-y",
    "recipient": "org-b/ns-x",
    "message": "test 1-2-3"
}

Similarly when transferring blobs:
POST /api/v1/transfers

Payload:

{
    "path": "/photo.jpg",
    "sender": "org-a/ns-x",
    "recipient": "org-b/ns-y"
}

Response:

{
    "requestId": "ba830d2c-dd39-48ce-ab70-dbfa610dc606"
}

Sender receives event:

{
    "id": "16354dfb-1644-404e-a23c-51dd62d0d5d9",
    "type": "blob-delivered",
    "path": "/photo.jpg",
    "sender": "org-a/ns-x",
    "recipient": "org-b/ns-y",
    "requestId": "ba830d2c-dd39-48ce-ab70-dbfa610dc606"
}

Recipient receives event:

{
    "id": "bb745fe8-8837-436f-9d20-315dc0da01a5",
    "type": "blob-received",
    "sender": "org-a/ns-x",
    "recipient": "org-b/ns-y",
    "path": "received/org-a/ns-x/photo.jpg",
    "hash": "9707a075644e450ebec9c87dfa3b79b53e51f878cfc0394b80c30949f4d2000c",
    "size": 146866,
    "lastUpdate": 1658437514514
}

Notice the folder structure, the file is stored in a subdirectory based on the additional identifier.
Note also that these changes are backward compatible as the additional identifiers are optional.

Signed-off-by: Gabriel Indik <gabriel.indik@kaleido.io>
Signed-off-by: Gabriel Indik <gabriel.indik@kaleido.io>
Signed-off-by: Gabriel Indik <gabriel.indik@kaleido.io>
throw new RequestError('Invalid path', 400);
}
if (req.body.recipient === undefined) {
await blobsHandler.retreiveMetadata(path.join(utils.constants.DATA_DIRECTORY, utils.constants.BLOBS_SUBDIRECTORY, req.body.path));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a bug - you are prepending the data directory prefix here, but then the retreiveMetadata function prepends the same prefix again.

Side note - retrieve is misspelled here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@awrichar good catch! I fixed that issue and also addressed the typo, plus I updated the headers. All the changes are in #62

@gabriel-indik gabriel-indik deleted the add-destinations-improvements branch August 1, 2022 14:39
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.

3 participants