def OnParticpantsChanged(event, wavelet): ''' Called when the waves participants change. This will request the gadget refetches the waves participant profiles ''' if not wavelet.robot_address == config.ROBOT_EMAIL: logging.info('Proxy_robot- request ignored') return if wavelet.participants.get_role(config.ROBOT_EMAIL) == wavelet.participants.ROLE_READ_ONLY: logging.info("Mr-Ray is read only- request ignored") return logging.info("OnParticipantsChanged") root_blip = waveletTools.getRootBlip(wavelet) if root_blip: add_participants_gadget_v2 = root_blip.first(element.Gadget, url=config.ADD_PARTICIPANTS_GADGET_URL2) if(add_participants_gadget_v2): gadgetHandler.requestParticipantProfilesUpdate(add_participants_gadget_v2)
def OnSelfAdded(event, wavelet): ''' Called when a robot is added to wave. Adds the add email participants gadget to the wave @param event: the event that triggered @param wavelet: the wavelet where the event triggered ''' if not wavelet.robot_address == config.ROBOT_EMAIL: logging.info('Proxy_robot- request ignored') return logging.info('OnSelfAdded') #If there is no title add one if len(wavelet.title) == 0: wavelet.title = "(Untitled)" #Add the gadget root_blip = waveletTools.getRootBlip(wavelet) if root_blip: participants_gadget = element.Gadget(config.ADD_PARTICIPANTS_GADGET_URL2, gadgetHandler.constructInitialState(wavelet)) participants_gadget.waveid = wavelet.wave_id root_blip.at(len(wavelet.title)).insert_after(participants_gadget)