webXMPP

Check-in [9a029a23ed]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Initial work, accepting Mastodon pushes (can't get the d*mn server to hand us one, though).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:9a029a23ed8c4cfee0a7f39a4ec39e92c2ec369283772db5f3b76f51d1db909e
User & Date: web 2019-02-20 17:51:21
Context
2019-03-07
16:18
Support for experimental Web OS microservice architecture; notification light. check-in: c393c4bf57 user: web tags: master, trunk
2019-02-20
17:51
Initial work, accepting Mastodon pushes (can't get the d*mn server to hand us one, though). check-in: 9a029a23ed user: web tags: master, trunk
2018-12-08
16:14
Stop scanning when you get an answer. Don't flag default fall-through as error. check-in: 951cf42e72 user: vandys tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to main.py.

24
25
26
27
28
29
30
31
32
33
34
35




36
37


38
39





40
41
42
43
44
45
46

	chore.handlers.Chore_Handler.__init__(self, conn, tup, approot,
	    (GET_mixin.__init__,
	     POST_mixin.__init__,
	     PUT_mixin.__init__,
	     Authen_mixin.__init__))

    # SMS postings are defended by IP checks, not authentication
    def handle_noauth(self):
	# This check is before options are parsed, so self.paths
	#  isn't available and we have to look directly at the
	#  specified path.




	if self.path and self.path.startswith("/sms"):
	    return True


	if self.path and (self.path == "/favicon.ico"):
	    return True





	return False

    # If they appear by way of a saved cookie, we may need
    #  to set up their User right now
    def auth_ok(self):
	webxmpp = self.server.approot
	if self.user in webxmpp.users:







|
<
|
|
|
>
>
>
>
|
|
>
>
|
|
>
>
>
>
>







24
25
26
27
28
29
30
31

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

	chore.handlers.Chore_Handler.__init__(self, conn, tup, approot,
	    (GET_mixin.__init__,
	     POST_mixin.__init__,
	     PUT_mixin.__init__,
	     Authen_mixin.__init__))

    # Which queries skip the authentication step?

    # This check is before options are parsed, so self.paths
    #  isn't available and we have to look directly at the
    #  specified path.
    def handle_noauth(self):
	if self.path:

	    # SMS postings are defended by IP checks, not authentication
	    if self.path.startswith("/sms"):
		return True

	    # Let'em see our icon, if any
	    if self.path == "/favicon.ico":
		return True

	    # Mastodon pushes
	    if self.path.startswith("/mast"):
		return True

	return False

    # If they appear by way of a saved cookie, we may need
    #  to set up their User right now
    def auth_ok(self):
	webxmpp = self.server.approot
	if self.user in webxmpp.users:

Changes to post.py.

2
3
4
5
6
7
8

9
10
11
12
13
14
15
16
17
18

19
20
21
22
23
24
25
...
119
120
121
122
123
124
125



















# post.py
#	HTML POST/PUT handling
#
# POST's put state back to us--usually a text to send.
#
# /msg.json - JSON of a message to send
# /sms.json - JSON of a Flowroute-style SMS delivery

#
import sys, json, os
from chore.utils import toascii
import chore
import acct_sms

class POST_mixin(object):
    def __init__(self):
	self.dispatchers.append( ("POST", self.post_msg) )
	self.dispatchers.append( ("POST", self.post_sms) )


    # Does SMS blacklisting apply to this message?
    def filtered(self, msg):
	approot = self.server.approot

	# No blacklist
	if approot.smsblack is None:
................................................................................


	# Log a message on our own display
	user.add(False, towhom, body)

	# Empty result body
	return True,self.send_result("", "text/html")


























>










>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
...
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# post.py
#	HTML POST/PUT handling
#
# POST's put state back to us--usually a text to send.
#
# /msg.json - JSON of a message to send
# /sms.json - JSON of a Flowroute-style SMS delivery
# /mast.json - We Push from Mastodon
#
import sys, json, os
from chore.utils import toascii
import chore
import acct_sms

class POST_mixin(object):
    def __init__(self):
	self.dispatchers.append( ("POST", self.post_msg) )
	self.dispatchers.append( ("POST", self.post_sms) )
	self.dispatchers.append( ("POST", self.post_mast) )

    # Does SMS blacklisting apply to this message?
    def filtered(self, msg):
	approot = self.server.approot

	# No blacklist
	if approot.smsblack is None:
................................................................................


	# Log a message on our own display
	user.add(False, towhom, body)

	# Empty result body
	return True,self.send_result("", "text/html")

    # Mastodon event, web push
    def post_mast(self, buf):

	# /mast.json
	if not self.path_match("mast.json"):
	    return False,None

	# Log a Mastodon push
	sys.stderr.write("POST Mastodon: %s\n" % (buf,))
	f = open("/tmp/mast.log", "a")
	f.write("%s\n" % (buf,))
	f.close()

	# TBD, decode and turn to message event

	# If we error, they just re-deliver more times, so always
	#  accept it, even if we have to log an issue with handling it.
	return True,self.send_result("", "text/html")