isSenderTrusted incorrect
Expected behavior
Tell us what should happen
Once I select 'Always show images from
Actual behavior
Tell us what happens instead the apps/mail/api/messages/*/body call is returning isSenderTrusted = false. If I select 'always show images' again, it displays the images but gets a duplicate entry error on the server on index mail_trusted_sender_uniq.
Mail app
Mail app version: (see apps admin page, e.g. 0.5.3) 1.9.5 Mailserver or service: (e.g. Outlook, Yahoo, Gmail, Exchange,...) gmail & smtp
Server configuration
Operating system: (e.g. Debian 8) Ubuntu 20 Web server: (e.g. Apache, Nginx,...) Apache2 Database: (e.g. MariaDB, SQLite or PostgreSQL) MariaDB PHP version: (e.g. 7.0) 8.0 Nextcloud Version: (see admin page, e.g. 13.0.2) 21.0.2
Client configuration
Browser: (e.g. Firefox 48) Chrome 91.0.4472.77 Operating system: (e.g. Arch Linux) Ubuntu 20
... Here's the error log entry:
{"reqId":"hvjirBJWk1G0Hkf4dSa8","level":3,"time":"2021-06-08T15:22:32+00:00","remoteAddr":"64.201.232.47","user":"rmiller","app":"mail","method":"PUT","url":"/index.php/apps/mail/api/trustedsenders/ronjonsurfshop.info?type=domain","message":{"Exception":"Doctrine\DBAL\Exception\UniqueConstraintViolationException","Message":"An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'ronjonsurfshop.info-rmiller' for key 'mail_trusted_sender_uniq'","Code":1062,"Trace":[{"file":"/home/rmiller/Software/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1728,"function":"convert","class":"Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter","type":"->"},{"file":"/home/rmiller/Software/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1667,"function":"handleDriverException","class":"Doctrine\DBAL\Connection","type":"->"},{"file":"/home/rmiller/Software/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1146,"function":"convertExceptionDuringQuery","class":"Doctrine\DBAL\Connection","type":"->"},{"file":"/home/rmiller/Software/nextcloud/lib/private/DB/Connection.php","line":257,"function":"executeStatement","class":"Doctrine\DBAL\Connection","type":"->"},{"file":"/home/rmiller/Software/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":213,"function":"executeStatement","class":"OC\DB\Connection","type":"->"},{"file":"/home/rmiller/Software/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":287,"function":"execute","class":"Doctrine\DBAL\Query\QueryBuilder","type":"->"},{"file":"/home/rmiller/Software/nextcloud/apps/mail/lib/Db/TrustedSenderMapper.php","line":73,"function":"execute","class":"OC\DB\QueryBuilder\QueryBuilder","type":"->"},{"file":"/home/rmiller/Software/nextcloud/apps/mail/lib/Service/TrustedSenderService.php","line":55,"function":"create","class":"OCA\Mail\Db\TrustedSenderMapper","type":"->"},{"file":"/home/rmiller/Software/nextcloud/apps/mail/lib/Controller/TrustedSendersController.php","line":62,"function":"trust","class":"OCA\Mail\Service\TrustedSenderService","type":"->"},{"file":"/home/rmiller/Software/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":218,"function":"setTrusted","class":"OCA\Mail\Controller\TrustedSendersController","type":"->"},{"file":"/home/rmiller/Software/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":127,"function":"executeController","class":"OC\AppFramework\Http\Dispatcher","type":"->"},{"file":"/home/rmiller/Software/nextcloud/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\AppFramework\Http\Dispatcher","type":"->"},{"file":"/home/rmiller/Software/nextcloud/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\AppFramework\App","type":"::"},{"file":"/home/rmiller/Software/nextcloud/lib/base.php","line":993,"function":"match","class":"OC\Route\Router","type":"->"},{"file":"/home/rmiller/Software/nextcloud/index.php","line":37,"function":"handleRequest","class":"OC","type":"::"}],"File":"/home/rmiller/Software/nextcloud/3rdparty/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php","Line":60,"Previous":{"Exception":"Doctrine\DBAL\Driver\PDO\Exception","Message":"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'ronjonsurfshop.info-rmiller' for key 'mail_trusted_sender_uniq'","Code":1062,"Trace":[{"file":"/home/rmiller/Software/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php","line":84,"function":"new","class":"Doctrine\DBAL\Driver\PDO\Exception","type":"::"},{"file":"/home/rmiller/Software/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1136,"function":"execute","class":"Doctrine\DBAL\Driver\PDO\Statement","type":"->"},{"file":"/home/rmiller/Software/nextcloud/lib/private/DB/Connection.php","line":257,"function":"executeStatement","class":"Doctrine\DBAL\Connection","type":"->"},{"file":"/home/rmiller/Software/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":213,"function":"executeStatement","class":"OC\DB\Connection","type":"->"},{"file":"/home/rmiller/Software/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":287,"function":"execute","class":"Doctrine\DBAL\Query\QueryBuilder","type":"->"},{"file":"/home/rmiller/Software/nextcloud/apps/mail/lib/Db/TrustedSenderMapper.php","line":73,"function":"execute","class":"OC\DB\QueryBuilder\QueryBuilder","type":"->"},{"file":"/home/rmiller/Software/nextcloud/apps/mail/lib/Service/TrustedSenderService.php","line":55,"function":"create","class":"OCA\Mail\Db\TrustedSenderMapper","type":"->"},{"file":"/home/rmiller/Software/nextcloud/apps/mail/lib/Controller/TrustedSendersController.php","line":62,"function":"trust","class":"OCA\Mail\Service\TrustedSenderService","type":"->"},{"file":"/home/rmiller/Software/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":218,"function":"setTrusted","class":"OCA\Mail\Controller\TrustedSendersController","type":"->"},{"file":"/home/rmiller/Software/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":127,"function":"executeController","class":"OC\AppFramework\Http\Dispatcher","type":"->"},{"file":"/home/rmiller/Software/nextcloud/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\AppFramework\Http\Dispatcher","type":"->"},{"file":"/home/rmiller/Software/nextcloud/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\AppFramework\App","type":"::"},{"file":"/home/rmiller/Software/nextcloud/lib/base.php","line":993,"function":"match","class":"OC\Route\Router","type":"->"},{"file":"/home/rmiller/Software/nextcloud/index.php","line":37,"function":"handleRequest","class":"OC","type":"::"}],"File":"/home/rmiller/Software/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Exception.php","Line":26,"Previous":{"Exception":"PDOException","Message":"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'ronjonsurfshop.info-rmiller' for key 'mail_trusted_sender_uniq'","Code":"23000","Trace":[{"file":"/home/rmiller/Software/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php","line":82,"function":"execute","class":"PDOStatement","type":"->"},{"file":"/home/rmiller/Software/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1136,"function":"execute","class":"Doctrine\DBAL\Driver\PDO\Statement","type":"->"},{"file":"/home/rmiller/Software/nextcloud/lib/private/DB/Connection.php","line":257,"function":"executeStatement","class":"Doctrine\DBAL\Connection","type":"->"},{"file":"/home/rmiller/Software/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":213,"function":"executeStatement","class":"OC\DB\Connection","type":"->"},{"file":"/home/rmiller/Software/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":287,"function":"execute","class":"Doctrine\DBAL\Query\QueryBuilder","type":"->"},{"file":"/home/rmiller/Software/nextcloud/apps/mail/lib/Db/TrustedSenderMapper.php","line":73,"function":"execute","class":"OC\DB\QueryBuilder\QueryBuilder","type":"->"},{"file":"/home/rmiller/Software/nextcloud/apps/mail/lib/Service/TrustedSenderService.php","line":55,"function":"create","class":"OCA\Mail\Db\TrustedSenderMapper","type":"->"},{"file":"/home/rmiller/Software/nextcloud/apps/mail/lib/Controller/TrustedSendersController.php","line":62,"function":"trust","class":"OCA\Mail\Service\TrustedSenderService","type":"->"},{"file":"/home/rmiller/Software/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":218,"function":"setTrusted","class":"OCA\Mail\Controller\TrustedSendersController","type":"->"},{"file":"/home/rmiller/Software/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":127,"function":"executeController","class":"OC\AppFramework\Http\Dispatcher","type":"->"},{"file":"/home/rmiller/Software/nextcloud/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\AppFramework\Http\Dispatcher","type":"->"},{"file":"/home/rmiller/Software/nextcloud/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\AppFramework\App","type":"::"},{"file":"/home/rmiller/Software/nextcloud/lib/base.php","line":993,"function":"match","class":"OC\Route\Router","type":"->"},{"file":"/home/rmiller/Software/nextcloud/index.php","line":37,"function":"handleRequest","class":"OC","type":"::"}],"File":"/home/rmiller/Software/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php","Line":82}},"CustomMessage":"An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'ronjonsurfshop.info-rmiller' for key 'mail_trusted_sender_uniq'"},"userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36","version":"21.0.2.1"}
Are you a php dev by any chance? It would be interesting to know what the logic at https://github.com/nextcloud/mail/blob/9163684bfbff9f930e0ba76c601b84475b40ddd2/lib/Controller/MessagesController.php#L275-L289 does.
Alternatively could you share the raw sender info from the email sources?
It looks something like Sender: [email protected]
I did a little more investigation yesterday and it looks like isSenderTrusted doesn't get called again. The issue only happens when I accept a sender as trusted and then go back to that message. If I clear the browser cache and reload the page then the trusted sender sticks. So it seems like a browser / server sync issue. Thanks,Bob On Wed, 2021-06-09 at 04:14 -0700, Christoph Wurst wrote:
Are you a php dev by any chance? It would be interesting to know what the logic at https://github.com/nextcloud/mail/blob/9163684bfbff9f930e0ba76c601b84475b40ddd2/lib/Controller/MessagesController.php#L275-L289 does.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Right, we cache the response for the message body. Guess we have to split the mutable and the immutable parts of this response and only cache the latter.
Any update on this issue? It is annoying to clear browser cache each time a trusted sender is added.
Is there anything new? It's quite annoying to have to clean the browser cache every time.