Skip to content
This repository has been archived by the owner on Nov 8, 2018. It is now read-only.

Address collector #1276

Merged
merged 11 commits into from
Feb 16, 2016
Merged

Address collector #1276

merged 11 commits into from
Feb 16, 2016

Conversation

ChristophWurst
Copy link
Contributor

Adds all addresses of sent mails (to, cc, bcc) to a db table, so that those addresses can then be used for auto-completion.

This is a very simple implementation, it only saves the bare email address. Adding more information (label, recipient name) can be done in another PR as that might need some advanced update-logic.

We should also think about a way for users to delete one of those entries…

TODO:

  • fix sql matching
  • update/add unit tests

implements #879
fixes #1254

<index>
<name>mail_collected_addr_email_index</name>
<field>
<name>user_id</name>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be 'email'

}

public function exists($userId, $email) {
$sql = 'SELECT * FROM *PREFIX*mail_collected_addresses WHERE `user_id` = ? AND `email` = ?';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • use ILIKE here too

@ChristophWurst
Copy link
Contributor Author

Dang it. Some test cases still fail

@ChristophWurst
Copy link
Contributor Author

This is weird:

exception 'OCP\AppFramework\QueryException' with message 'Could not resolve OCP\IDBConnection! Class can not be instantiated' in /home/travis/build/owncloud/core/lib/private/appframework/utility/simplecontainer.php:80

Stack trace:

#0 /home/travis/build/owncloud/core/lib/private/appframework/utility/simplecontainer.php(98): OC\AppFramework\Utility\SimpleContainer->resolve('OCP\\IDBConnecti...')

#1 /home/travis/build/owncloud/core/lib/private/appframework/utility/simplecontainer.php(59): OC\AppFramework\Utility\SimpleContainer->query('OCP\\IDBConnecti...')

#2 /home/travis/build/owncloud/core/lib/private/appframework/utility/simplecontainer.php(78): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))

#3 /home/travis/build/owncloud/core/lib/private/appframework/utility/simplecontainer.php(98): OC\AppFramework\Utility\SimpleContainer->resolve('OCA\\Mail\\Db\\Col...')

#4 /home/travis/build/owncloud/core/lib/private/appframework/utility/simplecontainer.php(59): OC\AppFramework\Utility\SimpleContainer->query('OCA\\Mail\\Db\\Col...')

#5 /home/travis/build/owncloud/core/lib/private/appframework/utility/simplecontainer.php(78): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))

#6 /home/travis/build/owncloud/core/lib/private/appframework/utility/simplecontainer.php(98): OC\AppFramework\Utility\SimpleContainer->resolve('OCA\\Mail\\Servic...')

#7 /home/travis/build/owncloud/core/apps/mail/lib/account.php(90): OC\AppFramework\Utility\SimpleContainer->query('OCA\\Mail\\Servic...')

#8 /home/travis/build/owncloud/core/apps/mail/tests/imap/abstracttest.php(71): OCA\Mail\Account->__construct(Object(OCA\Mail\Db\MailAccount))

#9 [internal function]: OCA\Mail\Tests\Imap\AbstractTest::setUpBeforeClass()

#10 phar:///home/travis/.phpenv/versions/5.4.37/bin/phpunit/phpunit/Framework/TestSuite.php(673): call_user_func(Array)

#11 phar:///home/travis/.phpenv/versions/5.4.37/bin/phpunit/phpunit/Framework/TestSuite.php(716): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))

#12 phar:///home/travis/.phpenv/versions/5.4.37/bin/phpunit/phpunit/TextUI/TestRunner.php(398): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))

#13 phar:///home/travis/.phpenv/versions/5.4.37/bin/phpunit/phpunit/TextUI/Command.php(152): PHPUnit_TextUI_TestRunner->doRun(Object(PHPUnit_Framework_TestSuite), Array)

#14 phar:///home/travis/.phpenv/versions/5.4.37/bin/phpunit/phpunit/TextUI/Command.php(104): PHPUnit_TextUI_Command->run(Array, true)

#15 /home/travis/.phpenv/versions/5.4.37/bin/phpunit(722): PHPUnit_TextUI_Command::main()

#16 {main}

It's only reproducible on php5.4 and I have no idea what might cause that exception. @DeepDiver1975 is there any difference between php5.4 and php5.6 in terms of owncloud dependency injection?

@Gomez
Copy link
Contributor

Gomez commented Feb 15, 2016

I dropping 5.4 a option for us (i would say yes)? The news app dropped it and 5.4 is EOL.

@@ -83,6 +87,7 @@ public function __construct(MailAccount $account) {
$this->crypto = \OC::$server->getCrypto();
$this->config = \OC::$server->getConfig();
$this->memcacheFactory = \OC::$server->getMemcacheFactory();
$this->addressCollector = \OC::$server->query('OCA\Mail\Service\AutoCompletion\AddressCollector');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChristophWurst this is the reason why this is falling apart.

In previous versions of owncloud you cannot query the server container for services which are located in an app ... let me fix that ...

@ChristophWurst
Copy link
Contributor Author

@DeepDiver1975 thanks for fixing

@owncloud/mail @ErikPel @jospoortvliet review please ;-)

@jancborchardt
Copy link
Contributor

Nice @ChristophWurst, awesome on that functionality! :)

Do Gmail and others also collect addresses of people you receive emails from? (As well as people in cc there.)

And of course as you mention – saving the name would be cool, but for a follow-up PR.

@enoch85
Copy link
Contributor

enoch85 commented Feb 16, 2016

I know this is for another PR, but I'd love this to be synced with my CardDav as well so that when I write on mobile, the address is there as well.

@ChristophWurst
Copy link
Contributor Author

I dropping 5.4 a option for us (i would say yes)? The news app dropped it and 5.4 is EOL.

If we want to become an "official" app we have to support all platforms supported by core, see https://doc.owncloud.org/server/8.2/developer_manual/app/publishing.html#official

@Gomez
Copy link
Contributor

Gomez commented Feb 16, 2016

@ChristophWurst Cool! Checked & Tested

@enoch85 Would you open a issue? This PR will be closed.

Gomez added a commit that referenced this pull request Feb 16, 2016
@Gomez Gomez merged commit fba6a34 into master Feb 16, 2016
@Gomez Gomez deleted the address-collector branch February 16, 2016 14:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants