Phuks-co / throat

Open Source link aggregator and discussion platform powering Phuks
https://phuks.co
MIT License
73 stars 32 forks source link

'allow_email_forwarded_notifications' now a configurable default #520

Closed why-not-try-calmer closed 1 year ago

why-not-try-calmer commented 1 year ago

https://github.com/Phuks-co/throat/pull/514#issuecomment-1445306414

why-not-try-calmer commented 1 year ago

peewee.InterfaceError: Query must be bound to a database in order to call "execute". is a bit exotic to me. Any hint @Polsaker?

update: nevermind issue found!

globalistas commented 1 year ago

@why-not-try-calmer maybe this helps? https://stackoverflow.com/questions/54504266/how-i-can-bound-query-to-the-database

why-not-try-calmer commented 1 year ago

maybe this helps?

Yes but no, I think it's related to my not overlooking some addition step to be done against the Peewee ORM. If Polsaker is not familiar either with this error I'll dig deeper.

globalistas commented 1 year ago

@why-not-try-calmer have you been able to figure something out?

globalistas commented 1 year ago

@why-not-try-calmer I'm checking the commit and the only thing coming to mind is, why are you using triple quotes here? image

Maybe that's what's causing the issue?

You may reference how I did this in my own repo, including the migration, which you might be missing as well:

https://github.com/globalistas/ceknito/commit/189f5b0e63f0c6ecd96f6b917cdc678d7badc9f4

globalistas commented 1 year ago

This PR might be missing one more fix, where config.site.allow_email_forwarded_notifications needs to be renamed to config.site.email_forwarded_notifications: https://github.com/Phuks-co/throat/blob/b54360086c6bd9716fddaa2d25fa395d2c90df3f/app/html/user/settings/preferences.html#L37

globalistas commented 1 year ago

I have tested this PR and found several issues:

1) PR is missing an updated example.config.yaml with the new config setting email_forwarded_notifications = False in it

2) When email_forwarded_notifications = True is specified in config.yaml, running poetry run ./throat.py migration apply gets stuck and then crashes with the following error:

INFO:migration:: :Starting migrations
DEBUG:app.sql_timing:: :(CREATE TABLE IF NOT EXISTS "migratehistory" ("id" SERIAL NOT NULL PRIMARY KEY, "name" VARCHAR(255) NOT NULL, "migrated_at" TIMESTAMP NOT NULL), []) (executed in 3 ms)
DEBUG:app.sql_timing:: :(SELECT "t1"."id", "t1"."name", "t1"."migrated_at" FROM "migratehistory" AS "t1" ORDER BY "t1"."id", []) (executed in 1 ms)
INFO:migration:: :There is nothing to migrate
Process Process-1:
Traceback (most recent call last):
  File "/home/app/.pyenv/versions/3.9.16/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/home/app/.pyenv/versions/3.9.16/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/app/ceknito/app/email_manager.py", line 98, in _produce
    Notification.select(
  File "/home/app/.pyenv/versions/3.9.16/envs/app/lib/python3.9/site-packages/peewee.py", line 1960, in inner
    raise InterfaceError('Query must be bound to a database in order '
peewee.InterfaceError: Query must be bound to a database in order to call "execute".
Process Process-3:
Traceback (most recent call last):
  File "/home/app/.pyenv/versions/3.9.16/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/home/app/.pyenv/versions/3.9.16/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/app/ceknito/app/email_manager.py", line 98, in _produce
    Notification.select(
  File "/home/app/.pyenv/versions/3.9.16/envs/app/lib/python3.9/site-packages/peewee.py", line 1960, in inner
    raise InterfaceError('Query must be bound to a database in order '
peewee.InterfaceError: Query must be bound to a database in order to call "execute".

This error does not occur when False is specified.

3) When email_forwarded_notifications = True is specified in config.yaml, site user sees the following error when trying to open user preferences html:

  File "user/settings/preferences.html", line 39, in main
AttributeError: 'EditUserForm' object has no attribute 'email_forwarded_notifications'