Exemplo n.º 1
0
    def get(self):
        '''
        Fetches the wavelet and returns the template html
        '''
        logging.info("GET: /wave")

        #Fetch the auth values from the url
        self.wave_id = self.request.get('waveid', "")
        self.wavelet_id = self.request.get("waveletid", "")
        self.email = self.request.get("email", "")
        self.auth_token = self.request.get("auth", "")

        logging.info("Request waveid: " + self.wave_id + " waveletid: " + self.wavelet_id + " email: " + self.email + " auth token: " + self.auth_token)

        wavelet_details = waveRpc.retry_fetch_wavelet_json( config.HTTP_IMPORTANT_RETRY,
                                                            mrray,
                                                            self.wave_id,
                                                            self.wavelet_id)
        settingsTools.markSeenChanges(key={ 'wave_id'   : self.wave_id,
                                            'wavelet_id': self.wavelet_id,
                                            'email'     : self.email})
        wavelet_json = utils.construct_wavelet_json_for_http_response(  wavelet_details,
                                                                        self.wave_id,
                                                                        self.wavelet_id,
                                                                        self.email,
                                                                        b64Encode=True)
        self._renderWavePage(wavelet_json)
Exemplo n.º 2
0
    def _PublicReplies(self):
        '''
        Sends a reply to wave from the public user
        Maybe consider merging this into _publicReplies in the future. Methods are very similar
        '''
        self.name = self.incoming.get("name", None)
        if not self.name:
            logger.warn("The response came from a public wave and expected the 'name' field but was not found")
            raise MalformedRequest("The response came from a public wave and expected the 'name' field but was not found")
        if not re.match("^[a-zA-Z0-9_]+$", self.name):
            logger.warn("The response came from a public wave and expected the 'name' field to only contain [a-zA-Z0-9_] but it was " + name)
            raise MalformedRequest("The response came from a public wave and expected the 'name' field to only contain [a-zA-Z0-9_] but it was " + name)
        
        #Fetch the wavelet and do some house-keeping
        wavelet = waveRpc.retry_fetch_wavelet(  config.HTTP_IMPORTANT_RETRY,
                                                mrray,
                                                self.wave_id,
                                                self.wavelet_id)
        
        try:
            wavelet.robot_address = config.ROBOT_EMAIL
        except:
            pass#The wavelet already has the robot address
        proxy_for = utils.getProxyForFromPublic(self.name)
        
        if wavelet.participants.get_role(config.ROBOT_IDENT + "+" + proxy_for + "@" + config.ROBOT_DOMAIN) == wavelet.participants.ROLE_READ_ONLY:
            #TODO wrong exception raised here
            raise waveRpc.NotParticipantException("Wave permissions do not permit reply")
        if wavelet.participants.get_role(config.ROBOT_EMAIL) == wavelet.participants.ROLE_READ_ONLY:
            #TODO wrong exception raised here
            raise waveRpc.NotParticipantException("Wave permissions do not permit reply")
        
        wavelet.add_proxying_participant(proxy_for)
        self.__InsertBlipIntoWavelet(wavelet, proxy_for)
        self.__AlertEmailParticipants(wavelet, self.name + "(via Mr-Ray Public)")
        waveRpc.retry_submit(config.HTTP_IMPORTANT_RETRY, mrray, wavelet)

        #Re-fetch the new (updated) wavelet
        new_wavelet_data = waveRpc.retry_fetch_wavelet_json(config.HTTP_IMPORTANT_RETRY,
                                                            mrray,
                                                            self.wave_id,
                                                            self.wavelet_id)
        
        #Write the response
        wavelet_json = utils.construct_wavelet_json_for_http_response(  new_wavelet_data,
                                                                        self.wave_id,
                                                                        self.wavelet_id,
                                                                        self.email)
        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(wavelet_json)
        self.response.set_status(201)
Exemplo n.º 3
0
    def _UserRefresh(self):
        '''
        Fetches and returns the wavelet json for a user
        '''
        new_wavelet_data = waveRpc.retry_fetch_wavelet_json(config.HTTP_LOSSY_RETRY,
                                                            mrray,
                                                            self.wave_id,
                                                            self.wavelet_id)

        wavelet_json = utils.construct_wavelet_json_for_http_response(  new_wavelet_data,
                                                                        self.wave_id,
                                                                        self.wavelet_id,
                                                                        self.email)
        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(wavelet_json)
Exemplo n.º 4
0
    def _UserReplies(self):
        '''
        Sends a reply to wave from the user along with other tasks such as
        marking the wave read etc.
        '''
        #Modify requirements if the wave is public
        if sessionTools.isPublic(sessionTools.get( self.wave_id, self.wavelet_id, self.email)):
            self._PublicReplies()
        else:
            #Fetch the wavelet and do some house-keeping
            wavelet = waveRpc.retry_fetch_wavelet(  config.HTTP_IMPORTANT_RETRY,
                                                    mrray,
                                                    self.wave_id,
                                                    self.wavelet_id)
        
            try:
                wavelet.robot_address = config.ROBOT_EMAIL
            except:
                pass#The wavelet already has the robot address
            proxy_for = utils.getProxyForFromEmail(self.email)
            
            if wavelet.participants.get_role(config.ROBOT_IDENT + "+" + proxy_for + "@" + config.ROBOT_DOMAIN) == wavelet.participants.ROLE_READ_ONLY:
                #TODO wrong exception raised here
                raise waveRpc.NotParticipantException("Wave permissions do not permit reply")
            if wavelet.participants.get_role(config.ROBOT_EMAIL) == wavelet.participants.ROLE_READ_ONLY:
                #TODO wrong exception raised here
                raise waveRpc.NotParticipantException("Wave permissions do not permit reply")
            
            wavelet.add_proxying_participant(proxy_for)
            self.__InsertBlipIntoWavelet(wavelet, proxy_for)
            self.__AlertEmailParticipants(wavelet, self.email+"(via Mr-Ray)")
            waveRpc.retry_submit(config.HTTP_IMPORTANT_RETRY, mrray, wavelet)

            #Re-fetch the new (updated) wavelet
            new_wavelet_data = waveRpc.retry_fetch_wavelet_json(config.HTTP_IMPORTANT_RETRY,
                                                                mrray,
                                                                self.wave_id,
                                                                self.wavelet_id)
            self.__MarkNewBlipRead(new_wavelet_data)
        
            #Write the response
            wavelet_json = utils.construct_wavelet_json_for_http_response(  new_wavelet_data,
                                                                            self.wave_id,
                                                                            self.wavelet_id,
                                                                            self.email)
            self.response.headers['Content-Type'] = 'application/json'
            self.response.out.write(wavelet_json)
            self.response.set_status(201)