当用户搜索一个讨论时,它会返回所有讨论和问题,因为一个问题是一个带有布尔“问题”的讨论:是。
我想将它们分开,当我搜索一个讨论时,它只返回带有布尔型问题的讨论类型:false,而当我搜索一个问题时,它只返回带有布尔型问题的讨论:真。
有人可以帮助我吗?
API.prototype.search = function(discussionName, filter) {
if (this.debug === true) console.debug("API.search args : ", discussionName, this.jiveAppURL);
var discussionArray = [];
console.log(this.jiveAppURL, discussionName, this.discussionsReturnedCount);
return new Promise(function(resolve, reject) {
//search questionName
$this = this;
this.api.jive.corev3.discussions.get({
"place": this.jiveAppURL,
"search": discussionName,
"count": this.questionsReturnedCount
// "question": true
// "tag" : filter
}).execute(function(results) {
searchDiscussionByContent(results, $this, discussionName, discussionArray, resolve);
});
}.bind(this));
};
function searchDiscussionByContent(results, $this, discussionName, discussionArray, resolve){
if (!results.error)
for (var i = 0 ; i < results.list.length ; i++){
discussion = results.list[i];
// osapi.jive.core.discussions.get({
// question: true
// });
//if(!ideaArray.some(e => e.id == idea.id))function(r) { r.theString == row.theString[0] }
if(!discussionArray.some(function(e) { return e.id == discussion.id }))
discussionArray.push({ id: discussion.id, title: discussion.subject, date: discussion.published, author: discussion.author.displayName, tags: discussion.tags.join(", ") });
}
//search author
//get the uri of the first user matching
osapi.jive.core.get({
v:"v3",
href:"/search/people?filter=search(" + discussionName + ")"
}).execute(function(response) {
searchDiscussionByPeopel(response, $this, discussionName, discussionArray, resolve);
});
}
else if (args.isThereFilterFiles == "Question"){
return new Promise(function(resolve, reject) {
//question creation
this.api.jive.corev3.contents.create({
"type" : "discussion",
question: true,
subject: this.formatTitleIdeaContent(args),
content: {
"type": "text/html",
"text": this.formatIdeaContent(args)
},
parent: this.jiveAppURL,
tags: this.formatTagIdeaContent(args)
}).execute(function(idea) {
if (idea.error) {
reject("Fail to create Content", idea.error.code, idea.error.message);
return;
}
//setup external properties
idea.createExtProps(args.extProps).execute(function(res) {
console.info("res", res);
if (res.error) reject("Fail to add extraProperties", res.error.code, res.error.message);
resolve(idea.id);
});
});
}.bind(this))
} else if(args.isThereFilterFiles == "Discussion"){
return new Promise(function(resolve, reject) {
//discussion creation
this.api.jive.corev3.contents.create({
"type" : "discussion",
// question: true,
subject: this.formatTitleIdeaContent(args),
content: {
"type": "text/html",
"text": this.formatIdeaContent(args)
},
parent: this.jiveAppURL,
tags: this.formatTagIdeaContent(args)
}).execute(function(discussion) {
if (discussion.error) {
reject("Fail to create Content", discussion.error.code, discussion.error.message);
return;
}
//setup external properties
discussion.createExtProps(args.extProps).execute(function(res) {
console.info("res", res);
if (res.error) reject("Fail to add extraProperties", res.error.code, res.error.message);
resolve(discussion.id);
});
});
}.bind(this))
};