Replace any string value with a nullable network for the fallback to match the first social service
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
d7b540c9b5
commit
8ece6e064d
|
@ -46,7 +46,7 @@ class SocialUpdate extends \OC\BackgroundJob\QueuedJob {
|
|||
$offsetContact = $arguments['offsetContact'] ?? null;
|
||||
|
||||
// update contacts with first available social media profile
|
||||
$result = $this->social->updateAddressbooks('any', $userId, $offsetBook, $offsetContact);
|
||||
$result = $this->social->updateAddressbooks($userId, $offsetBook, $offsetContact);
|
||||
|
||||
if ($result->getStatus() === Http::STATUS_PARTIAL_CONTENT) {
|
||||
// not finished; schedule a follow-up
|
||||
|
|
|
@ -342,12 +342,12 @@ class SocialApiService {
|
|||
/**
|
||||
* Updates social profile data for all contacts of an addressbook
|
||||
*
|
||||
* @param {String} network the social network to use (fallback: take first match)
|
||||
* @param {String|null} network the social network to use (take first match if unset)
|
||||
* @param {String} userId the address book owner
|
||||
*
|
||||
* @returns {JSONResponse} JSONResponse with the list of changed and failed contacts
|
||||
*/
|
||||
public function updateAddressbooks(string $network, string $userId, string $offsetBook = null, string $offsetContact = null) : JSONResponse {
|
||||
public function updateAddressbooks(string $userId, string $offsetBook = null, string $offsetContact = null, string $network = null) : JSONResponse {
|
||||
|
||||
// double check!
|
||||
$syncAllowedByAdmin = $this->config->getAppValue($this->appName, 'allowSocialSync', 'yes');
|
||||
|
|
|
@ -237,7 +237,7 @@ class SocialApiServiceTest extends TestCase {
|
|||
'VERSION' => $contact['VERSION'],
|
||||
'PHOTO;ENCODING=b;TYPE=' . $imageType . ';VALUE=BINARY' => base64_encode($body)
|
||||
];
|
||||
|
||||
|
||||
$this->socialProvider
|
||||
->expects($this->once())->method("getSocialConnector")->with($network);
|
||||
$provider->expects($this->once())->method("supportsContact")->with($contact);
|
||||
|
@ -306,7 +306,7 @@ class SocialApiServiceTest extends TestCase {
|
|||
'VERSION' => $contact['VERSION'],
|
||||
'PHOTO' => "data:".$imageType.";base64," . base64_encode($body)
|
||||
];
|
||||
|
||||
|
||||
$this->socialProvider
|
||||
->expects($this->once())->method("getSocialConnector")->with($network);
|
||||
$provider->expects($this->once())->method("supportsContact")->with($contact);
|
||||
|
@ -442,7 +442,17 @@ class SocialApiServiceTest extends TestCase {
|
|||
|
||||
$this->setupAddressbooks();
|
||||
|
||||
$result = $this->service->updateAddressbooks('any', 'mrstest');
|
||||
if ($syncAllowedByAdmin === 'yes' && $bgSyncEnabledByUser === 'yes') {
|
||||
$this->socialProvider
|
||||
->expects($this->atLeastOnce())
|
||||
->method('getSocialConnectors');
|
||||
}
|
||||
|
||||
$this->socialProvider
|
||||
->expects($this->never())
|
||||
->method('getSocialConnector');
|
||||
|
||||
$result = $this->service->updateAddressbooks('mrstest');
|
||||
|
||||
$this->assertEquals($expected, $result->getStatus());
|
||||
|
||||
|
@ -474,7 +484,7 @@ class SocialApiServiceTest extends TestCase {
|
|||
|
||||
$this->setupAddressbooks();
|
||||
|
||||
$result = $this->service->updateAddressbooks('any', 'msstest');
|
||||
$result = $this->service->updateAddressbooks('msstest');
|
||||
|
||||
$this->assertEquals(Http::STATUS_PARTIAL_CONTENT, $result->getStatus());
|
||||
|
||||
|
@ -502,7 +512,7 @@ class SocialApiServiceTest extends TestCase {
|
|||
|
||||
$this->setupAddressbooks();
|
||||
|
||||
$result = $this->service->updateAddressbooks('any', 'mrstest', 'contacts2', '22222222-2222-2222-2222-222222222222');
|
||||
$result = $this->service->updateAddressbooks('mrstest', 'contacts2', '22222222-2222-2222-2222-222222222222');
|
||||
|
||||
$this->assertEquals($expected, $result->getStatus());
|
||||
|
||||
|
|
Loading…
Reference in New Issue