Handle missing 'attachments' array in /connector/saveItems
This commit is contained in:
parent
6cb4057fee
commit
862ac5ab40
2 changed files with 8 additions and 4 deletions
|
@ -667,21 +667,24 @@ Zotero.Server.Connector.SaveItems.prototype = {
|
|||
function (topLevelItems) {
|
||||
// Only return the properties the connector needs
|
||||
topLevelItems = topLevelItems.map((item) => {
|
||||
return {
|
||||
let o = {
|
||||
id: item.id,
|
||||
title: item.title,
|
||||
itemType: item.itemType,
|
||||
contentType: item.mimeType,
|
||||
mimeType: item.mimeType, // TODO: Remove
|
||||
attachments: item.attachments.map((attachment) => {
|
||||
};
|
||||
if (item.attachments) {
|
||||
o.attachments = item.attachments.map((attachment) => {
|
||||
return {
|
||||
id: session.id + '_' + attachment.id, // TODO: Remove prefix
|
||||
title: attachment.title,
|
||||
contentType: attachment.contentType,
|
||||
mimeType: attachment.mimeType, // TODO: Remove
|
||||
};
|
||||
})
|
||||
});
|
||||
};
|
||||
return o;
|
||||
});
|
||||
resolve([201, "application/json", JSON.stringify({items: topLevelItems})]);
|
||||
}
|
||||
|
|
|
@ -222,6 +222,7 @@ Zotero.Translate.ItemSaver.prototype = {
|
|||
if (urlObjects.length) {
|
||||
let title = Zotero.getString('findPDF.openAccessPDF');
|
||||
let jsonAttachment = this._makeJSONAttachment(jsonItem.id, title);
|
||||
if (!jsonItem.attachments) jsonItem.attachments = [];
|
||||
jsonItem.attachments.push(jsonAttachment);
|
||||
attachmentCallback(jsonAttachment, 0);
|
||||
}
|
||||
|
@ -266,7 +267,7 @@ Zotero.Translate.ItemSaver.prototype = {
|
|||
let jsonItem = jsonByItem.get(item);
|
||||
// Reuse the existing status line if there is one. This could be a failed
|
||||
// translator attachment or a possible OA PDF found above.
|
||||
let jsonAttachment = jsonItem.attachments.find(
|
||||
let jsonAttachment = jsonItem.attachments && jsonItem.attachments.find(
|
||||
x => x.mimeType == 'application/pdf' && x.isPrimaryPDF
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue