How to browse message by ID - activemq-artemis

I need to browse a message by ID.
In QueueControl.class I find the method browse(), which return all messages, and method browse(#Parameter(name = "filter", desc = "A message filter (can be empty)").
I tried to get the message with a filter "messageID = '10737437509'" (based on the example here https://activemq.apache.org/components/artemis/documentation/latest/filter-expressions.html), but this didn't work.
How to browse the message by ID?

Filtering seems to be applied to message properties only, not headers (like messageID).
You can set a custom message id property before send:
TextMessage message = session.createTextMessage("abc");
message.setIntProperty("myMessageID", 123);
producer.send(message);
Then, you can filter by property like this:
CompositeData[] browse = queueControl.browse("myMessageID=123");
if (browse != null && browse.length > 0) {
System.out.println((String) browse[0].get("text"));
}

Related

Outlook draft message changes immutable ID when sent

Context I am using: office-js (retrieve rest ID of message item), java backend (using GraphClient to get the immutable ID, subscription webhook endpoint)
When I get the rest itemId of the draft item via office-js like this:
Office.context.mailbox.item.saveAsync((asyncResult) => {
if (asyncResult.error) {
//hadle
} else {
resolve(
Office.context.mailbox.convertToRestId
(
asyncResult.value,
Office.MailboxEnums.RestVersion.v1_0
)
);
}
});
I send it to the backend where I translate it to Immutable ID, via GraphClient, that I save.
Once I get a notification on my subscription endpoint (I change and save the subject of the message draft
in outlook), it is successfully paired.
Problem is when I send the draft from outlook. I get notification to the subscription enpoint, but it has a different immutable ID. I create subscriptions with Prefer header like this:
Subscription subscription = new Subscription();
subscription.changeType = "updated";
subscription.notificationUrl = notificationUrl;
subscription.resource = resource;
subscription.expirationDateTime = OffsetDateTime.now().plusDays(2);
subscription.clientState = secret;
subscription.latestSupportedTlsVersion = "v1_2";
SubscriptionCollectionRequest request = graphServiceClient.subscriptions().buildRequest();
if(request != null) {
request.addHeader("Prefer", "IdType=\"ImmutableId\"");
request.post(subscription);
} else {
Is there anything I am doing wrong? Draft is move to the "Sent items" folder, which should not change immutable ID (https://learn.microsoft.com/en-us/graph/outlook-immutable-id).
Ids looks like this AAkALgAAA.........yACqAC-EWg0AC.......7B4s_RdwAA....TwAA I suppose they are correct. Just last section after underscore changes on draft sent.
Not surprising at all - it is a physically different message. Just the way Exchange works - sent/unsent flag cannot be flipped after the message is saved, so a new message is created in the Sent Items folder.

How to get the "body" and "subject" fields of a draft when extending compose UI?

We are developing a Gmail Addon in which we extend the compose UI.
This extends the compose window in which you can compose your e-mail.
We need the 'From', 'To', 'Subject' and 'Body' of the message that is being composed.
The 'From' can be read from the Session object like this
var mySelf = Session.getEffectiveUser().getEmail();
The 'To' can be read from the draftMetadata from the event object of the function being called.
function composeEmail(event) { console.log(event.draftMetadata.toRecipients); }
The 'Subject' and 'Body' can't be read from the event object of the function since it is a composeTrigger. The argument contains these objects:
{
formInput = {},
clientPlatform = web,
formInputs = {},
parameters = {},
draftMetadata = {
toRecipients = [test #test.com],
subject = ,
bccRecipients = [],
ccRecipients = []
}
}
Surprisingly to me, the subject key is there but not being filled in (yes I did type in a subject).
Question:
How can I get the 'Subject' and 'Body' of the E-mail being composed by the user in the extended composer UI?
Extra information:
The contextual trigger action contains the following object as event object:
{
clientPlatform = web,
messageMetadata = {
messageId = 16e agg7323451256989f68,
accessToken = AAGdOAawdaAOW8PWchmdawdk0N13STKnBPMAOXVjZVHyQMfAawdBtgEIrS6N8y5h2BOZnKFPlfsl5VBsyPiF7YiONOoP7XVjKZawdi - E6vI - jVU92dPmfj3RNmXfawdawdeaNMrXehAFLm
}
}
By reading an email through the contextual trigger a messageId is being added in which the getBody and getSubject methods can be used.
As of now, the Compose Trigger Event never returns the value of the subject field.
I have filled a bug for this here. Click the ★ icon to follow this Issue and get updates. This will also help prioritize this Issue.
As a workaround, you can use the contextual trigger to:
Get the messageId
Find drafts that have that messageId associated to them
Get the draft by their draftId
Fetch the subject line from the Headers object on the draft.
This only works on drafts that are replying to a specific message.
I've never done this before so this is a guess. I looked at the compose dialog html with the developer tools and this is what I noticed.
There seem to be a bunch of hidden inputs that are used to store values that are typed into the compose dialog. So I would try something like:
formInputs.body or perhaps formInput.body taking the name of the key from names of this hidden elements. This is just a guess.

How to change success message of form extension?

I'm using the system extension form for small contact forms. The default success message is
The form has been sent successfully by mail
How can this message and the error message be changed and/or translated?
Edit your form content element, go to tab Form. There you will see the form configuration. In block postProcessor add a message block:
postProcessor {
1 = mail
1 {
recipientEmail = contact#example.com
senderEmail = form#example.com
subject = Call me please
messages {
success = Thank you! We will call you soon.
error = Oops! Something went wrong.
}
}
}

Mark an order as "Full Payment" on Sage 200

I am inserting orders on Sage 200 through an application using the client side, C# and APIs.
I would like to check the "Full payment" checkbox on the "Payment with order" tab.
Currently, I am setting the PaymentType property, which is not working.
order.PaymentType = Sage.Accounting.SOP.SOPOrderPaymentTypeEnum.EnumSOPOrderPaymentTypeFull;
order is an instance of Sage.Accounting.SOP.SOPOrder.
Do you know how I can check that property?
The following method should supply the required results.
private static void SetPaymentWithOrder(Sage.Accounting.SOP.SOPOrder sopOrder)
{
// Indicate that order has payment
sopOrder.PaymentWithOrder = true;
// This is full payment order
sopOrder.PaymentType = Sage.Accounting.SOP.SOPOrderPaymentTypeEnum.EnumSOPOrderPaymentTypeFull;
// Fetch the the Payment Methods. SOPPaymentMethods contructor accepts the boolean flag whether to fetch payment methods including card processing method or not.
Sage.Accounting.SOP.SOPPaymentMethods paymentMethodsCollection = new Sage.Accounting.SOP.SOPPaymentMethods(false);
// Set the first payment method of the collection to the order
sopOrder.PaymentMethod = paymentMethodsCollection.First;
}
dont know if you ever managed to figure this one out or not.
Not sure if you knew this, but you cannot modify the Sales Order on the view form, or at least shouldn't be trying to do so.
Using either of the Enter/Amend Sales Order forms will allow you to do so.
What is potentially happening, is that the properties that the controls are bound to are not updating the UI after your code has run.
You can simply force this to happen using the following
Fetching the underlying bound object
public Sage.Accounting.SOP.SOPOrderReturn SOPOrderReturn
{
get
{
//Loop over the boundobjects collection
//check if the bound object is of the type we want - e.g. SOPOrderReturn
//if correct type, return this object
Sage.Common.Collections.BoundObjectCollection boundObjects = this.form.BoundObjects;
if (boundObjects != null)
{
foreach (object boundObject in boundObjects)
{
if (boundObject is Sage.Accounting.SOP.SOPOrderReturn)
{
this._sopOrderReturn = boundObject as Sage.Accounting.SOP.SOPOrderReturn;
break;
}
}
}
return this._sopOrderReturn;
}
}
Fetch the correct underlying form type that the amendable form is, suspending the databinding,
perform your changes,
resuming the databinding
Sage.MMS.SOP.MaintainOrderForm maintainOrderForm = this.form.UnderlyingControl as Sage.MMS.SOP.MaintainOrderForm;
maintainOrderForm.BindingContext[this.SOPOrderReturn].SuspendBinding();
this.SOPOrderReturn.PaymentWithOrder = true;
this.SOPOrderReturn.PaymentType = Sage.Accounting.SOP.SOPOrderPaymentTypeEnum.EnumSOPOrderPaymentTypeFull;
maintainOrderForm.BindingContext[this.SOPOrderReturn].ResumeBinding();
should do the trick.

Updating mail draft using Domino REST API causes message to appear in Send folder

I am using the Domino Mail REST API and am able to create a new draft mail which appears in the Drafts folder.
When I update the draft mail it appears in the Sent folder and is no longer visible in the Drafts folder.
This is unexpected. The message was not sent. I have also tried setting the From and To fields to null and the sresult is always the same.
Partial code:
Gson gson = new Gson();
String json = gson.toJson(message);
// if message has an id then do update
if (href != null && href.trim().length() > 0) {
url = createFullQualifiedRequestUrl(href);
HttpPut request = new HttpPut(url);
request.setHeader("Content-Type", "application/json");
request.setEntity(new StringEntity(json, "utf-8"));
response = this.executeRequest(request, username);
} else {
MailboxFolder folder = getFolder("drafts", username);
url = this.createFullQualifiedRequestUrl(folder.getLink()
.getHref());
HttpPost request = new HttpPost(url);
request.setHeader("Content-Type", "application/json");
request.setEntity(new StringEntity(json, "utf-8"));
response = this.executeRequest(request, username);
}
if (response != null) {
SendMessageResult result = parseResponse(response);
if(href != null)
result.setLocation(href);
return result;
}
That's a bug in the REST mail API and Richard is correct about the root cause. The bug will be fixed in the next release of the extension library (901v00_12). I can't say exactly when release 12 will be available, but it should be soon.
Most likely, your problem is being caused by something that is setting the PostedDate item to a non-empty value.
The Sent "folder" is not a folder. It is a view. The same is true for the Drafts "folder". It is also a view. If you go into Domino Designer and look at the views, you can see their selection formula. You will see that they look something like this
Sent
SELECT DeliveredDate = "" & PostedDate != "" & !(#IsMember("S"; ExcludeFromView))
Drafts
SELECT PostedDate = "" & $MessageType = "" & #IsNotMember("D" : "A"; ExcludeFromView) & ISMAILSTATIONERY != 1 & Form != "Group" & Form != "Person"
Note that these are taken from a rather old version of the mail template, so what you actually see may be different, but AFAIK the idea has not changed. Documents appear in Sent if they contain a non-empty PostedDate item and the DeliveredDate item is either empty or missing and they are not marked for exclusion. Documents appear in Drafts if they do not contain either of those two date items, are not marked for exclusion, are not stationery, and are not Group or Person docs. The one thing that is in common here is the dependence on the PostedDate item.