27 lines
624 B
Python
27 lines
624 B
Python
import logging
|
|
|
|
import database
|
|
|
|
def user_in_thread(user_id: int, thread_id: int) -> bool:
|
|
forums = database.get_user_forums(user_id)
|
|
|
|
if not forums:
|
|
return False
|
|
|
|
for forum in forums:
|
|
if not forum.id:
|
|
logging.error(f'Forum {forum.name} has no id but user is in it?')
|
|
continue
|
|
|
|
threads = database.get_forum_threads(forum.id)
|
|
|
|
for thread in threads:
|
|
if not thread.id:
|
|
logging.error(f'Thread {thread.name} has no id?')
|
|
continue
|
|
|
|
if thread.id == thread_id:
|
|
return True
|
|
|
|
return False
|