pinnwand

bpaste has migrated platforms. We now support self removal of pastes and will automatically import pastes from our old software for the following 2 months (that is, until the end of november 2014).

If you have any pastes you'd like to preserve please visit their URLs and they will be automatically imported with no expiry.

This paste never expires. Pasted by import. View raw.

 1
 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
28
29
30
31
32
33
class ChannelComms(webapp2.RequestHandler):
    @dopamine_api_handler
    def post(self):
        if 'device_id' in self.data:
            token_value = self.data['tokenValue']
        else:
            logging.warn("Channel Comms: No token present")
            return ('err_token_not_found', {
                'tokenValue': "undefined"
            })

        try:
            token = ndb.Key(urlsafe=token_value).get()
        except:
            logging.warn("Bad token_value, exception raised by .get()")
            logging.info("Token Value: [{}]".format(token_value))
            token = None

        if not token:
            logging.warn("Channel Comms: No token found")
            return ('err_token_not_found', {
                'tokenValue': token_value
            })
            
        ret = updatestream.channel_comms(
            token=token,
            message_type=self.data['type'],
            message_data=self.data.get('mData', None)
        )

        return {
            'updates': ret
        }