How the notification system of any messaging app works - java

I apologize for my English right away. My question is very simple: when I send a message to a person, how does that particular person receive the notification? I know there are many services that do this, but I would like to understand the process behind it. My theory is this: there is a trigger on the message table, as soon as a record is added to this table, the backend sends a notification to the person, but the thing I don't understand is how can I track the person, I don't believe via IP since it is unreliable. I really apologize for my ignorance and I hope you can help me.

Related

Hide Entity for some Players - Spigot/Bukkit - Java

I tried to hide an Entity (ArmorStand) for some Players. Is there a Method like for Players (Player1.hidePlayer(Player2);)?
Thank you for your help and sorry for my bad English :)
I personally would suggest utilizing packet manipulation to do this. Specifically using a destroy packet as well as cancelling any ping packets sent to the player. I'm not sure if it's still a thing but we used to abuse this to determine what admins were online and in vanish because even though Bukkit/Spigot sent the destroy we continued to receive pings from the player to update them on the scoreboard even if they weren't present on the scoreboard. Big tell.
Also in reference to the "ping" packet I'm referring to I believe Entity Status with a certain code.

Trouble receiving multiple emails with camel aggregator

I'm truly not sure how to word this correctly, but I'll try my best.
I want to send n emails to n recipients via a camel route and have those n recipients send approvals to the sender, which is done by using the world 'approve' in the subject, at which point, I'd trigger a process.
The first half of this task is done, as sending emails is a relatively simple task in Camel. Receiving is as well. My problem lies in the fact that I'd like to wait on these n emails to be received before continuing.
I'm using this code to attempt to do the latter half.
from("imaps://imap.gmail.com?username=emailaddress#gmail.com&" +
"password=RAW(password)&searchTerm.subject=approve")
.aggregate(header("*"), new UseLatestAggregationStrategy())
.completionSize(2)
.process(myProcess);
I know this code won't do exactly what I'm asking for, but it's what I'm working with for now. I'm getting this error when I drop the .jar into ServiceMix
org.apache.camel.CamelExchangeException: Invalid correlation key. Exchange[MailMessage:
I've tried looking up the error, but I haven't gotten much that's helpful. It's fairly obvious it's from either the header or the aggregation strategy, but again, I have yet to find anything useful for my situation.
Is there a better way to do this? I feel like my problems are coming from not completely understanding the nuances of camel, so there may very well be an easier/better way to achieve this. If not, what am I missing?
I apologize if I've left anything useful out. Feel free to ask questions.
You can use a constant as the correlation key if you want any message to be grouped together, for example:
.aggregate(constant(true), new UseLatestAggregationStrategy())

Dummy email address and Email parser

If you're not interested in helping a beginner in email parsing, don't read further.
I have been programming for a while so I know the gist of things. But, I'm really interested in creating a dummy email address and then set up a parsing program inside of it (if thats even how you do it)
Scenario:
I have an email account which receives certain emails which need parsing. I want to be able to forward those emails to a "dummy" email address which is basically just a program which parses the email for sender, subject, and message. I would prefer to write a runnable jar program or something on windows but I'm willing to do web programming if need be. Android programming is also an option for me.
What would I do to get started? I'm not asking for anyone to write out everything, I just need a starting point for all of this.
Thanks!
What you describe can be solved like this:
1/ Create a catch-all address *#yourdomain.com which will receive all incoming e-mails except those who match an existing email address (e.g. contact#yourdomain.col)
2/ Pipe all incoming e-mails to a script with Procmail
:0
| `/home/foouser/scripts/footool/footool.sh`
3/ Let the script process the e-mail (read headers, save in db, ...)
Another, probably much more easy solution would be to use a web service like cloudmailin.com for this. If the structure of the e-mail is always the same, an email parsing solution like mailparser.io could help you as well.

Devise customization for registration and confirmation

I was just about to follow this tutorial:
http://eureka.ykyuen.info/2011/03/03/rails-%E2%80%93-add-custom-fields-to-devise-user-model/
But then realized that my Devise needed some customizing. I am very new to Rails, so sorry for anything in advance.
What I am doing:
I need to create a site for a Minecraft server a friend and I are making. I set up devise with no extras, just an access level (admin, moderator, developer, ranks, etc.). I am using mongoid for everything here.
What's the problem? I need to make sure that the user really owns their minecraft account! The way I want to do it: In game you type /register [email], you are sent an email with a confirmation link, you click it and done, you are now registered.
What I am asking: Can someone guide me as to: What I need to do in Java, simply what's needed to be done, not the code (in PHP I've done this before, I opened up a connection to a page, I sent username and a hash as parameters), and what must be done in Rails (Change up some views, totally redo the insides of Devise, just what's needed, and some examples). I'm quite new to rails, so please be nice to my brain! Thanks!
I understand it's a big request for help, but if you have some idea of how this can be done, please help. Thank you for reading!
Edit:
Okay... I really am getting desperate here, I will make it as simple as I can:
How do I customize Devise confirmation? I want it like this: from JAVA I can create a user (with only his username and email) who can't log in because he hasn't confirmed yet. When the site gets this request to make an account, I want to dispatch an email with mailer with a confirmation link. From there, instead of just going ahead and verifying, I need them to type their password and reconfirm it, because remember: the account was created without the password, only username and email! After they fill in the form, their account is active!
Please help, I need this done quickly, my app is quickly growing and it will be a hassle to change this all. Until someone can help me, to make things better in user I am using a method to get what display name I want them to use, right now it's set to email, after someone helps me I can finally make it username!
Thank you for reading, please reply if you know the answer or upvote so someone can provide a good answer!
(Assuming that you already added the username field to the User model created by Devise)
What I would do:
Create a simple form, no Devise at all, just a standard form that takes the username and the email.
Email the user. This email will have the Devise form and/or a confirmation link.
If placing the Devise form in the mail is not possible, have it displayed in the page linked by the confirmation email. Of course, you can now auto-complete all the fields except for the password.
With this approach you don't have to dig in the guts of Devise. Use it out of the box, but until the second interaction with the user.

How to send a broadcast message with SmackAPI?

We're developing special devices that uses XMPP to talk to each other. A new API i am developing now, should talk to these devices too. The problem i am facing - all these devices are building little groups - for each customer we have... so we will have a chat-room for each group of devices, or, for each of our customer with his bunch of devices ;)
But now.. the api should be able to talk to every device that is connected. I don't need a real broadcast-mechanism - in the end, i will send a message only to one specific device..
But i don't want to login to each chat-room either - running a product with over 40k customers and much more devices, will end in a funny api, that is opening over 40k chat-rooms at startup... even if don't tried this yet, i can't imagine that an app like this will run well... even though we can have millions of customers in a few years.. i don't like solutions that will grow linear with the amount of customers, if you know what i mean :/
Now, basically i'm thinking of a solution, where i just can use the basic XMPPConnection to do my stuff.
MyCustomMessage msg = new MyCustomMessage();
msg.setTo("*"); // don't know what to address, i want to send it to "all"
msg.setFrom("ThatAPI"); // just a string telling that is sent from my java api ;)
msg.setEvent(event); // stuff that is coming through the parameters of the method where this code is inside
msg.setCustomStanza(data); // same here
connection.sendPacket(msg); // my try to send it to all till now..
Somewhere in the Ignite Realtime Forums i have read of one guy who "solved" it, but everything he says is "it's working now, i push my message through the sendPacket of Connection"... ok nice, my attempt of this seems not to work :(
Any better ideas/real implementations how this will work fine?
Basically i start to think that XMPP will not be the best technology to achieve something like this at all - i wish i could have a real/basic socket-implementation where something like this would be piece of cake.. But i can't choose - the third-party-system has implemented XMPP already... not enough time to change all of this... Just if you're wondering why we try this on XMPP..
You seem to have some conflicting requirements in that you want to send to all devices now, but only 1 specific device later. Are both models required at the same time, or do you plan on switching? How either is done would be different solutions.
As for your current approach, I think pubsub would make more sense than your chatroom approach, as that is oriented to generic message passing to subscribers.
You could set up a pubsub node per customer to send messages to all
of their devices.
As for a broadcast to all, you can make all devices
subscribe to a single pubsub node.
Thus you control broadcast and group messages by sending to the appropriate pubsub node.
For sending to a specific device, that is just a sendPacket to the specific entity, nothing really special there.

Categories

Resources