Thunderbird extension code not returning all the threads - api

I am using the below code and expecting to retrieve all the messages belonging to the same thread. However, it always returns only the selected message details. The message is already an hour old so indexing should be done. Also i tried this on multiple threads but same result. Please advise whats wrong here
this.query =
Gloda.getMessageCollectionForHeaders([msgHdr], {
onItemsAdded: function (aItems) {},
onItemsModified: function () {},
onItemsRemoved: function () {},
onQueryCompleted: function (aCollection) {
add("\t\t\t/---------------------------\\\n");
add("\t\t\t| vik Gloda results |\n");
add("\t\t\t\\---------------------------/\n\n");
add("Gloda found "+aCollection.items.length+" items\n");
// Iterator over the messages Gloda found...
for each (let [i, glodaMsg] in Iterator(aCollection.items)) {
add("This message is from: "+glodaMsg.from+"\n");
add("This message is to: "+glodaMsg.to+"\n");
add("This message is from lists: "+glodaMsg.mailingLists+"\n");
}
},
}, true)
;

See the last paragraph of https://developer.mozilla.org/en-US/docs/Mozilla/Thunderbird/Creating_a_Gloda_message_query?redirectlocale=en-US&redirectslug=Thunderbird%2FCreating_a_Gloda_message_query ; in your case, you need to launch a second query by doing glodaMsg.conversation.getMessageCollection. https://developer.mozilla.org/en-US/docs/Mozilla/Thunderbird/Gloda_examples?redirectlocale=en-US&redirectslug=Thunderbird%2FGloda_examples has a bigger example.

Related

Karate Api : check if a phrase is available response object array

I've a response
{ errors: [
{
code: 123,
reason: "this is the cause for a random problem where the last part of this string is dynamically generated"
} ,
{
code: 234,
reason: "Some other error for another random reason"
}
...
...
}
Now when I validate this response
I use following
...
...
And match response.errors[*].reason contains "this is the cause"
This validation fails, because there is an equality check for complete String for every reason ,
I all I want is, to validate that inside the errors array, if there is any error object, which has a reason string type property, starting with this is the cause phrase.
I tried few wild cards but didn't work either, how to do it ?
For complex things like this, just switch to JS.
* def found = response.errors.find(x => x.reason.startsWith('this is the cause'))
* match found == { code: 123, reason: '#string' }
# you can also do
* if (found) karate.log('found')
Any questions :)

Vue.js Nuxt - cannot access Array (value evaluated upon first expanding error)

I have the following function which gives me an array called URLs
const storageRef = this.$fire.storage.ref().child(fileName)
try {
const snapshot = storageRef.put(element).then((snapshot) => {
snapshot.ref.getDownloadURL().then((url) => {
urls.push(url)
})
})
console.log('File uploaded.')
} catch (e) {
console.log(e.message)
}
});
console.log(urls)
console.log("about to run enter time with imageurls length " + urls.length)
When I run console.log(URLs) initially I do see the array like the following
[]
0: "testvalue"
length: 1
__proto__: Array(0)
However, there is a small information icon stating
This value was evaluated upon first expanding. The value may have changed since.
Because of this, when I try to get the length of URLs, I get zero, meaning the value is being updated.
Does anyone know what's happening? I am using Vue.JS/Nuxt.

TypeError: Cannot read property 'replace' of undefined in the context of VueJS

I am filtering some of the characters from the string. I went across few questions which has a same problem ie error in the console, but could not find any good answers.
Here is my string:
response_out1|response_out2|response_out3
Here is the method that i have used:
<vs-select v-model="change">
<vs-select-item :key="index" v-bind="item" v-for="(item,index) in
userFriendly(out.changes)" />
</vs-select>
...
methods: {
userFriendly (str){
return str.replace(/_/g, ' ').split('|').map(value => ({text: value, value }))
}
Here is the output that i am getting in the vs-select:
response out1
response out2
response out3
The error that i am getting in my console:
Here i want to know why i am getting this error and i wanna know how to rectify it and the output that i am expecting is: Response Out1, here how to capitalize first character of each word in the same method.
you're using a method directly in the template which causes multiple calls whenever your data changes,
you can use computed property to avoid such a scenario, not sure about how you are accessing out.changes
this might help you to solve your error and capitalize your text,
capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
},
sentenceCase (sentence) {
return sentence.split(' ').map(s => this.capitalize(s)).join(' '));
},
userFriendly (str) {
if (!str) return;
return str.replace(/_/g, ' ').split('|').map(value => ({text: this.sentenceCase(value), value }))
},

Accessing elements in JSON for nodejs

