def apply_filter_rule(self, _filter, query='in:inbox', way='in'):
        """
        :param: _filter _filter a zobjects.FilterRule or the filter name
        :param: query on what will the filter be applied
        :param: way string discribing if filter is for 'in' or 'out' messages
        :returns: list of impacted message's ids
        """
        if isinstance(_filter, zobjects.FilterRule):
            _filter = _filter.name

        content = {
            'filterRules': {
                'filterRule': {'name': _filter}
                },
            'query': {'_content': query}
        }
        if way == 'in':
            ids = self.request('ApplyFilterRules', content)
        elif way == 'out':
            ids = self.request('ApplyOutgoingFilterRules', content)

        if ids:
            return [int(m) for m in ids['m']['ids'].split(',')]
        else:
            return []