'Process incoming mobile navigation events.
For forum-thread-viewed events, change their names to
edx.forum.thread.viewed and manipulate their data to conform with
edx.forum.thread.viewed event design.
Throw out other events.'

def process_event(self):

    context = self.get('context')
    if (not isinstance(context, dict)):
        raise EventEmissionExit()
    if (_get_string(context, 'label', del_if_bad=False) != FORUM_THREAD_VIEWED_EVENT_LABEL):
        raise EventEmissionExit()
    self['name'] = 'edx.forum.thread.viewed'
    self['event_type'] = self['name']
    if ('event' not in self):
        self['event'] = {}
        self.event = {}
    if ('context' in self.event):
        del self.event['context']
    course_id_string = (_get_string(context, 'course_id') if context else None)
    course_id = None
    if course_id_string:
        try:
            course_id = CourseLocator.from_string(course_id_string)
        except InvalidKeyError:
            pass
    thread_id = _get_string(self.event, 'thread_id')
    if thread_id:
        del self.event['thread_id']
        self.event['id'] = thread_id
    commentable_id = _get_string(self.event, 'topic_id')
    if commentable_id:
        del self.event['topic_id']
        self.event['commentable_id'] = commentable_id
    title = _get_string(self.event, 'action')
    if (title is not None):
        del self.event['action']
        add_truncated_title_to_event_data(self.event, title)
    author = _get_string(self.event, 'author')
    if (author is not None):
        del self.event['author']
        self.event['target_username'] = author
    username = _get_string(self, 'username')
    user = None
    if username:
        try:
            user = User.objects.get(username=username)
        except User.DoesNotExist:
            pass
    if (course_id and commentable_id and user):
        id_map = get_cached_discussion_id_map_by_course_id(course_id, [commentable_id], user)
        if (commentable_id in id_map):
            self.event['category_name'] = id_map[commentable_id]['title']
            self.event['category_id'] = commentable_id
    if (course_id and commentable_id and thread_id):
        url_kwargs = {'course_id': course_id_string, 'discussion_id': commentable_id, 'thread_id': thread_id}
        try:
            self.event['url'] = reverse('single_thread', kwargs=url_kwargs)
        except NoReverseMatch:
            pass
    if (course_id and user):
        self.event['user_forums_roles'] = [role.name for role in user.roles.filter(course_id=course_id)]
        self.event['user_course_roles'] = [role.role for role in user.courseaccessrole_set.filter(course_id=course_id)]
    if commentable_id:
        team = get_team(commentable_id)
        if team:
            self.event['team_id'] = team.team_id
