Synchronize users between XMPP and django - ios

I'm creating an iOS app which uses django as my backend. I need to have a chat functionality between users.
I heard that XMPP is good for real time communication, and I have successfully set up ejabberd as the XMPP server. But still I'm having hard time to deal with the details:
I created the app first and then the chat feature, so before I setup ejabberd, there are already users in my django DB. I need ejabberd to authenticate users against my existing DB and I have almost solved this by using external authentication. There is only one small problem, as ejabberd seems to require the jabber ID like username#abc.com, and here abc means the virtual host of ejabberd. I don't know maybe I could only use one virtual host on my server(which is the domain name)? But then at the beginning I asked the user to register using emails which are from different domains of course, e.g. gmail.com, yahoo.com, but username#gmail.com#abc.com is not a valid jabber ID, so maybe one small trick I can do here is to convert first # to # and handle it properly in the python script in the backend. But maybe I did it totally wrong?
Another issue is about user profile. I stored the user information as well in my django DB, e.g. display name, avatar url, etc. I learnt that I could use the vCard module if I want to get those information from XMPP server. So maybe I need to have duplicated information in two places? And still I haven't figured out how to synchronize the user information from DB to ejabberd. Or maybe I just need to have only one source, which is my DB, and the iOS client could then query the information from the backend whenever needed?
I feel that XMPP is not easy to setup, is it really popular to use it in your Apps? Especially if chatting is not the main functionality of your App and you are not expecting to have huge messages from big number of users?

You wrote:
but username#gmail.com#abc.com is not a valid jabber ID
You are supposed to escape the user id (i.e "username#gmail").
XEP 106 explains how you should escape the node part of a JID.
In python, it would look something like this:
def escape_node(node):
""" """
node.strip()
node = node.replace('\\', "\\5c")
node = node.replace(' ', "\\20")
node = node.replace('\"', "\\22")
node = node.replace('\&', "\\26")
node = node.replace('\'', "\\27")
node = node.replace('\/', "\\2f")
node = node.replace(':', "\\3a")
node = node.replace('<', "\\3c")
node = node.replace('>', "\\3e")
node = node.replace('#', "\\40")
return node
With regards to storing your users' details in Django. When you register your Django users in XMPP, just make sure that you also register valid vCards for them.
When a Django user changes his details, update the vCard as well.

Related

How to assign specific mailbox for each user in Rails using ActionMailBox?

I am creating a service in which services can upload files from different methods.
One of them is by sending the file to a specific email address that is linked to the app.
I have managed to do so with a unique email address that is the same for all the users (generic#mail.com), but I would like that have a different address for every user (like user_specific_email#mail.com).
I am using MailBox on rails.
Do you know if it is possible ? And if so, is it more secured and generates less risks of bottleneck if a lot of mails are processed at the same time ?
Best

A few basic questions about Zendesk Support

Zendesk Support is a world-class site full of useful information. But after searching for, and reading, lots of articles I still have some very basic questions:
We run a travel site that takes bookings. We have a need to organise our emails so that everyone can easily find every email regarding an individual booking, both incoming and outgoing. (And later we would add other channels like chat and WhatsApp).
It seems to me that Zendesk Support would do this job well. But throughout the Zendesk site there only seems to be talk of using Support for problems.
1) I assume that it would also be good for bookings, is that right?
Ok, so we set up Zendesk and start using it. A client then writes to our chosen email address (we will retain and use one of our domain email addresses) and Zendesk Support automatically starts a thread and sends us an email to tell us about the new thread. We then open the Zendesk console, and find the thread.
2) To reply by email to the client we then write a comment in the Zendesk console - is that right?
3) And presumably our email system gets a copy of the comment?
4) What happens to our actual email system? - We will be doing everything in Zendesk, so all the usual maintenance of our email inbox is not being done - marking as read, cancelling stuff, moving to other folders and so on. How do people manage the inbox on the original email server?
Thanks for any help on this.
Zendesk Support is a world-class site full of useful information. But
after searching for, and reading, lots of articles I still have some
very basic questions:
We run a travel site that takes bookings. We have a need to organise
our emails so that everyone can easily find every email regarding an
individual booking, both incoming and outgoing. (And later we would
add other channels like chat and WhatsApp).
It seems to me that Zendesk Support would do this job well. But
throughout the Zendesk site there only seems to be talk of using
Support for problems.
You are correct in that a plurality if not majority of use cases are
for customer contact centers which usually focus on addressing issues
after they arise. At the same time, I know Zendesk is used for a
variety of other use cases including in your space.
1) I assume that it would also be good for bookings, is that right?
Ok, so we set up Zendesk and start using it. A client then writes to
our chosen email address (we will retain and use one of our domain
email addresses) and Zendesk Support automatically starts a thread and
sends us an email to tell us about the new thread. We then open the
Zendesk console, and find the thread.
Yep, that sounds correct. Details on the mechanism for configuring
the Support Address and redirecting messages to Zendesk can be found
here.
2) To reply by email to the client we then write a comment in the Zendesk > console - is that right?
While it is possible to work from an inbox, Yes, the main emphasis is
on working in the Zendesk agent console.
3) And presumably our email system gets a copy of the comment?
I would suggest to check out some of the articles provided by Zendesk
about email. forwarding, SPF, email archiving
4) What happens to our actual email system? - We will be doing
everything in Zendesk, so all the usual maintenance of our email inbox
is not being done - marking as read, cancelling stuff, moving to other
folders and so on. How do people manage the inbox on the original
email server? Thanks for any help on this.
Basically, Zendesk will be used by agents to respond to communications
and guide the interactions, and the email box can be considered as
operational in directing emails as needed. Separately you can
configure email archiving as linked above.
Depending on what system you're using, Gmail has a built in connector
described here, details on Exchange here, or something else here.
What do you want the interaction to look like between it and Zendesk
and what does your current operation look like compared to motivation
for using something like Zendesk?

