Unpin or remove star on Gmail Message using the api - gmail-api

I am trying to update a message in gmail to remove the pin and I thought I could do it using labels. But I am getting a bad request error.
Anyone aware of a way to do it?

It's very hard to say where the issue is without you sharing your code and the exact error message you're getting but to remove a star from a message, you'd use messages.modify() with a body having the removeMessageLabelIds list and STARRED as the label to remove. I haven't tested pinning but I believe that'd be removing the INBOX label.

Tl;DR: If you find this thread because you want to disable pinning in Google Inbox (maybe because you dislike that snoozed emails automatically get pinned, breaking them out of bundles), don't try to solve that with the Gmail API. Maybe try this TamperMonkey user script instead.
Detail:
I want to add a dire warning for anyone who finds this thread while trying to do what I just wasted a lot of hours on:
If you dislike that snoozed emails get pinned when they un-snooze, don't try to solve this with the Gmail API. You might know that whether an email is in the inbox (versus being archived) is handled by an INBOX label, and you might know that you can subscribe to push notifications about a mailbox.
So you read Paul McManus's comment above that mentions that removing and re-adding the INBOX label with the Gmail API un-pins your messages. You put it together and think it'll solve your problem - you'll subscribe to push notifications about mailbox changes, then use history/list to find recent messages that gained the INBOX label, and you'll use message/modify to remove and re-add the INBOX label.
The problem is that history/list doesn't show changes from emails becoming un-snoozed (even though they gained the INBOX label). So you won't know which message to un-pin.
After discovering that, I thought through the problem again and realized that a user script that calls the click event on un-pin buttons would also solve the problem, and that's just a few lines of Javascript. You can get it here. The only problem is that it won't work on your phone.

What I did to solve the same problem was.
Use the Threads.list API with a query (q param) of is:pinned to get all threads that were "pinned".
Loop through those threads and use the Threads.modify API to first removeLableIds of "Inbox" then addLabelIds to add Inbox back. This removed the pin from the thread and kept it sorted in my Inbox the way I wanted it.
Of course every time you snooze an email with Google's Inbox, you'll have to run the same script again. I haven't figured out the best way to automate that yet, but potentially using push notification for inbox changes could do it.

Related

Way to follow or receive notification on page update for end user?

We have a need for our end-users to be able to click a "watch" button or something similar to get update notifications when page contents are updated.
Is there a feature or plugin for this?
Thank you.
There's no built-in mechanism for this, but you could build one by defining a "Subscription" model to keep track of which users are watching a given page, and adding a listener for the page_published signal that sends the notification to those users.

CodenameOne API, how to customise Local Notification text

I think i've found a blocker in my app development that i hope you can help me out with please.I am using a CN1 Local Notification and i want them to be triggered at an interval at a particular time. The LocalNotification sample project works but please can you answer this. How can i code it so that each local notification text n.setAlertTitle() is customised\different each day, from reading from a List? All the examples i read have static text.
I had thought of not making it repeat but initiating a new notification upon the user clicking previous one, but this would have the problem that if the user ignores the notification then no more would be sent, so i abandoned that approach.
Many thanks in advance.
The solution is not to issue a recurring notification and instead register several separate notifications. You will need to store and manage the notification ID's so you can cancel and replace them.
In order to change the text dynamically your app needs to run and the basic idea of the notification is that it occurs while your app isn't running so it must be static.

GPS tracking in Kinetise application

Anyone here familiar with Kinetise? I try to add to my app some kind of remote tracking functionality, where backend will trigger from active user his GPS position. What first come to my mind was PUSH notifications, but it's rather message notification than event triggering in this tool. In taxi template there is a map with live changing positions, realized by longpooling requests I think. I found that you can add your current position in request params or body and I consider to use this technique to send user location to server, but I think that I would have to add empty lists in each screen, just to send a location. A bit weird but maybe there is any better solution?
#Marek for GPS purposes you have also functions:
GPS TRACKING START
GPS TRACKING STOP
You can add it to buttons from widget "EVENTS" tab.
EVENTS tab
I know it's not triggered by server but can help you meet your requirements.

