Fixing local event delivery for calendar events based on the email address
This commit is contained in:
parent
d7eb17bdc0
commit
b10dcfc3b7
|
@ -196,6 +196,14 @@ class Principal implements BackendInterface {
|
|||
* @return string
|
||||
*/
|
||||
function findByUri($uri, $principalPrefix) {
|
||||
if (substr($uri, 0, 7) === 'mailto:') {
|
||||
$email = substr($uri, 7);
|
||||
$users = $this->userManager->getByEmail($email);
|
||||
if (count($users) === 1) {
|
||||
return $this->principalPrefix . '/' . $users[0]->getUID();
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,9 @@ class Server {
|
|||
|
||||
// acl
|
||||
$acl = new DavAclPlugin();
|
||||
$acl->principalCollectionSet = [
|
||||
'principals/users', 'principals/groups'
|
||||
];
|
||||
$acl->defaultUsernamePath = 'principals/users';
|
||||
$this->server->addPlugin($acl);
|
||||
|
||||
|
|
|
@ -255,4 +255,19 @@ class Principal extends TestCase {
|
|||
public function testSearchPrincipals() {
|
||||
$this->assertSame([], $this->connector->searchPrincipals('principals/users', []));
|
||||
}
|
||||
|
||||
public function testFindByUri() {
|
||||
$fooUser = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$fooUser
|
||||
->expects($this->exactly(1))
|
||||
->method('getUID')
|
||||
->will($this->returnValue('foo'));
|
||||
|
||||
$this->userManager->expects($this->once())->method('getByEmail')->willReturn([
|
||||
$fooUser
|
||||
]);
|
||||
$ret = $this->connector->findByUri('mailto:foo@bar.net', 'principals/users');
|
||||
$this->assertSame('principals/users/foo', $ret);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
namespace OC\User;
|
||||
|
||||
use OC\Hooks\PublicEmitter;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserBackend;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IConfig;
|
||||
|
@ -354,4 +355,17 @@ class Manager extends PublicEmitter implements IUserManager {
|
|||
} while (count($users) >= $limit);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
* @return IUser[]
|
||||
* @since 9.1.0
|
||||
*/
|
||||
public function getByEmail($email) {
|
||||
$userIds = $this->config->getUsersForUserValue('settings', 'email', $email);
|
||||
|
||||
return array_map(function($uid) {
|
||||
return $this->get($uid);
|
||||
}, $userIds);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,4 +142,11 @@ interface IUserManager {
|
|||
* @since 9.0.0
|
||||
*/
|
||||
public function callForAllUsers (\Closure $callback, $search = '');
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
* @return IUser[]
|
||||
* @since 9.1.0
|
||||
*/
|
||||
public function getByEmail($email);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue