reuse the url_hash instead of calculating a new hash for the address book
This commit is contained in:
parent
62d7885c3b
commit
eccd7cf654
|
@ -27,8 +27,7 @@
|
|||
<type>text</type>
|
||||
<default></default>
|
||||
<notnull>true</notnull>
|
||||
<length>32</length>
|
||||
<comments>md5 hash of the url without the protocol</comments>
|
||||
<comments>sha1 hash of the url without the protocol</comments>
|
||||
</field>
|
||||
<field>
|
||||
<name>token</name>
|
||||
|
|
|
@ -112,7 +112,7 @@ class DbHandler {
|
|||
*/
|
||||
public function getAllServer() {
|
||||
$query = $this->connection->getQueryBuilder();
|
||||
$query->select(['url', 'id', 'status', 'shared_secret', 'sync_token'])->from($this->dbTable);
|
||||
$query->select(['url', 'url_hash', 'id', 'status', 'shared_secret', 'sync_token'])->from($this->dbTable);
|
||||
$result = $query->execute()->fetchAll();
|
||||
return $result;
|
||||
}
|
||||
|
@ -252,11 +252,11 @@ class DbHandler {
|
|||
*/
|
||||
protected function hash($url) {
|
||||
$normalized = $this->normalizeUrl($url);
|
||||
return md5($normalized);
|
||||
return sha1($normalized);
|
||||
}
|
||||
|
||||
/**
|
||||
* normalize URL, used to create the md5 hash
|
||||
* normalize URL, used to create the sha1 hash
|
||||
*
|
||||
* @param string $url
|
||||
* @return string
|
||||
|
|
|
@ -40,7 +40,7 @@ class SyncFederationAddressBooks {
|
|||
if (is_null($sharedSecret)) {
|
||||
continue;
|
||||
}
|
||||
$targetBookId = sha1($url);
|
||||
$targetBookId = $trustedServer['url_hash'];
|
||||
$targetPrincipal = "principals/system/system";
|
||||
$targetBookProperties = [
|
||||
'{DAV:}displayname' => $url
|
||||
|
|
|
@ -89,9 +89,9 @@ class DbHandlerTest extends TestCase {
|
|||
|
||||
public function dataTestAddServer() {
|
||||
return [
|
||||
['http://owncloud.org', 'http://owncloud.org', md5('owncloud.org')],
|
||||
['https://owncloud.org', 'https://owncloud.org', md5('owncloud.org')],
|
||||
['http://owncloud.org/', 'http://owncloud.org', md5('owncloud.org')],
|
||||
['http://owncloud.org', 'http://owncloud.org', sha1('owncloud.org')],
|
||||
['https://owncloud.org', 'https://owncloud.org', sha1('owncloud.org')],
|
||||
['http://owncloud.org/', 'http://owncloud.org', sha1('owncloud.org')],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -233,10 +233,10 @@ class DbHandlerTest extends TestCase {
|
|||
|
||||
public function dataTestHash() {
|
||||
return [
|
||||
['server1', md5('server1')],
|
||||
['http://server1', md5('server1')],
|
||||
['https://server1', md5('server1')],
|
||||
['http://server1/', md5('server1')],
|
||||
['server1', sha1('server1')],
|
||||
['http://server1', sha1('server1')],
|
||||
['https://server1', sha1('server1')],
|
||||
['http://server1/', sha1('server1')],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ class SyncFederationAddressbooksTest extends \Test\TestCase {
|
|||
willReturn([
|
||||
[
|
||||
'url' => 'https://cloud.drop.box',
|
||||
'url_hash' => 'sha1',
|
||||
'shared_secret' => 'iloveowncloud',
|
||||
'sync_token' => '0'
|
||||
]
|
||||
|
@ -47,6 +48,7 @@ class SyncFederationAddressbooksTest extends \Test\TestCase {
|
|||
willReturn([
|
||||
[
|
||||
'url' => 'https://cloud.drop.box',
|
||||
'url_hash' => 'sha1',
|
||||
'shared_secret' => 'iloveowncloud',
|
||||
'sync_token' => '0'
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue