Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions lib/Service/MembersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ private function addMassiveMembers(Circle $circle, $ident, $type) {
return $this->addGroupMembers($circle, $ident);
}

if ($type === Member::TYPE_USER) {
return $this->addMassiveMails($circle, $ident);
}

return false;
}

Expand Down Expand Up @@ -320,9 +324,8 @@ private function verifyIdentContact(&$ident, $type) {
}

$tmpContact = $this->userId . ':' . $ident;
try {
MiscService::getContactData($tmpContact);
} catch (Exception $e) {
$result = MiscService::getContactData($tmpContact);
if (empty($result)) {
throw new NoUserException($this->l10n->t("This contact is not available"));
}

Expand Down Expand Up @@ -358,6 +361,31 @@ private function addGroupMembers(Circle $circle, $groupId) {
}


/**
* @param Circle $circle
* @param string $mails
*
* @return bool
*/
private function addMassiveMails(Circle $circle, $mails) {

foreach (explode(' ', trim($mails)) as $mail) {
if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) {
return false;
}
}

foreach (explode(' ', trim($mails)) as $mail) {
try {
$this->addMember($circle->getUniqueId(), $mail, Member::TYPE_MAIL);
} catch (Exception $e) {
}
}

return true;
}


/**
* getMember();
*
Expand Down Expand Up @@ -543,4 +571,4 @@ public function onUserRemoved($userId) {
}


}
}
11 changes: 6 additions & 5 deletions lib/Service/MiscService.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public function getRealUserId($userId) {
}

$user = array_shift($result);

return $user->getUID();
}

Expand Down Expand Up @@ -200,12 +201,12 @@ private static function getDisplayContact(&$display, $ident, $type) {
* @return mixed|string
*/
public static function getContactData($ident) {
list($userId, $contactId) = explode(':', $ident);

if (!class_exists(\OCA\DAV\AppInfo\Application::class)) {
return null;
if (!class_exists(\OCA\DAV\AppInfo\Application::class) || !strpos(':', $ident)) {
return [];
}

list($userId, $contactId) = explode(':', $ident);

try {
/** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
$contactApp = new \OCA\DAV\AppInfo\Application();
Expand All @@ -217,7 +218,7 @@ public static function getContactData($ident) {
} catch (Exception $e) {
}

return null;
return [];
}


Expand Down