iOS - Secure way to get data out of an app for a researcher

tl;dr What's the "right" way to get my data off an iPad such that only a researcher can receive and read it?
Full Explanation:
In my app, I've got to get the data from a database off the app and to a researcher. This will consist (most likely) of two separate files. The first will be table of identifying information:
ID FirstName ... etc.
This is sensitive identifying information that has to be sent so that only the researcher can get it.
The other will be de-identified info that uses ID numbers and the like, and it doesn't necessarily have to be secure, but I would like to only have it go to the researcher, obviously.
So far, I've only ever worked with data that can just be emailed, but there are some problems with this implementation. You can't just up and send an email; you can only present an email composition view ready to send, and then the user can edit the email before sending it. So a user could send this data to someone else.
Another wrench in the works: this researcher doesn't have access to a server, so I can't do SFTP uploads that way. It's also not guaranteed that the app will have internet access all the time.
The best idea I've got so far is to have a button to compose an email that attaches an encrypted file, protected by a password whose hash is hard-coded, I mean, compile-time provisioned, into the app.
EDIT: Here's what I'm going to do for the time being: use some personal server space so I can implement SFTP uploading, and then I will work with the researcher to get some server space they can use. Thanks for your answers.
Email is not particularly "safe" but if you just want to send email to one specific address, without the possibility of user intervening, you can use SMTP protocol yourself.
In one of my old apps I used skpsmtpmessage - I don't know if it still works, but if not there should be more solutions like it.
What it does is basically send email messages programatically, without using the composer dialog.

email service that lets you programmatically create addresses?

I'm considering adding email addresses to a marketing web app. Currently users are able to sign up and get a subdomain address that they can choose (theychoose.domain.com). So I'm thinking of also offering theychoose#domain.com for an email address they can use.
I've pretty much decided on sendgrid.com for sending email through the web interface which takes care of a ton of sending headaches. I'd also like to avoid setting up an email server if I could so I'm looking for services that allow me to set up an account and then programmatically create addresses when a user signs up. I want to find a service that will deal with all the spam filtering etc.
Also, this probably makes no difference but it's a Rails app.
One possibility is to use Google Apps Premier Edition. The API description can be found at http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference.html.
Keep in mind though, that each user will cost $50/year. However, if you make significantly more than that per registered user, then it may be worth it.

JID naming strategy for a bot army?

I'm planning an XMPP bot system in which a bot is "attached" to a Rails app in background to receive commands and so on. Is is appropriate to use the same account for all apps (40+) and just changed the resource part, like this:
account#host/bot1
account#host/bot2
account#host/bot2
or use totally different JIDs, like:
account1#host
account2#host
account3#host
Pros/cons? Thanks for any feedback!
I'm still learning about this myself, but I've observed that implementing the bots as resources associated with the same bare JID has some characteristics:
XMPP servers may route Message stanzas (but not IQs or Presence stanzas) addressed to one resource to another resource which shares the same JID if delivery fails
The Jabber Session Manager component seems to maintain roster information on the bare JID level, so all the bots will share a XMPP
You want to use unique JIDs, and not reuse same bare JID and change the resource. As Mitch described, sometimes the packet will go to the bare JID, sometimes the full JID. If you're already writing a Robot Army, make a setup script and register the unique names to create the accounts for the Army. It'll test that component as a bonus.
You will drive yourself crazy in 90% of your testing if you just change the resource name.

Resources