Example #1
0
    def __AlertEmailParticipants(self, wavelet, who_changed):
        '''
        Send an email out to any other proxy-for participants in the wave
        @param wavelet: the wavelet that the proxy-for participants are
                        subscribed to
        @param who_changed: the friendly name of who changed the wave
        '''
        #Alert other e-mail participants that a new blip has been posted
        sessions = sessionTools.fetch(wavelet.wave_id, wavelet.wavelet_id)

        for userSession in sessions:
            if not userSession.email == self.email and not sessionTools.isPublic(userSession):
                userSettings = settingsTools.get(userSession)
                if not userSettings.unseen_changes and not userSettings.rw_permission == pt_raw.RW['DELETED']:
                    deferred.defer(
                        emailInterface.sendNotificationEmail,
                        sessionCreation.regenerateUser( wavelet.wave_id,
                                                        wavelet.wavelet_id,
                                                        userSession.email   ),
                        wavelet.wave_id,
                        wavelet.wavelet_id,
                        userSession.email,
                        self.email,
                        wavelet.title,
                        who_modified_display=who_changed)
                    
                    settingsTools.markUnseenChanges(session=userSession)
Example #2
0
def updateUsers(event, wavelet):
    '''
    Loops through the users in the wave and sends email if these are the first
    new changes
    @param event: the event that triggered
    @param wavelet: the wavelet where the event triggered
    '''
    blip_id = None
    if event.blip:
        blip_id = event.blip.blip_id
    sessions = sessionTools.fetch(wavelet.wave_id, wavelet.wavelet_id)
    for userSession in sessions:
        if sessionTools.isPublic(userSession):
            continue
        #Dispatch e-mail if these are new changes
        userSettings = settingsTools.get(userSession)
        if userSettings and not userSettings.unseen_changes and not userSettings.rw_permission == pt_raw.RW['DELETED']:
            deferred.defer( emailInterface.sendNotificationEmail,
                            sessionCreation.regenerateUser( wavelet.wave_id,
                                                            wavelet.wavelet_id,
                                                            userSession.email   ),
                            wavelet.wave_id,
                            wavelet.wavelet_id,
                            userSession.email,
                            event.modified_by,
                            wavelet.title)
            settingsTools.markUnseenChanges(session=userSession)

        #Update each users blip unread status
        settingsTools.blipChanges(blip_id, session=userSession)
def constructInitialState(wavelet):
    '''
    Constructs the initial gadget state. This is used purely for migration from
    the v1 gadget to v2 gadget. So it returns a list of email users in the 
    correct format for the gadget
    @param wavelet: the wavelet where the gadget will live
    @return a dictionary containing the key values of the initial state
    '''
    sessions = sessionTools.fetch(wavelet.wave_id, wavelet.wavelet_id)
    #Form the email list
    email_list = []
    public_session = None
    for session in sessions:
        if sessionTools.isPublic(session):
            public_session = session
        else:
            email_list.append(session.email)
            
    #Form public settings
    public = {}
    isPublic = False
    isReadOnly = True
    
    try:
        public_settings = settingsTools.get(public_session)
        rw_permission = public_settings.rw_permission
        
        if rw_permission == pt_raw.RW['READ']:
            isPublic = True
            isReadOnly = True
        elif rw_permission == pt_raw.RW['READ_WRITE']:
            isPublic = True
            isReadOnly = False
    except:
        #Just means public settings could not be found. Defaults will be used
        pass
    public.update({'isPublic' : isPublic, 'isReadOnly' : isReadOnly});
    
    output = base64.b64encode(simplejson.dumps({'emailParticipants' : email_list,
                                                'public'            : public}))
    return {'state' : output, 'participantDetailsState' : 'fetch'}