Find unanswered emails using Microsoft Graph API - microsoft-graph-api

I am trying to find all unanswered emails in a folder with Microsoft Graph.
The closest thing I could find is the PidTagLastVerbExecuted attribute, which gives me the last executed verb, e.g.:
https://graph.microsoft.com/v1.0/me/messages?$filter=parentFolderId eq '<my_folder_id>'&$select=subject,parentFolderId&$expand=SingleValueExtendedProperties($filter=id eq 'Integer 0x1081')
However, if an email was first replied to and then forwarded, the LastVerbExecuted is "forwarded", not "answered".
So how can I find out with certainty if an email in the inbox has been answered?
In IMAP there is the "ANSWERED" Flag, but I cannot find anything like that in Graph.
Thanks for your help!

The equivalent IMAP property is pidtagmessagestatus https://learn.microsoft.com/en-us/office/client-developer/outlook/mapi/pidtagmessagestatus-canonical-property eg to find answered emails (replied or forwarded)
https://graph.microsoft.com/v1.0/me/messages?$filter=singleValueExtendedProperties/any(ep:ep/id eq 'Integer 0x0E17' and cast(ep/value, Edm.Int32) eq 512)
or unanswered would be
https://graph.microsoft.com/v1.0/me/messages?$filter=singleValueExtendedProperties/any(ep:ep/id eq 'Integer 0x0E17' and cast(ep/value, Edm.Int32) ne 512)
The one thing to be careful of is that its a bitwise value and the Graph doesn't allow you to filter on bitwise values (EWS does have a bitwise search filters). So there could be edge cases where something else may use that property that would break the graph filter so I would suggest you put a client side filter to also check the bitwise value.

Related

Watson Discovery Passage Length

I am finding that the passages returned by Discovery are generally very good choices... but they are too short and truncated at odd points... even mid sentence. A couple of questions:
Is there a way to control the passage length returned?
Is there a way to bring the user directly to the passage within the full document?
It looks like they Discovery Query API now supports controlling the passage length, although the SDK's (Java and NodeJS) haven't been updated yet to support it.
passages.characters The approximate number of
query characters that any one passage should have.
integer The default is 400. The minimum is 50. The
maximum is 2000. Note: The passages.characters
parameter is supported only on private
collections. It is not supported in the
Watson Discovery News collection.
1) Currently, passage length is fixed at 200 characters, though it will generally not be exactly 200 as passages start and end at word boundaries.
2) No.
This is a problem with Watson Discovery. The answer seems to be if you need longer answers, to divide your documents into short sub-documents and make those part of your collection. For instance, I use discovery with my syllabus to help students who have questions about class and university policies. I divide each sub-section into its own document. Discovery can then produce the entire document (which is not more than a paragraph).

'Or' operator for bosun tags in an expression

I am writing a Bosun expression in order to get the number of 2xx responses in a service like:
ungroup(avg(q("sum:metric.name.hrsp_2xx{region=eu-west-1}", "1m", "")))
The above expression gives me the number of 2xx requests of the selected region (eu-west-1) in the last minute but I would like to get the number of 2xx requests that happened in 2 regions (eu-west-1 and eu-central-1).
This metric is tagged with region. I have 4 regions available.
I was wondering if it is possible to do an 'or' operation with the tags. Something like:
{region=or(eu-west-1,eu-central-1)}
I've checked the documentation but I'm not able to find anything to achieve this.
Since q() is specific to querying OpenTSDB, it uses the same syntax. The basic syntax for what you put would be to use a pipe symbol: ungroup(avg(q("sum:metric.name.hrsp_2xx{region=eu-west-1|eu-central-one}", "1m", ""))).
If you have version 2.2 set to true you can also use more advanced features of the filters as documented in the OpenTSDB documentation (i.e. host=literal_or(web01|web02|web03)). The main advantage is that OpenTSDB added the ability to aggregate a subset of tag values instead of all or nothing. The Graph page in Bosun also helps you generate the queries for OpenTSDB.

Youtube API v3 : no wildcard in search?

I'm making a list of the videos of my channel, and want to use the search endpoint of the API : https://developers.google.com/youtube/v3/docs/search/list
Ther eis a "q" parameter to send the query. What completely bugs me is that no wildcard is referenced in the documentation, and when using * it doesn't do anything. For example, in order to find any video containing "television" in the title, the full word has to be input ! Sending "tel" won't work, nor sending "televisio".
Did I miss something ? Is there a way around this ?
Thanks !
YouTube searching works along the same paradigm as Google searching, which is quite a bit different than the character-wildcard keyword approach. It's semantic probabilistic searching, looking for relevance based on the terms you give it, so while the * does represent a wildcard, it represents a whole word. For example, you can search for "a * saved" and it will return to you the videos which score the highest relevance score where any word could be substituted in place of your wildcard.
You can also use other punctuation based search operators ... the + sign, - sign, quotation marks, etc. Just make sure they're all URL encoded before you send the query in.

Best way to fix using a reserved JQL keyword in a JIRA query?

I am trying to write a JIRA query to query a bunch of defects. The problem I am having is that if there is a JQL keyword in the list of defects I am querying, the entire query fails and spits out the following error:
JiraError HTTP 400 - text: Error in the JQL Query: 'update' is a reserved JQL word.
You must surround it in quotation marks to use it in a query.
My query:
jira.search_issues( 'key in ({})'.format(','.join(defects))),
validate_query=false,
maxResults = MAX_JIRA_RESULTS )
This fails when a defect contains the word: 'update'. Now it is a bad data error, but I want to make sure the query is tolerant to malicious input.
Now the only way I can think of to make sure this bug never happens again is to make sure each defect that contains a JIRA keyword has that keyword escaped. This is obviously pretty tedious and is subject to fail if any new JQL keywords are added.
So is there a better way to do this other than escaping each JIRA keyword I find in my string? Additionally, is there an easy way in Python to get the JIRA keywords?
Thanks!
First of all, you can quote anything that you pass to that particular query, so you don't have to care about what is a reserved word or not. For example, this works:
key in ("abc-1","def-2")
If you were to substitute the word "update" in there, it would eliminate the specific error you are complaining about...but, unfortunately, you'd get another one: The issue key 'update' for field 'key' is invalid.
Luckily for you, there is a better solution. Your question indicates that you are working with issue keys. JIRA issue keys are always of the format:
<PROJECT>-<ISSUENUM>
where the format of PROJECT is explicitly defined by JIRA, namely:
The first character must be a letter,
All letters used in the project key must be from the Modern Roman Alphabet and upper case, and
Only letters, numbers or the underscore character can be used.
Instead of blacklisting keywords, you can instead whitelist anything that matches the issue key regex and reject everything else.
Note that while it is possible for the JIRA system administrator to change the project regex format outside of those guidelines, this is relatively uncommon (and Atlassian does not support JIRA running in that configuration anyway).

Encoding spaces for exact bigram match in twitter streaming API track keywords

I'm using the Twitter streaming API. It works wonderfully for single words, but seemingly cannot filter by an exact bigram (two word string).
I'm testing this by searching for common words, that are commonly in combination:
e.g. "feel good"
This is the URL: (will require OAuth login):
https://stream.twitter.com/1.1/statuses/filter.json?track=keywords_go_here
Things that don't work:
track=feel%20good ==> still produces: "text":"Feels so good outside!..."
track=%27feel%20good%27 ==> produces nothing
track=feel%20good, ==> still produces "good that my friend has an ED too because I can feel..."
Any ideas on getting this to work?
edit: someone sort-of answered this in early 2010: Twitter Streaming API - tracking exact multiple keywords in exact order , but are there any updates on this issue?
It seems like you can do that search according to the api: https://dev.twitter.com/docs/using-search
"happy hour" containing the exact phrase "happy hour"
Just need to put your phrase in quotation
I am sorry, but the answer is
Exact matching of phrases (equivalent to quoted phrases in most search engines) is not supported.
Furthermore,
Punctuation and special characters will be considered part of the term they are adjacent to.
So if you track "feel good", you will get messages such as
He said, "feel it", and I replied, "I am good".
If you want exact matches, then you have two options:
A) track both terms and then discard all tweets that don't have exact matches, or
B) get a paid subscription to the Twitter firehose with Gnip or DataSift. Twitter makes a living out of things like this, so I don't think it's ever gonna be available on the Streaming API.

Resources