File size: 1,049 Bytes
7c89ed7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
# Copyright (c) 2014 Mozilla Corporation


class message(object):
    def __init__(self):
        '''
        takes an incoming message
        and sets the type
        '''

        self.registration = ['google']
        self.priority = 5

    def onMessage(self, message, metadata):
        # make sure it's a google activity event
        # set the doc type
        # and do any clean up

        # check for details.kind like 'admin#reports#activity'
        if ('details' in message and 'kind' in message['details'] and
                'activity' in message['details']['kind']):
            # details.etag might be quoted..unquote it
            if 'etag' in message['details']:
                message['details']['etag'] = message['details']['etag'].replace('"', '')

            message['type'] = 'google'

        return (message, metadata)