I've successfully implemented push notifications with RavenDB (see code below). I was expecting the actual document to be included with the change notification. That way, all the UI clients can display the information. However, it seems that only the Id and Etag properties are available for the changed document.
What am I supposed to do if I want the client to be able to display information about the document? Does the client now need to make a DB call to get the document based on the ID? It seems inefficient to have to make a DB call to get the information. But, is that what is supposed to happen?
documentStore.Changes()
.ForDocumentsStartingWith("LogMessages")
.Subscribe(change =>
{
if (change.Type == DocumentChangeTypes.Put)
{
// Fire event so consumers can display document info
// Uh oh, are change.Id and change.Etag all we have here?
DatabaseItemAdded(null, new EventArgs<string>(change.Id));
}
});
Yes, you need to call the db to get the new document.
The reason for that is that it would be expensive to send the document (which may be very big) if all you need is just the notification on the change).
Related
I am developing my own eclipse editor and need to switch between different contexts for key binding. Currently I am doing the context activation/deactivation manually upon part activation.
This page
https://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fworkbench_advext_contexts.htm says:
If you are activating a more specific Context within your part (either
View or Editor) you can use the part site service locator to active
your Context. The part's IContextService will take care of activating
and deactivating the Context as your part is activated or deactivated.
It will also dispose the Context when the part is disposed.
It seems like that is just what I want. But the page did not say how. Can anyone give me a hint what a 'part site service locator' mentioned in the text is and how to use it?
I would interpret the text so that you should use the service locator of the site that corresponds to your (editor) part. In the following example, part references your editor. By obtaining the context service from the part's site, you get a child context service for that particular part in wich you can activate a specialized editor context.
IContextService contextService = part.getSite().getService( IContextService.class );
contextService.activateContext( "your.editor.context.id" );
After digging through Eclipse code, here's my answer to my own question.
First thing first, it is JUST enough to invoke
IContextService contextService = part.getSite().getService( IContextService.class );
contextService.activateContext( "your.editor.context.id" );
anywhere after init(where you get PartSite), just as #RĂ¼diger Herrmann mentioned in his answer.
AND(here's my finding) NOTHING ELSE need to be done.
Eclipse will automatically activate/deactivate the context when part is activated /deactivated, just as described in the text I refer to. In addition, when the part site is disposed, all context will be disposed.
If you are interested in how, here's more digging.
Activate/Deactivate
When we invoke getSite().getService(IContextService.class), what we get is an instance of SlaveContextService.
When we call activateContext(String contextId) on it, our request will be automatically translate to a request with a default expression ActivePartExpression.
From it's name we can easily guess that this expression will check whether a part is active and do some changes. The changes it does can be seen at ContextService.UpdateExpression.changed. Here's the code(ContextService:124-128)
if (result != EvaluationResult.FALSE) {
runExternalCode(() -> contextService.activateContext(contextId));
} else if (cached != null) {
runExternalCode(() -> contextService.deactivateContext(contextId));
}
Whenever Eclipse context changes(activate/deactivate part will trigger context change), UpdateExpression.changed will be invoked and check whether the target part is still active, then activate/deactivate the context accordingly.
Dispose
In SlaveContextService.dispose, all context registered through it will be disposed upon the service's dispose.
I created an automated action in Odoo that is triggered when a purchase order is updated from state = draft to state = sent. This automated action simply calls a server action that runs the following code:
record.button_confirm()
The idea is I am trying to confirm the purchase order automatically after the RFQ is sent to the vendor.
After sending the RFQ the PO is confirmed as expected. However, the vendor on the PO also receives a notification from the system related to the picking that was created. It will say something like:
"This transfer has been created from: PO00007"
If I disable my automated action and instead confirm the PO manually by clicking the "Confirm Order" button on the PO form, the order is approved, a picking is created, and this notification is not sent.
I would like my automatic approval to mimic the manual approval. Meaning, I do not want this notification to be sent.
After searching the source code, I was able to accomplish what I wanted by passing in a context key like this in the server action:
record.with_context(message_create_from_mail_mail=True).button_confirm()
I came across this solution here in the source code:
https://github.com/odoo/odoo/blob/df60828488a702acb64757f518b4be12b7a95a04/addons/mail/models/mail_message.py#L729
However, I don't understand why this is necessary or if it's even the correct way to solve this problem. I honestly don't even know what it means. I just know it works. I don't see the manual "button_confirm" method passing in this context key anywhere.
Can anyone offer any guidance here as to why this notification email is sent when I simply run button_confirm() from a server action rather than triggering it manually with a button from the UI? Also, is my solution correct or does it have some sort of side effect I am not aware of?
I want to send a WhatsApp message to a specific contact with the Automate-app. How can do I do this?
This is the link to the app:
https://play.google.com/store/apps/details?id=com.llamalab.automate
I know this is pretty late reply.
You can make use of below blocks and build
App start block and choose activity class as
com.whatsapp.ContactPicker
Use Interact blocks for searching, selecting and messaging
Extend with Variable for searching contact and for message text
I have been trying different ways but many of them fall short of full automation.
currently, I am using blocks to send a message to (unsaved) contact. This skips the contactPicker window.
the flow blocks:
[start flow] --> [view content] --> [interact]
that's it!
in view content, you will need to specify the content uri (change number and msg):
https://api.whatsapp.com/send?phone=+966xxxxxxxxx&text=msg
in interact block, specify the (proceed) when element appeared.
the (action) is click.
and (XPATH):
fn:reverse((.//[{("android.widget.ImageButton") = null ? "true()" : "fn:choose(#class,string(#class),name())={"android.widget.ImageButton";xpathEncode}"} and {("com.whatsapp:id/send") = null ? "true()" : "#android:id={"#" ++ ("com.whatsapp:id/send");xpathEncode}"}])[1]/ancestor-or-self::)
that's it.
Is there any way to force a Kaltura videoplayer to stop ONLY using code and the Kaltura API?
Currently I have solved it by adding a Access Control Profile named "Free preview" under Settings > Access Control in KMC and then added this profile to the Entries I've choosen.
I then add the session to the players flashvars to restrict non-members to only watch the preview, not the whole clip.
But I would like to restrict ALL, or even better selected Categories of clips by using only code, so I don't need to involve KMC.
Is that possible?
Alt) Can you create a new player in KMC and restrict it to viewing only X seconds, no matter what length of Entry? Then I can do the check if user is valid or not and get the category via API and show it in the "preview-player" och the "default player".
If I use the mediaProxy.mediaPlayTo attribute the clip stops, but is easily started again by presing play.
Would greatly appreciate an answer
I got this answer from a guy named oferc in a different forum:
You can listen to the head move event and pause the clip it goes beyond a certain time (then if someone pressed play, you can stop it again)
function jsCallbackReady(player_id) {
my_kdp = $("#"+player_id).get(0); // document.getElementById(player_id) if you do not use jquery/ prefer pure js
my_kdp.addJsListener("kdpReady", "kdpReady"); // when you load the player with an entry (and the player is ready to begin playing it using doPlay for instance)
}
function kdpReady() {
my_kdp.addJsListener("playerUpdatePlayhead","headMove");
}
function headMove(position) {
if (position > "30") { // Your Time, example 30 seconds
my_kdp.sendNotification('doStop')
}
}
Works like a charm!
fredrik_w - neither of the ways you chosen here are a good option to restrict access.
in both cases, your videos are made public, and can be easily accessible by anyone.
The best way to limit access to a video is by defining an Access Control, and like everything in Kaltura, you can define an ACL using API as well.
Check this out as a reference sample-
http://blog.kaltura.org/turning-profit-online-video-made-easy-using-paypal-html5-digital-goods
I would like to be able to gather info like how often certain windows are opened, what types of user data are accessed, how often menu items are clicked, etc. Does anyone know of a 3rd party (open source or commercial) Cocoa/Obj-C library or plugin that would allow me to gather this info?
I have used pinch media in the past, and they merged with Flurry. Library was simple to use and was setup in around 40 minutes.
I don't know any library for that but at least to get informed about when the user switches the front application you can install an event handler like this:
EventTypeSpec eventType;
eventType.eventClass = kEventClassApplication;
eventType.eventKind = kEventAppFrontSwitched;
EventHandlerUPP handlerUPP = NewEventHandlerUPP(FrontAppSwitchedDetector_callback);
OSStatus status=InstallApplicationEventHandler(handlerUPP,1,&eventType,self,&_eventHandlerRef);
... and when receiving an callback you may get the current front application process:
pascal OSStatus FrontAppSwitchedDetector_callback(EventHandlerCallRef nextHandler,EventRef theEvent,void* userData)
{
ProcessSerialNumber newSerial;
GetFrontProcess(&newSerial);
//to something with that ....
return (CallNextEventHandler(nextHandler, theEvent));
}