Transient result in Bixby - bixby

I am trying to make a result transient in bixby.
Specify a text reply like so:
text (reply) {
description (HomeAssistant conversation reply)
features {
transient
}
}
However it seems as if the result is still cached, what am I missing here?
Thanks.

Perhaps the data is being cached in your server side? Here's a related question and answer to this here.

Related

Is there a way to delete the response to an interaction (discord.js)

I recently started converting my commands to slash commands. I successfully did that, but I'm missing one functionality that I can't seem to find how to do. I want to delete the response I've given to an interaction (so the callback), and if possible after a certain amount of time (but that isn't required for my Discord bot).
For example, my callback is posted like this:
client.api.interactions(interaction.id, interaction.token).callback.post({
data: {
type: 4,
data: {
content: 'Hello World!'
}
}
})
And I want to delete that response immediately (or timed, but not in this example).
In the Discord docs (this page) is standing that it is possible, but I don't know how exactly to do that.
The specific code I already tried is this, but when the code is executed I'm getting the METHOD NOT ALLOWED error:
client.api.interactions(interaction.id, interaction.token).callback.delete()
I hope you can help me, thanks in advance.
Sorry for my bad English 😉
you can just fetch this :
https://discordapp.com/api/webhooks/{APP ID}/{Interaction Token}/messages/#original
Like That :
fetch("https://discordapp.com/api/webhooks/123456789012345678/${interaction.token}/messages/#original",
{
method: "DELETE"
}
);
https://discord.com/developers/docs/interactions/slash-commands#delete-original-interaction-response

What is considered standard when dealing with database errors in a REST application?

I'm currently writing a public REST service in Node.js that interfaces with a Postgres-database (using Sequelize) and a Redis cache instance.
I'm now looking into error handling and how to send informative and verbose error messages if something would happen with a request.
It struck me that I'm not quite sure how to handle internal server errors. What would be the appropriate way of dealing with this? Consider the following scenario:
I'm sending a post-request to an endpoint which in turn inserts the content to the database. However, something went wrong during this process (validation, connection issue, whatever). An error is thrown by the Sequelize-driver and I catch it.
I would argue that it is quite sensitive information (even if I remove the stack trace) and I'm not comfortable with exposing references of internal concepts (table-names, functions, etc.) to the client. I'd like to have a custom error for these scenarios that briefly describes the problem without giving away too detailed information.
Is the only way to approach this by mapping every "possible" error in the Sequelize-driver to a generic one and send that back to the client? Or how would you approach this?
Thanks in advance.
Errors are always caused by something. You should identify and intercept these causes before doing your database operation. Only cases that you think you've prepared for should reach the database operation.
If an unexpected error occurs, you should not send an informative error message for security reasons. Just send a generic error for unexpected cases.
Your code will look somewhat like this:
async databaseInsert(req, res) {
try {
if (typeof req.body.name !== 'string') {
res.status(400).send('Required field "name" was missing or malformed.')
return
}
if (problemCase2) {
res.status(400).send('Error message 2')
return
}
...
result = await ... // database operation
res.status(200).send(result)
} catch (e) {
res.status(500).send(debugging ? e : 'Unexpected error')
}
}

Notification in ajax response orchard

I'm using ajax requests to get one of PartialViews in my project. I want to pass a message by INotifier.
Cuttently i'm using HttpStatusCodeResult return new HttpStatusCodeResult(204, "Message");to pass informations about the errors but is not satisfying solution.
$(this).load($(this).attr("href"), function (response, status, xhr) {
if (xhr.status == 204) {
// show message
}
});
I'm wondering that is possible by using standard INotifier.Error() in ActionResult.
Nope. The default notifier is not suitable for AJAX requests. What it does, it queues notifications inside a temporary collection. Queued notifications are then written to the client when request ends - pushed into Layout.Messages zone.
In your case it would be best to implement your own INotifier that would follow the required logic. It's a very simple interface to implement so it's not actually that much work.
I needn't to implement INotifier, i only placed in my PartialView this:
#Display(WorkContext.Layout.Zones["Messages"])
Now the message isn't rendered in main zone (in Layout.cshtml of used theme), but could be placed anywhere in your PartialView, for example under the affected table.

can't into OnChar() when deal with WM_KEYDOWN in 'PreTranslateMessage' function

For some reason, I need to do something when I get WM_KEYDOWN message in PreTranslateMessage, So I do something like this:
if(WM_KEYDOWN == pMsg->message && pMsg->hwnd == GetSafeHwnd())
{
SendMessage(pMsg->message,pMsg->wParam,pMsg->lParam);
return TRUE;
}
After doing so, I find there is no way to get into OnChar function, It's bad.
Anybody knows why and how to solve this problem? Help will be greatly appreciated.
When you return TRUE from PreTranslateMessage() then the message won't be processed further. You do this for every keystroke, so none will be processed and can never generate a WM_CHAR message. In other words, you got what you ask for. It also looks like you are sending the message to yourself. Hard to suggest an alternative, the code doesn't make sense.
Why will you send the same message to yourself? If all you want to do is do some processing and let the message pass through all you need to do in the 'if' statement is do your processing and let the normal message chaining work. This way the message will dispatched for further processing and eventually reach your onChar.
so your code should be something like this:
void YourWnd::PreTranslateMessage(MSG *pMsg)
{
if(WM_KEYDOWN == pMsg->message && pMsg->hwnd == GetSafeHwnd())
{
processKeyDown();
}
return CWnd::PreTranslateMessage(pMsg);
}
Why PreTranslateMessage? What possible reason would you have to do it in PreTranslateMessage?
PreTranslateMessage as the name suggests pretlanslate messages containing hot/shortcut keys.
Using it as some kind of a bandage very frequently leads to disaster sooner or later.
Could you please tell us what you are trying to achieve? Somebody will be able to come up with better solution.

node-cloudfiles module - Is there a way to track upload progress

If anyone here is familiar with the node-cloudfiles module for node.js, I could use some help in several different areas. Unfortunately, is seems the authors are nearly impossible to reach via their github repo (EDIT: nevermind, someone did reach out to me, I'll send an update when I have an answer of some sort prepared.)
I'll start with my most basic challenge: is there a way to track the progress of the upload? I have tried many things, but the object returned from the .addFile command does not seem to hold any sort of progress stats.
Here is a basic outline of what I am working with.
var readStream = fs.createReadStream(path+'.'+extension, streamopts);
var upOpts = {
headers: {
'content-type': 'video/'+extension,
'content-length': totalBytes
},
remote: CDNfilename,
stream: readStream
};
//reqStream is the object returned from the 'request' module,
//which is used by the 'cloudfiles' module.
var reqStream = cloudClient.addFile(Container.name, upOpts, function (err, uploaded) {
if (err) { console.log(err); }
});
At first I thought I could just use the .bytesWritten property connected to an interval timer, but the object is not a normal node writeStream, so there is no such property.
Charlie (the author of the module) told me that this is possible because it's using a pipe and you just check the data events from the object returned from .addFile, like so:
reqStream.on('data', function () {
/* track progress /*
});
Whenever you need to contact somebody from the nodejitsu team, join the #nodejitsu channel on IRC, they're really active.
At the time of writing this answer, there isn't really a good way to get upload progress for files being sent to cloudfiles. However, one of the nodejitsu geniuses implemented chunked uploading, which in my case, eliminates the need for progress reports. Thanks Bradley.

Resources