Geoloqi Geofencing Logic Flow

All,
I have been looking high and low for a solution and at this point I am baffled. I am not looking for code here. I am just looking for the proper logic flow to alert users of my app that an event is taking place nearby using Geoloqi.
My platforms:
Geoloqi: Geofencing
Appcelerator Cloud Services: User, Event and Message Management
Language: javascript
Mobile: iPhone and Android
What I am trying to do:
1) I want users of my app to be able to create an event, then create a trigger based on that event.
2) I want users of my app who are near the event to be automatically alerted that the event is happening.
What I have so far:
1) Create an Appcelerator Event - Works fine
2) Create a Geoloqi Layer including the Appcelerator EventID - Works fine
3) Create a Geoloqi Trigger for the above layer - Works fine
I can see everything getting to the Geoloqi debugger. I just don't see the alert going out. I saw a post that the anonymous user needs to subscribe to the layer in order for the trigger to send to my users inside the trigger geofence. I just don't understand how to do that. I have tried several code permutations around the user/create_anon method with a key using either the anonymous username or the user access token to subscribe to the layer with no luck. I have tried using the access token returned on init as the parameter to subscribe with no luck.
I am wondering, however, if I can get the same effect by using a place instead of the layer, and avoiding the subscription issue. I somehow doubt this as the place has to reside in a default layer.
Color me confused. I already went through hell and back just getting the push certs set up for Apple, so any and all help is greatly appreciated.
Thanks,
Bruce
Bruce,
I'd recommend hitting the geoloqi developer IRC channel. You can get to it from one of the developer pages on their website. The geoloqi guys are usually online and they've been very helpful to me in the past.
If you do get it working, I'd love to hear the solution/flow for it! Hope that helps!
Tyler
OK, so here is what I am doing. Not sure yet if it is the answer, but I think it will work.
Create a default layer with no boundaries and a key that is the same each time the app runs. This will ensure the same layer is used based on Geoloqi's anti-dupe logic.
Create an anon user using the logged in user's email address since I am using Appcelerator to handle the user management. If I understand this correctly, this will also ensure the same anon-user is used if the user logs in again later. The anon user is automatically subscribed to the default layer.
When the user wants to create an event, the app creates an event on Appcelerator, creates a layer with a radius of x, a trigger on that layer, and sends a broadcast message to all users in the default layer using the trigger centerpoint and radius to limit the message to the immediate area.
If the user wants to cancel the event, the app sends a broadcast message to the default
layer in the same way the layer was created, then deletes the Appcelerator event and the layer.
I have all the code hooked in except the anonymous user. I can see the triggers being set and the messages being created on the Geoloqi Debugger, but I don't always get them. I'll be hooking in the anonymous user next week, so we shall see.

Add bug to Bugzilla via code

I'm using browser-like approach for adding a bug to Bugzilla.
I'm making a successful login. When I add the bug, I don't get error. I get status code OK. But, the response html contains this:
Bugzilla – Suspicious Action
"It looks like you didn't come from the right page (you have no valid token for the create_bug action while processing the 'post_bug.cgi' script). The reason could be one of:
You clicked the "Back" button of your web browser after having successfully submitted changes, which is generally not a good idea (but harmless).
You entered the URL in the address bar of your web browser directly, which should be safe.
You clicked on a URL which redirected you here without your consent, in which case this action is much more critical.
Are you sure you want to commit these changes anyway? This may result in unexpected and undesired results."
There is a confirm button.
When I do this by hand (not by code), I don't get the error page. Instead, I get response that everything went fine and I can get my bug's id. So, ahead in my code I'm using the id. However, because of the error I get, the id is an empty string. How to resolve this?
Can it be resolved by clicking on the confirm button by code?
You can use Bugzilla's REST API from your script.
Creation of a bug is documented here

Resources