Skip to main content

Generic application to handle https://ejabberd-saas.com/ Remote Data API calls

djabberd

For each specific tasks a handler function must be implemented.

Install

pip install djabberd

Quick start

1. Include the django-ejabberd URLconf in your project urls.py like this::

url(r'', include('djabberd.urls'),
# For Django==1.8
url(r'', include('djabberd.urls'), namespace='djabberd')

2. Setup the handler in your Django settings::

DJABBERD_API_HANDLERS='your.module.path'

Based on ejabberd-saas’s documentation those endpoints are required(01-Feb-2016):

  1. User management:

    1. Authentication (‘/auth’)

    2. User exists (‘/user’)

  2. Roster management:

    1. Retrieve user roster (‘/roster’)

  3. Archive:

    1. Store (‘/archive’)

    2. Get (‘/archive’)

There must be one function for each endpoint that should be implemented like this:

  • user_authentication(username, password):

    • Returns True if authentication is valid

    • Returns False if authentication is not valid

  • user_exists(username):

    • Returns True if user exists

    • Returns False if not(or if it is not active)

  • retrieve_user_roster(username):

    • Returns the roster in JSON format

    • Returns False if user does not exist

  • archive_store(payload)

    • Returns True if message has been stored

    • Returns a string containing an error message if message has not been stored

  • archive_get(username[, peer, after, before, limit, chat_type])

    • Returns the message history in JSON format

    • Returns False in any other case

Formats

  • retrieve_user_roster:

    {"roster": [
        {"username": "CONTACT",
         "subscription": "both",
         "nick": "NICK"},
         ...
      ]}
  • archive_store:

    {"username": "USERNAME1",
     "peer": "USERNAME2",
     "xml": "MESSAGE_STANZA",
     "body": "TEXT",
     "timestamp": "TIMESTAMP",
     "direction": "DIRECTION"}
  • archive_get:

    {"archive": [{"username": "USERNAME1",
                  "peer": "USERNAME2",
                  "xml": "MESAGE_STANZA",
                  "body": "TEXT",
                  "timestamp": "TIMESTAMP",
                  "direction": "DIRECTION"}, ...]
                  "count" : MESSAGES_NUMBER
    }

Considerations

Based on ejabberd-saas’s documentation:

  • If XMPP JID is “userid@xmppdomain”, just pass “userid”

  • If XMPP JID of USER is “userid@xmppdomain”, just pass “xmppdomain”

  • If an exception is raised from your handler it would be treated as a server error

  • Return HTTP 200 for the successful case

  • Return HTTP 401 if authentication fails

  • Return HTTP 401 if it’s not the successful case

  • Return HTTP 500 for server errors, this is the Django’s default behavior

Running Tests

python setup.py develop
python runtests.py [tests.<tests_module>[.<TestClass>[.<test_method>]]]

Metadata

Release files for djabberd 0.9.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for djabberd 0.9.6
File Size Uploaded
djabberd-0.9.6.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for djabberd 0.9.6
File Interpreter ABI Platform
djabberd-0.9.6-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 27.6 kB

Release files / djabberd-0.9.6.tar.gz

Download URL djabberd-0.9.6.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
284806662cc5afc3e79b6e3cc03895e282ea672616fd2e6a96b2abfbab1af603
BLAKE2b-256 checksum
How to use checksums
db2dc7594621cd67f6a87d43438711899ded3f1846c8e7b22162e16308215e49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / djabberd-0.9.6-py2.py3-none-any.whl

Download URL djabberd-0.9.6-py2.py3-none-any.whl
Size 21.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
0c443b30f302799aef21cf954e5a989f335a4d9e13905cefb762f89b8fd7c5fc
BLAKE2b-256 checksum
How to use checksums
6172552d4adde14e5914f8cb760f57ab9541e6282a148f721a5c57422365a18f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.9.6 This release

2 release files

0.9.5

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page