I developed a Web Add-In for Outlook for my Company, which will set an E-Mail Header on an outgoing Mail to indicate whether a mail shall be encrypted by the MTA or not. Additionally, there shall be an indicator on the saved outgoing mail, to make it easy for the user to determine if the Mail was encrypted or not.
To archive this, I hook into the OnMessageSend event and simple change the icon and text of a notification.
It works like expected as long I run the Add-In locally in development. But as soon the Add-In is on the Production Server, it does not change the last notification within the OnMessageSend event. The saved mail, from the outgoing folder, still shows the "This Message will be encrypted" notification and not the indicator.
To fix this I tried several tricks like to implement a wait for the event to complete but nothing worked out. The Add-In does not change the indicator notification when put on the production server, just like it does locally in development.
Do maybe someone knows what's the problem here?
This is the Code snipped which will change the Notification on a Mail, when the User click the "Send" Button, based on the Security Settings for this mail:
// Define a callback function for checking the header.
function eventCallback(asyncResult) {
// Get the event pointer from asyncContext.
let event = asyncResult.asyncContext;
// If the function was executed successful.
if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
// If we got a value back aka there is our header,...
if (asyncResult.value) {
// ..if this is a dismiss routine set the message again.
if (dismiss) {
Office.context.mailbox.item.notificationMessages.replaceAsync("information", {
type: "informationalMessage",
message: "Ihre Nachricht wird Verschlüsselt.",
icon: "Icon.Lock.16x16",
persistent: true
});
} else {
// ..and set a new notification with a own icon to reflect the encryption state on the outgoing mail.
Office.context.mailbox.item.notificationMessages.replaceAsync("information", {
type: "informationalMessage",
message: "Diese Nachricht wurde Verschlüsselt.",
icon: "Icon.Cryptmail.16x16",
persistent: true
});
}
} else if (dismiss) {
Office.context.mailbox.item.notificationMessages.replaceAsync("information", {
type: "informationalMessage",
message: "Verschlüsselung wurde entfernt.",
icon: "Icon.Unlock.16x16",
persistent: true
});
}
} else {
let message = "Ein Fehler ist aufgetrehten: " + JSON.stringify(asyncResult.error);
event.completed({ allowEvent: false, errorMessage: message });
}
// Reset the dismiss global variable.
dismiss = false;
// Close the event, we are done here.
event.completed({ allowEvent: true });
}
The Notification when a user click the encrypt button on a mail:
The Message will be encrypted
The Notification of the saved outgoing mail in development:
This Message was encrypted
The Notification of the saved outgoing mail in production:
The Message will be encrypted
Related
Sorry about my English,
I tried to code a discord bot that sends a captcha to the new member, and if the captcha is good my bot gives them a role, it works but after it gets the role my bot crash with this error message:
console error image
voici mon code :
const { Client, IntentsBitField, EmbedBuilder } = require("discord.js");
const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent, //IMPORTANT: make sure you enable "Message Content Intent" in the dev portal!
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.DirectMessages,
]
});
client.login("bot tk");
const { Captcha } = require("discord.js-captcha");
client.on("ready", () => {
console.log("Bot opérationnel");
});
const captcha = new Captcha(client, {
roleID: "role id", //optional
channelID: "channel id", //optional
sendToTextChannel: true, //optional, defaults to false
addRoleOnSuccess: true, //optional, defaults to true. whether you want the bot to add the role to the user if the captcha is solved
kickOnFailure: true, //optional, defaults to true. whether you want the bot to kick the user if the captcha is failed
caseSensitive: true, //optional, defaults to true. whether you want the captcha responses to be case-sensitive
attempts: 3, //optional, defaults to 1. number of attempts before captcha is considered to be failed
timeout: 300000, //optional, defaults to 60000. time the user has to solve the captcha on each attempt in milliseconds
showAttemptCount: true, //optional, defaults to true. whether to show the number of attempts left in embed footer
customPromptEmbed: new EmbedBuilder(), //customise the embed that will be sent to the user when the captcha is requested
customSuccessEmbed: new EmbedBuilder(), //customise the embed that will be sent to the user when the captcha is solved
customFailureEmbed: new EmbedBuilder(), //customise the embed that will be sent to the user when they fail to solve the captcha
});
client.on("guildMemberAdd", async member => {
//in your bot application in the dev portal, make sure you have intents turned on!
captcha.present(member); //captcha is created by the package, and sent to the member
});
captcha.on("success", data => {
console.log(`Un membre a réussie le captcha !`);
console.log(data);
});
captcha.on("failure", data => {
console.log(`Un membre a raté le captcha !`);
console.log(data);
});
Thanks for helping me!
That error refers to your node.js particularly, this is warning regarding node.js that feature may change or be removed in future of node.js and it's not stable.
You can ignore the warning as it's experimental feature related only but you can suppress it by doing process.noDeprecation = true; in top of your file where this is causing mainly.
I have vue js application and i am consuming messages sent from a php script like this
document.addEventListener("deviceready", OneSignalInit, false);
function OneSignalInit() {
// Uncomment to set OneSignal device logging to VERBOSE
// window.plugins.OneSignal.setLogLevel(6, 0);
// NOTE: Update the setAppId value below with your OneSignal AppId.
window["plugins"].OneSignal.setAppId("");
window["plugins"].OneSignal.setNotificationOpenedHandler(function(jsonData) {
console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
});
// iOS - Prompts the user for notification permissions.
// * Since this shows a generic native prompt, we recommend instead using an In-App Message to prompt for notification permission (See step 6) to better communicate to your users what notifications they will get.
window["plugins"].OneSignal.setNotificationReceivedHandler(function(jsonData) {
this.$router.push({path: '/my_ads'});
});
window["plugins"].OneSignal.promptForPushNotificationsWithUserResponse(function(accepted) {
console.log("User accepted notifications: " + accepted);
});
}
In my code above, this gives me a notification that shows on android. I would like to send a message that do not require a notification prompt but i would like to consume the message sent inside my application i.e use the message sent and do something with it i.e go to another route
this.$router.push({path: '/another_route'});
How can i do that?
i am new to socket.io & nodejs. i have been writing a tictactoe game and i have a problem in it, my purpose is if someone refresh the page or close the browser let his/her opponent know . i know i should do this with disconnect event and here is what i try, but it is not working .
server side
socket.on('disconnect', function() {
socket.emit('user:disconnect');
});
client side
socket.on('user:disconnect', function() {
var message = player.getPlayerName() + ' leaves';
socket.emit('gameEnded', {room: this.getRoomId(), message: message,id:player.getPlayerId(),gameid: this.getGameId(),winType:"leave"});
});
also, i need to know how to get the room of disconnected user .
i already saw this but i just want to send the users in a room not all users in the whole application.
server.js
socket.on('disconnect', function() {
socket.emit('user:disconnect');
});
In the above code if a user named 'xxx' is disconnected, server is emitting 'user:disconnect' to the same user. You have to find the socket connection of other player and emit the event to that client.
You can achieve your goal by joining both the clients in a room and send message to other user in the room.
socket.join('room1');
io.sockets.in('room1').emit('user:disconnect');
Otherwise you have to store all clients as mentioned below and send message to the specific client using the following code.
var users = {
'client1': [socket object],
'client2': [socket object],
'client3': [socket object]
}
users['client3'].emit('user:disconnect')
I am trying to include Push Notification in my Hybrid Application.
While doing this, I am able to send the push notification message from rest client and also able to receive the notification in my Android device.
Now I want to the device user to get only the alert message which I send from the server.
For example:
In the body of my Post method,I am sending:
{
"alert": "Hello android"
}
Then, only "Hello Android" should be visible to him, even if I open the application.
Currently,when I test the above example,
when the user's app is open, he gets an alert message with details related to gcm sender, collapse_key information, apart from the alert message.
I am attaching screenshot here
function processNotification(notification) {
console.log("Hi! You have received a notification: " + JSON.stringify(notification));
alert("Hi! You have received a notification: " + JSON.parse(notification));
if(sap.Push.isPlatformIOS()){
sap.Push.resetBadge(resetBadgeSuccess);
}
}
Any Help would be appreciated
is there a way I can sent an alert from the server to the client? For example, a user clicks a button. That button calls a method on the server that checks if the user has been assigned an ID# yet. If the user has not been assigned an ID#, I want the browser to get an alert. I could easily do a check if I publish the ID# to the client, but the ID# is very sensitive and so I don't want to publish it. Any thoughts? Thank you in advance.
You can try something like the following:
1) On the client, create a button click listener that runs a Meteor method.
// CLIENT
Template.example.events({
'click button': function () {
Meteor.call('checkIfUserHasId', function (err, userHasId) {
if (!userHasId) {
alert('user has no id');
}
});
}
});
2) On the server, create the Meteor method that checks if the user has an id.
// SERVER
Meteor.methods({
checkIfUserHasId: function () {
// check if user has id
return true; // or false depending whether user has id or not
}
});
Meteor methods can be called remotely on the client but are defined on the server. This should help achieve what you want in terms of not exposing the id's when performing the check.