DavideGalilei / markinim

Markinim Telegram bot source code
MIT License
79 stars 16 forks source link

SQLite trigger to automatically consent all new users. #9

Open iwalfy opened 3 months ago

iwalfy commented 3 months ago
CREATE TRIGGER `gdpr_auto_consent`
AFTER INSERT ON `users`
BEGIN
  UPDATE `users` SET `consented` = 1 WHERE `userId` = NEW.userId;
END;
iwalfy commented 3 months ago

Probably you should make it possible via config option.

DavideGalilei commented 3 months ago

A trigger is not necessary, it is already possible to change this line: https://github.com/DavideGalilei/markinim/blob/5bc29e71ee1ee7da3f144420b77f9034c0a3663d/src/markinim.nim#L1071 into this line:

      let user = conn.getOrInsert(database.User(userId: msgUser.id, consented: true))

I might add a default consent value in the .env in the next update, with something like:

      let user = conn.getOrInsert(database.User(userId: msgUser.id, consented: not CONSENT_REQUIRED))