@zzish/sdk-js 0.5.8 → 0.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/zzish.js +34 -3
package/package.json
CHANGED
package/zzish.js
CHANGED
|
@@ -1122,19 +1122,50 @@
|
|
|
1122
1122
|
* @param content - The JSON object to save
|
|
1123
1123
|
* @param callback - An optional callback to call when done (returns error,message)
|
|
1124
1124
|
*/
|
|
1125
|
-
Zzish.postContent = function (profileId, type, uuid, meta, content, callback) {
|
|
1125
|
+
Zzish.postContent = function (profileId, type, uuid, meta /* , [tags], content, callback */) {
|
|
1126
|
+
// Arity-tolerant: support both the modern 6-arg shape and the legacy
|
|
1127
|
+
// 7-arg shape that includes `tags`. Legacy callers (quizalize quiz.js,
|
|
1128
|
+
// quiz-player server routes, anything pre-0.5.7) pass:
|
|
1129
|
+
// postContent(profileId, type, uuid, meta, tags, content, callback)
|
|
1130
|
+
// Modern callers pass:
|
|
1131
|
+
// postContent(profileId, type, uuid, meta, content, callback)
|
|
1132
|
+
// Detect by total argument count; the callback is always the last
|
|
1133
|
+
// argument and it's the only function in the trailing position.
|
|
1134
|
+
const args = arguments;
|
|
1135
|
+
let tags;
|
|
1136
|
+
let content;
|
|
1137
|
+
let callback;
|
|
1138
|
+
if (args.length >= 7) {
|
|
1139
|
+
tags = args[4];
|
|
1140
|
+
content = args[5];
|
|
1141
|
+
callback = args[6];
|
|
1142
|
+
} else if (args.length === 6) {
|
|
1143
|
+
content = args[4];
|
|
1144
|
+
callback = args[5];
|
|
1145
|
+
} else if (args.length === 5) {
|
|
1146
|
+
content = args[4];
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1126
1149
|
const data = {
|
|
1127
1150
|
uuid,
|
|
1128
1151
|
meta,
|
|
1129
1152
|
payload: JSON.stringify(content),
|
|
1130
1153
|
};
|
|
1154
|
+
// Forward `tags` on the wire only when the legacy caller supplied them.
|
|
1155
|
+
// The zzish-api content endpoint reads `content.getTags()` and persists
|
|
1156
|
+
// them onto the merged ActivityDef, so omitting the field preserves
|
|
1157
|
+
// the existing rows instead of overwriting them with an empty list.
|
|
1158
|
+
if (tags !== undefined) {
|
|
1159
|
+
data.tags = tags;
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1131
1162
|
const request = {
|
|
1132
1163
|
method: "POST",
|
|
1133
1164
|
url: `${getBaseUrl()}profiles/${profileId}/contents/${type}/${uuid}`,
|
|
1134
1165
|
data,
|
|
1135
1166
|
};
|
|
1136
|
-
sendData(request, (err,
|
|
1137
|
-
callCallBack(err,
|
|
1167
|
+
sendData(request, (err, responseData) => {
|
|
1168
|
+
callCallBack(err, responseData, callback);
|
|
1138
1169
|
});
|
|
1139
1170
|
};
|
|
1140
1171
|
|