topic_comment_notice.py 1.1 KB

12345678910111213141516171819202122232425262728
  1. from .tool.func import *
  2. async def topic_comment_notice(topic_num = 1, num = 1):
  3. with get_db_connect() as conn:
  4. curs = conn.cursor()
  5. topic_num = str(topic_num)
  6. num = str(num)
  7. if await acl_check(tool = 'toron_auth', memo = 'notice (code ' + topic_num + '#' + num + ')') == 1:
  8. return await re_error(conn, 3)
  9. curs.execute(db_change("select code from topic where code = ? and id = ?"), [topic_num, num])
  10. if curs.fetchall():
  11. curs.execute(db_change("select top from topic where code = ? and id = ?"), [topic_num, num])
  12. top_data = curs.fetchall()
  13. if top_data:
  14. if top_data[0][0] == 'O':
  15. curs.execute(db_change("update topic set top = '' where code = ? and id = ?"), [topic_num, num])
  16. else:
  17. curs.execute(db_change("update topic set top = 'O' where code = ? and id = ?"), [topic_num, num])
  18. do_reload_recent_thread(conn,
  19. topic_num,
  20. get_time()
  21. )
  22. return redirect(conn, '/thread/' + topic_num + '#' + num)