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

Auto-sharing: take into account stage attachments #353

Closed
adubovik opened this issue Jun 6, 2024 · 0 comments
Closed

Auto-sharing: take into account stage attachments #353

adubovik opened this issue Jun 6, 2024 · 0 comments
Assignees

Comments

@adubovik
Copy link
Contributor

adubovik commented Jun 6, 2024

Currently, DIAL Core takes into account only the attachments that are attached directly to individual chat messages.
However, according to the DIAL API, each message may also have multiple stages each of which could have attachments.

Those must also be taken into account in the auto-sharing logic, otherwise application won't have an access to the stage attachments:

public static void collectAttachedFiles(ObjectNode tree, Consumer<String> consumer) {
ArrayNode messages = (ArrayNode) tree.get("messages");
if (messages == null) {
return;
}
for (int i = 0; i < messages.size(); i++) {
JsonNode message = messages.get(i);
JsonNode customContent = message.get("custom_content");
if (customContent == null) {
continue;
}
ArrayNode attachments = (ArrayNode) customContent.get("attachments");
if (attachments == null) {
continue;
}
for (int j = 0; j < attachments.size(); j++) {
JsonNode attachment = attachments.get(j);
collectAttachedFile(attachment, consumer);
}
}
}

@astsiapanay astsiapanay self-assigned this Jun 6, 2024
astsiapanay added a commit that referenced this issue Jun 11, 2024
Co-authored-by: Aliaksandr Stsiapanay <aliaksandr_stsiapanay@epam.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants