Skip to content

Commit 448576d

Browse files
authored
Merge pull request #5405 from nextcloud/chore/fix-little-typo
chore(SocialApi): Fix several small typos
2 parents a57b462 + 13c00b2 commit 448576d

3 files changed

Lines changed: 30 additions & 29 deletions

File tree

lib/Cron/SocialUpdate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected function run($argument) {
4040
}
4141

4242
// update contacts with first available social media profile
43-
$result = $this->social->updateAddressbooks($userId, $offsetBook, $offsetContact);
43+
$result = $this->social->updateAddressBooks($userId, $offsetBook, $offsetContact);
4444

4545
if ($result->getStatus() === Http::STATUS_PARTIAL_CONTENT) {
4646
// not finished; schedule a follow-up

lib/Service/SocialApiService.php

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ protected function addPhoto(array &$contact, string $imageType, string $photo) {
105105

106106

107107
/**
108-
* Gets the addressbook of an addressbookId
108+
* Gets the address book of an addressBookId
109109
*
110110
* @param string $addressBookId the identifier of the addressbook
111111
* @param IManager|null $manager optional a ContactManager to use
@@ -136,12 +136,12 @@ protected function getAddressBook(string $addressBookId, ?IManager $manager = nu
136136

137137

138138
/**
139-
* Retrieves and initiates all addressbooks from a user
139+
* Retrieves and initiates all address books from a user
140140
*
141141
* @param string $userId the user to query
142142
* @param IManager $manager the contact manager to load
143143
*/
144-
protected function registerAddressbooks($userId, IManager $manager) {
144+
protected function registerAddressBooks($userId, IManager $manager) {
145145
$coma = $this->serverContainer->get(ContactsManager::class);
146146
$coma->setupContactsProvider($manager, $userId, $this->urlGen);
147147
$this->manager = $manager;
@@ -150,30 +150,30 @@ protected function registerAddressbooks($userId, IManager $manager) {
150150
/**
151151
* Retrieves social profile data for a contact and updates the entry
152152
*
153-
* @param string $addressbookId the addressbook identifier
153+
* @param string $addressBookId the address book identifier
154154
* @param string $contactId the contact identifier
155155
* @param string|null $network the social network to use (if unknown: take first match)
156156
*
157157
* @return JSONResponse an empty JSONResponse with respective http status code
158158
*/
159-
public function updateContact(string $addressbookId, string $contactId, ?string $network) : JSONResponse {
159+
public function updateContact(string $addressBookId, string $contactId, ?string $network) : JSONResponse {
160160
if (!$this->syncAllowedByAdmin()) {
161161
return new JSONResponse([], Http::STATUS_FORBIDDEN);
162162
}
163163

164-
$socialdata = null;
164+
$socialData = null;
165165
$imageType = null;
166166
$urls = [];
167167
$allConnectors = $this->socialProvider->getSocialConnectors();
168168

169169
try {
170-
// get corresponding addressbook
171-
$addressBook = $this->getAddressBook(urldecode($addressbookId));
170+
// get corresponding address book
171+
$addressBook = $this->getAddressBook(urldecode($addressBookId));
172172
if (is_null($addressBook)) {
173173
return new JSONResponse([], Http::STATUS_BAD_REQUEST);
174174
}
175175

176-
// search contact in that addressbook, get social data
176+
// search contact in that address book, get social data
177177
$contacts = $addressBook->search($contactId, ['UID'], ['types' => true]);
178178

179179
if (!isset($contacts[0])) {
@@ -207,29 +207,29 @@ public function updateContact(string $addressbookId, string $contactId, ?string
207207
foreach ($urls as $url) {
208208
try {
209209
$httpResult = $this->clientService->newClient()->get($url);
210-
$socialdata = $httpResult->getBody();
210+
$socialData = $httpResult->getBody();
211211
$imageType = $httpResult->getHeader('content-type');
212-
if (isset($socialdata) && !empty($imageType)) {
212+
if (isset($socialData) && !empty($imageType)) {
213213
break;
214214
}
215215
} catch (\Exception $e) {
216216
}
217217
}
218218

219-
if (!$socialdata || $imageType === null) {
219+
if (!$socialData || $imageType === null) {
220220
return new JSONResponse([], Http::STATUS_NOT_FOUND);
221221
}
222222
if (!in_array($imageType, self::ALLOWED_CONTENT_TYPES)) {
223223
return new JSONResponse([], Http::STATUS_UNSUPPORTED_MEDIA_TYPE);
224224
}
225225

226-
if (is_resource($socialdata)) {
227-
$socialdata = stream_get_contents($socialdata);
226+
if (is_resource($socialData)) {
227+
$socialData = stream_get_contents($socialData);
228228
}
229229

230-
$socialdata = $this->imageResizer->resizeImage($socialdata);
230+
$socialData = $this->imageResizer->resizeImage($socialData);
231231

232-
if (!$socialdata) {
232+
if (!$socialData) {
233233
return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
234234
}
235235

@@ -238,7 +238,7 @@ public function updateContact(string $addressbookId, string $contactId, ?string
238238
$changes['URI'] = $contact['URI'];
239239
$changes['VERSION'] = $contact['VERSION'];
240240

241-
$this->addPhoto($changes, $imageType, base64_encode($socialdata));
241+
$this->addPhoto($changes, $imageType, base64_encode($socialData));
242242

243243
if (isset($changes['PHOTO'], $contact['PHOTO']) && $changes['PHOTO'] === $contact['PHOTO']) {
244244
return new JSONResponse([], Http::STATUS_NOT_MODIFIED);
@@ -252,7 +252,7 @@ public function updateContact(string $addressbookId, string $contactId, ?string
252252
}
253253

254254
/**
255-
* checks an addressbook is existing
255+
* checks an address book is existing
256256
*
257257
* @param string $searchBookId the UID of the addressbook to verify
258258
* @param string $userId the user that should have access
@@ -267,7 +267,7 @@ public function existsAddressBook(string $searchBookId, string $userId): bool {
267267
}
268268

269269
/**
270-
* checks a contact exists in an addressbook
270+
* checks a contact exists in an address book
271271
*
272272
* @param string $searchContactId the UID of the contact to verify
273273
* @param string $searchBookId the UID of the addressbook to look in
@@ -291,7 +291,7 @@ public function existsContact(string $searchContactId, string $searchBookId, str
291291

292292
/**
293293
* Stores the result of social avatar updates for each contact
294-
* (used during batch updates in updateAddressbooks)
294+
* (used during batch updates in updateAddressBooks)
295295
*
296296
* @param array $report where the results are added
297297
* @param string $entry the element to add
@@ -350,7 +350,7 @@ protected function sortContacts(array $a, array $b) {
350350
}
351351

352352
/**
353-
* Updates social profile data for all contacts of an addressbook
353+
* Updates social profile data for all contacts of an address book
354354
*
355355
* @param string $userId the address book owner
356356
* @param string|null $offsetBook the addressbook to resume from
@@ -359,7 +359,7 @@ protected function sortContacts(array $a, array $b) {
359359
*
360360
* @return JSONResponse JSONResponse with the list of changed and failed contacts
361361
*/
362-
public function updateAddressbooks(string $userId, ?string $offsetBook = null, ?string $offsetContact = null, ?string $network = null) : JSONResponse {
362+
public function updateAddressBooks(string $userId, ?string $offsetBook = null, ?string $offsetContact = null, ?string $network = null) : JSONResponse {
363363
if (!$this->backgroundSyncEnabled($userId)) {
364364
return new JSONResponse([], Http::STATUS_FORBIDDEN);
365365
}
@@ -368,8 +368,8 @@ public function updateAddressbooks(string $userId, ?string $offsetBook = null, ?
368368
$response = [];
369369
$startTime = $this->timeFactory->getTime();
370370

371-
// get corresponding addressbook
372-
$this->registerAddressbooks($userId, $this->manager);
371+
// get corresponding address book
372+
$this->registerAddressBooks($userId, $this->manager);
373373
$addressBooks = $this->manager->getUserAddressBooks();
374374
usort($addressBooks, [$this, 'sortAddressBooks']); // make sure the order stays the same in consecutive calls
375375

@@ -388,7 +388,8 @@ public function updateAddressbooks(string $userId, ?string $offsetBook = null, ?
388388
$offsetBook = null;
389389
}
390390

391-
// get contacts in that addressbook
391+
// get contacts in that address book
392+
/** @noinspection SpellCheckingInspection */
392393
$contacts = $addressBook->search('', ['X-SOCIALPROFILE'], ['types' => true]);
393394
usort($contacts, [$this, 'sortContacts']); // make sure the order stays the same in consecutive calls
394395

tests/unit/Service/SocialApiServiceTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ public function testUpdateAddressbooks($syncAllowedByAdmin, $bgSyncEnabledByUser
606606
->expects($this->never())
607607
->method('getSocialConnector');
608608

609-
$result = $this->service->updateAddressbooks('mrstest');
609+
$result = $this->service->updateAddressBooks('mrstest');
610610

611611
$this->assertEquals($expected, $result->getStatus());
612612

@@ -637,7 +637,7 @@ public function testUpdateAddressbooksTimeout() {
637637

638638
$this->setupAddressbooks();
639639

640-
$result = $this->service->updateAddressbooks('msstest');
640+
$result = $this->service->updateAddressBooks('msstest');
641641

642642
$this->assertEquals(Http::STATUS_PARTIAL_CONTENT, $result->getStatus());
643643

@@ -665,7 +665,7 @@ public function testUpdateAddressbooksContinued($syncAllowedByAdmin, $bgSyncEnab
665665

666666
$this->setupAddressbooks();
667667

668-
$result = $this->service->updateAddressbooks('mrstest', 'contacts2', '22222222-2222-2222-2222-222222222222');
668+
$result = $this->service->updateAddressBooks('mrstest', 'contacts2', '22222222-2222-2222-2222-222222222222');
669669

670670
$this->assertEquals($expected, $result->getStatus());
671671

0 commit comments

Comments
 (0)