add additionalContent to the message -> seems to work, just sometimes creates a blank node
@@ -9,7 +9,7 @@ import { checkHttpStatus, urisToLookupMap, is } from "./utils.js";
import { ownerBaseUrl } from "config";
import urljoin from "url-join";
-import { getRandomWonId } from "./won-utils.js";
+import { getRandomWonId, getAllDetails } from "./won-utils.js";
import { isConnUriClosed } from "./won-localstorage.js";
export const emptyDataset = Immutable.fromJS({
@@ -238,18 +238,39 @@ export function buildChatMessage({
.hasOwnerDirection()
.hasSentTimestamp(new Date().getTime().toString());
- //TODO: IMPLEMENT ADDITIONALCONTENT STUFF
- additionalContent &&
- console.log("AdditionalContent in Message: ", additionalContent);
-
if (isTTL && graphPayload) {
wonMessageBuilder.mergeIntoContentGraph(graphPayload);
- } else if (!isTTL && chatMessage) {
+ } else if (!isTTL && (chatMessage || additionalContent)) {
//add the chatMessage as normal text message
+ if (chatMessage) {
wonMessageBuilder.addContentGraphData(
won.WON.hasTextMessage,
chatMessage
);
+ }
+
+ if (additionalContent) {
+ const contentNode = wonMessageBuilder.getContentGraphNode();
+ const detailList = getAllDetails();
+ additionalContent.forEach((value, key) => {
+ const detail = detailList[key];
+ const detailRDF = detail && detail.parseToRDF({ value: value });
+
+ if (detailRDF) {
+ for (const key in detailRDF) {
+ //if contentNode[key] and detailRDF[key] both have values we ommit adding new content (until we implement a merge function)
+ if (contentNode[key]) {
+ if (!Array.isArray(contentNode[key]))
+ contentNode[key] = Array.of(contentNode[key]);
+
+ contentNode[key] = contentNode[key].concat(detailRDF[key]);
+ } else {
+ contentNode[key] = detailRDF[key];
+ }
+ }
+ }
+ });
+ }
} else {
throw new Error(
"No textmessage or valid graph as payload of chat message:" +
