def filter_subscriptions(self, event, subscriptions): action = '%s_VIEW' % event.realm.upper() for subscription in subscriptions: if event.realm in self.exception_realms: yield subscription continue sid, auth = subscription[1:3] # PermissionCache already takes care of sid = None if not auth: sid = 'anonymous' perm = PermissionCache(self.env, sid) resource_id = get_target_id(event.target) self.log.debug( 'Checking *_VIEW permission on event for resource %s:%s' % (event.realm, resource_id) ) if perm.has_permission(action) and action in perm(event.realm, resource_id): yield subscription else: self.log.debug( "Filtering %s because of %s rule" % (sid, self.__class__.__name__) )
def matches(self, event): klass = self.__class__.__name__ attrs = SubscriptionAttribute.find_by_class_realm_and_target( self.env, klass, event.realm, get_target_id(event.target)) sids = set(map(lambda x: (x['sid'], x['authenticated']), attrs)) for i in Subscription.find_by_sids_and_class(self.env, sids, klass): yield i.subscription_tuple()
def matches(self, event): klass = self.__class__.__name__ attrs = SubscriptionAttribute.\ find_by_class_realm_and_target(self.env, klass, event.realm, get_target_id(event.target)) sids = set(map(lambda x: (x['sid'], x['authenticated']), attrs)) for i in Subscription.find_by_sids_and_class(self.env, sids, klass): yield i.subscription_tuple()
def uid_encode(projurl, realm, target): """ Unique identifier used to track resources in relation to emails. Returns a base32 encode UID string. projurl included to avoid Message-ID collisions. Returns a base32 encode UID string. Set project_url in trac.ini for proper results. """ uid = ','.join((projurl, realm, get_target_id(target))) return b32encode(uid.encode('utf8'))
def filter_subscriptions(self, event, subscriptions): action = '%s_VIEW' % event.realm.upper() for subscription in subscriptions: if event.realm in self.exception_realms: yield subscription continue sid, auth = subscription[1:3] # PermissionCache already takes care of sid = None if not auth: sid = 'anonymous' perm = PermissionCache(self.env, sid) resource_id = get_target_id(event.target) self.log.debug("Checking *_VIEW permission on event for resource " "%s:%s", event.realm, resource_id) if action in perm and action in perm(event.realm, resource_id): yield subscription else: self.log.debug("Filtering %s because of %s rule", sid, self.__class__.__name__)
def wiki_page_deleted(self, page): klass = self.__class__.__name__ SubscriptionAttribute.delete_by_class_realm_and_target( self.env, klass, 'wiki', get_target_id(page))
def ticket_deleted(self, ticket): klass = self.__class__.__name__ SubscriptionAttribute.delete_by_class_realm_and_target( self.env, klass, 'ticket', get_target_id(ticket))
def wiki_page_renamed(self, page, old_name): class_ = self.__class__.__name__ target = get_target_id(page) SubscriptionAttribute\ .change_target(self.env, class_, 'wiki', old_name, target)
def wiki_page_deleted(self, page): klass = self.__class__.__name__ SubscriptionAttribute.\ delete_by_class_realm_and_target(self.env, klass, 'wiki', get_target_id(page))