Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fac6fd5

Browse filesBrowse files
author
Bill Prin
committed
Add Missing XMPP Snippet
1 parent 502ef25 commit fac6fd5
Copy full SHA for fac6fd5

File tree

Expand file treeCollapse file tree

3 files changed

+22
-2
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+22
-2
lines changed

‎appengine/xmpp/app.yaml

Copy file name to clipboardExpand all lines: appengine/xmpp/app.yaml
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ inbound_services:
1313
- xmpp_presence
1414
- xmpp_subscribe
1515
- xmpp_error
16-

‎appengine/xmpp/xmpp.py

Copy file name to clipboardExpand all lines: appengine/xmpp/xmpp.py
+17-1Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,25 @@ def post(self):
6868
# [END error]
6969

7070

71+
# [START send-chat-to-user]
72+
class SendChatHandler(webapp2.RequestHandler):
73+
def post(self):
74+
user_address = 'example@gmail.com'
75+
msg = ('Someone has sent you a gift on Example.com. '
76+
'To view: http://example.com/gifts/')
77+
status_code = xmpp.send_message(user_address, msg)
78+
chat_message_sent = (status_code == xmpp.NO_ERROR)
79+
80+
if not chat_message_sent:
81+
# Send an email message instead...
82+
# [END send-chat-to-user]
83+
pass
84+
# [START send-chat-to-user]
85+
86+
7187
# [START chat]
7288
class XMPPHandler(webapp2.RequestHandler):
7389
def post(self):
74-
print "REQUEST POST IS %s " % self.request.POST
7590
message = xmpp.Message(self.request.POST)
7691
if message.body[0:5].lower() == 'hello':
7792
message.reply("Greetings!")
@@ -83,4 +98,5 @@ def post(self):
8398
('/_ah/xmpp/presence/available', PresenceHandler),
8499
('/_ah/xmpp/error/', ErrorHandler),
85100
('/send_presence', SendPresenceHandler),
101+
('/send_chat', SendChatHandler),
86102
])

‎appengine/xmpp/xmpp_test.py

Copy file name to clipboardExpand all lines: appengine/xmpp/xmpp_test.py
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,8 @@ def test_error(xmpp_mock, app):
5858
'from': 'sender@example.com',
5959
'stanza': 'hello world'
6060
})
61+
62+
63+
@mock.patch('xmpp.xmpp')
64+
def test_send_chat(xmpp_mock, app):
65+
app.post('/send_chat')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.