mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: return null if field isn't in hash
This commit is contained in:
@@ -73,7 +73,7 @@ module.exports = function (Categories) {
|
||||
|
||||
Categories.getCategoryField = async function (cid, field) {
|
||||
const category = await Categories.getCategoryFields(cid, [field]);
|
||||
return category ? category[field] : null;
|
||||
return category && category.hasOwnProperty(field) ? category[field] : null;
|
||||
};
|
||||
|
||||
Categories.getCategoryFields = async function (cid, fields) {
|
||||
|
||||
@@ -51,7 +51,7 @@ module.exports = function (Groups) {
|
||||
|
||||
Groups.getGroupField = async function (groupName, field) {
|
||||
const groupData = await Groups.getGroupFields(groupName, [field]);
|
||||
return groupData ? groupData[field] : null;
|
||||
return groupData && groupData.hasOwnProperty(field) ? groupData[field] : null;
|
||||
};
|
||||
|
||||
Groups.getGroupFields = async function (groupName, fields) {
|
||||
|
||||
@@ -29,7 +29,7 @@ module.exports = function (Messaging) {
|
||||
|
||||
Messaging.getMessageField = async (mid, field) => {
|
||||
const fields = await Messaging.getMessageFields(mid, [field]);
|
||||
return fields ? fields[field] : null;
|
||||
return fields && fields.hasOwnProperty(field) ? fields[field] : null;
|
||||
};
|
||||
|
||||
Messaging.getMessageFields = async (mid, fields) => {
|
||||
|
||||
@@ -37,7 +37,7 @@ module.exports = function (Posts) {
|
||||
|
||||
Posts.getPostField = async function (pid, field) {
|
||||
const post = await Posts.getPostFields(pid, [field]);
|
||||
return post ? post[field] : null;
|
||||
return post && post.hasOwnProperty(field) ? post[field] : null;
|
||||
};
|
||||
|
||||
Posts.getPostFields = async function (pid, fields) {
|
||||
|
||||
@@ -40,7 +40,7 @@ module.exports = function (Topics) {
|
||||
|
||||
Topics.getTopicField = async function (tid, field) {
|
||||
const topic = await Topics.getTopicFields(tid, [field]);
|
||||
return topic ? topic[field] : null;
|
||||
return topic && topic.hasOwnProperty(field) ? topic[field] : null;
|
||||
};
|
||||
|
||||
Topics.getTopicFields = async function (tid, fields) {
|
||||
|
||||
Reference in New Issue
Block a user