Exemple #1
0
 def load_messages(self):
     thread_keys = self.user.get_threads()
     for thread_key in thread_keys:
         t = Thread(redis=self.redis, user=self.user)
         try:
             t.load(key=thread_key)
             t.get_unread_count()
             self.threads.append(t)
         except ThreadError:
             t.delete(recipient=self.user)
Exemple #2
0
def del_thread(thread_id):
    try:
        g.user.username
        if str(thread_id) not in g.user.get_threads():
            abort(401)
    except AttributeError:
        abort(401)
    if request.method == "POST":
        t = Thread(redis=g.r, user=g.user)
        t.load(thread_id)
        t.delete()
        flash(u"Deleted thread.", "success")
        return redirect(url_for("inbox"))
    else:
        return render_template(
            "confirm.html",
            _message="Are you sure you wish to DELETE this thread?",
            _ok=url_for("del_thread", thread_id=thread_id),
            _cancel=url_for("inbox"),
        )