first off I am very new to node/JSON, so please take that into consideration when reading through.
The purpose of this code is to take data from a SQL Server database, and be able to access the elements that it pulls. For example, it will pull several thousand parentacccount ID's, and I just want to access one of those.
I've browsed forums for almost the entire day trying to access JSON elements from my nodejs function, and I every time I try and access one of these elements I am hit with an "undefined" error. As a last resort I am here.
I have checked a few times to see recordset has been parsed, and it appears that it is being parsed.
Below is my code, and a very small example of the JSON code is towards the end.
I have commented where I am getting my error.
function getEmp() {
var conn = new sql.ConnectionPool(dbConfig);
var req = new sql.Request(conn);
conn.connect(function (err) {
if (err) {
console.log(err);
return;
}
req.query("SELECT * FROM parentaccount Where accountname like 'Titan%' FOR JSON PATH", function (err, recordset) {
if (err) {
console.log(err);
}
else {
const Test1 = recordset[0].ParentAccountId; //error here
console.log(Test1);
}
conn.close();
})
})
}
getEmp();
//EXAMPLE JSON
{ recordsets: [ [ [Object] ] ],
recordset:
[ { 'JSON_F52E2B61-18A1-11d1-B105-00805F49916B':
'[{"ParentAccountId":4241411,"AccountName":"Titan"} ],
output: {},
rowsAffected: [ 3 ] }
ERROR:
TypeError: Cannot read property 'ParentAccountId' of undefined
at C:\Users\za47387\Desktop\Excel Export Code\test2.js:31:48
at _query (C:\Users\za47387\node_modules\mssql\lib\base.js:1347:9)
at Request.tds.Request.err [as userCallback] (C:\Users\za47387\node_modules\mssql\lib\tedious.js:671:15)
at Request.callback (C:\Users\za47387\node_modules\tedious\lib\request.js:37:27)
at Connection.endOfMessageMarkerReceived (C:\Users\za47387\node_modules\tedious\lib\connection.js:2104:20)
at Connection.dispatchEvent (C:\Users\za47387\node_modules\tedious\lib\connection.js:1084:36)
at Parser.tokenStreamParser.on (C:\Users\za47387\node_modules\tedious\lib\connection.js:914:14)
at Parser.emit (events.js:189:13)
at Parser.parser.on.token (C:\Users\za47387\node_modules\tedious\lib\token\token-stream-parser.js:27:14)
at Parser.emit (events.js:189:13)
From what the sample you have shared,
recordset[0] is undefined, meaning either two options :
a) the result for the query fetched no rows.
b) the result of the query is in a different format than expected.
though i suspect a), its good to console the output. kindly run the below code before you try accessing ParentAccountId.
console.log('output : ', JSON.stringify(recordset, null, 4));
also i would refactor the code to be :
const Test1 = (Array.isArray(recordset) &&
recordset.length) ? recordset[0].ParentAccountId : null;
so that the error won't make the nodejs process go down.

How to pass same parameter with different value

I am trying the following API using Alamofire, but this API has multiple "to" fields. I tried to pass an array of "to" emails as parameters. It shows no error but did not send to all emails. API is correct, I tested that from terminal. Any suggestions will be cordially welcomed.
http -a email:pass -f POST 'sampleUrl' from="email#email.com" to="ongkur.cse#gmail.com" to="emailgmail#email.com" subject="test_sub" bodyText="testing hello"
I am giving my code:
class func sendMessage(message:MessageModel, delegate:RestAPIManagerDelegate?) {
let urlString = "http://localhost:8080/app/user/messages"
var parameters = [String:AnyObject]()
parameters = [
"from": message.messageFrom.emailAddress
]
var array = [String]()
for to in message.messageTO {
array.append(to)
}
parameters["to"] = array
for cc in message.messageCC {
parameters["cc"] = cc.emailAddress;
}
for bcc in message.messageBCC {
parameters["bcc"] = bcc.emailAddress;
}
parameters["subject"] = message.messageSubject;
parameters["bodyText"] = message.bodyText;
Alamofire.request(.POST, urlString, parameters: parameters)
.authenticate(user: MessageManager.sharedInstance().primaryUserName, password: MessageManager.sharedInstance().primaryPassword)
.validate(statusCode: 200..<201)
.validate(contentType: ["application/json"])
.responseJSON {
(_, _, jsonData, error) in
if(error != nil) {
println("\n sendMessage attempt json response:")
println(error!)
delegate?.messageSent?(false)
return
}
println("Server response during message sending:\n")
let swiftyJSONData = JSON(jsonData!)
println(swiftyJSONData)
delegate?.messageSent?(true)
}
}
First of all if you created the API yourself you should consider changing the API to expect an array of 'to' receivers instead of multiple times the same parameter name.
As back2dos states it in this answer: https://stackoverflow.com/a/1898078/672989
Although POST may be having multiple values for the same key, I'd be cautious using it, since some servers can't even properly handle that, which is probably why this isn't supported ... if you convert "duplicate" parameters to a list, the whole thing might start to choke, if a parameter comes in only once, and suddendly you wind up having a string or something ...
And I think he's right.
In this case I guess this is not possible with Alamofire, just as it is not possible with AFNetworking: https://github.com/AFNetworking/AFNetworking/issues/21
Alamofire probably store's its POST parameter in a Dictionary which doesn't allow duplicate keys.