fixing stuff
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
This commit is contained in:
parent
9f67aebd45
commit
bcf1992a1c
|
@ -12,12 +12,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/daita/my-small-php-tools.git",
|
||||
"reference": "3c0a95f97b8f09cab26f18a4c37b3ad73a0b96a2"
|
||||
"reference": "23d37b41c4d492604e545c05e0d6abe35eb38cc0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/3c0a95f97b8f09cab26f18a4c37b3ad73a0b96a2",
|
||||
"reference": "3c0a95f97b8f09cab26f18a4c37b3ad73a0b96a2",
|
||||
"url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/23d37b41c4d492604e545c05e0d6abe35eb38cc0",
|
||||
"reference": "23d37b41c4d492604e545c05e0d6abe35eb38cc0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -40,7 +40,7 @@
|
|||
}
|
||||
],
|
||||
"description": "My small PHP Tools",
|
||||
"time": "2019-10-04T12:32:13+00:00"
|
||||
"time": "2020-01-08T12:11:53+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
|
|
|
@ -157,7 +157,7 @@ class Application extends App {
|
|||
try {
|
||||
/** @var ConfigService $configService */
|
||||
$configService = OC::$server->query(ConfigService::class);
|
||||
if ($configService->getAppValue(ConfigService::CIRCLES_CONTACT_BACKEND) !== '1') {
|
||||
if (!$configService->isContactsBackend()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
namespace OCA\Circles\Command;
|
||||
|
||||
use Exception;
|
||||
use OC\Core\Command\Base;
|
||||
use OCA\Circles\Exceptions\CommandMissingArgumentException;
|
||||
use OCA\Circles\Exceptions\FakeException;
|
||||
|
@ -63,11 +64,18 @@ class SyncContact extends Base {
|
|||
|
||||
protected function configure() {
|
||||
parent::configure();
|
||||
$this->setName('circles:sync')
|
||||
$this->setName('circles:contacts:sync')
|
||||
->setDescription('sync contacts, when using the Circles app as a backend of the Contact app');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*
|
||||
* @return int|void|null
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
$this->davService->migration();
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ class ContactsExistingShares extends TimedJob {
|
|||
$this->configService = $c->query(ConfigService::class);
|
||||
$this->miscService = $c->query(MiscService::class);
|
||||
|
||||
if ($this->configService->getAppValue(ConfigService::CIRCLES_CONTACT_BACKEND) !== '1') {
|
||||
if (!$this->configService->isContactsBackend()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ class TokensRequestBuilder extends CoreRequestBuilder {
|
|||
$qb = $this->dbConnection->getQueryBuilder();
|
||||
|
||||
/** @noinspection PhpMethodParametersCountMismatchInspection */
|
||||
$qb->select('t.user_id', 't.circle_id', 't.share_id', 't.token')
|
||||
$qb->select('t.user_id', 't.circle_id', 't.member_id', 't.share_id', 't.token', 't.accepted')
|
||||
->from(self::TABLE_TOKENS, 't');
|
||||
|
||||
$this->default_select_alias = 't';
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace OCA\Circles\Model;
|
|||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use JsonSerializable;
|
||||
use OCP\Share\IShare;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -45,6 +46,12 @@ class SharesToken implements JsonSerializable {
|
|||
/** @var string */
|
||||
private $circleId = '';
|
||||
|
||||
/** @var string */
|
||||
private $memberId = '';
|
||||
|
||||
/** @var int */
|
||||
private $accepted = IShare::STATUS_PENDING;
|
||||
|
||||
/** @var string */
|
||||
private $userId = '';
|
||||
|
||||
|
@ -81,6 +88,25 @@ class SharesToken implements JsonSerializable {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMemberId(): string {
|
||||
return $this->memberId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $memberId
|
||||
*
|
||||
* @return SharesToken
|
||||
*/
|
||||
public function setMemberId(string $memberId): self {
|
||||
$this->memberId = $memberId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
@ -138,11 +164,32 @@ class SharesToken implements JsonSerializable {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getAccepted(): int {
|
||||
return $this->accepted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $accepted
|
||||
*
|
||||
* @return SharesToken
|
||||
*/
|
||||
public function setAccepted(int $accepted): self {
|
||||
$this->accepted = $accepted;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*/
|
||||
function import(array $data) {
|
||||
$this->setCircleId($this->get('circle_id', $data, ''));
|
||||
$this->setMemberId($this->get('member_id', $data, ''));
|
||||
$this->setAccepted($this->getInt('accepted', $data, IShare::STATUS_PENDING));
|
||||
$this->setUserId($this->get('user_id', $data, ''));
|
||||
$this->setShareId($this->get('share_id', $data, ''));
|
||||
$this->setToken($this->get('token', $data, ''));
|
||||
|
@ -155,9 +202,11 @@ class SharesToken implements JsonSerializable {
|
|||
function jsonSerialize(): array {
|
||||
return [
|
||||
'circleId' => $this->getCircleId(),
|
||||
'memberId' => $this->getMemberId(),
|
||||
'userId' => $this->getUserId(),
|
||||
'shareId' => $this->getShareId(),
|
||||
'token' => $this->getToken()
|
||||
'token' => $this->getToken(),
|
||||
'accepted' => $this->getAccepted()
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -371,6 +371,19 @@ class ConfigService {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isContactsBackend(): bool {
|
||||
return ($this->getAppValue(ConfigService::CIRCLES_CONTACT_BACKEND) !== '0');
|
||||
}
|
||||
|
||||
|
||||
public function contactsBackendType(): int {
|
||||
return (int)$this->getAppValue(ConfigService::CIRCLES_CONTACT_BACKEND);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
|
|
@ -160,6 +160,8 @@ class DavService {
|
|||
|
||||
$this->miscService->log('Deleting Card: ' . json_encode($davCard), 1);
|
||||
$this->membersRequest->removeMembersByContactId($davCard->getUniqueId(), Member::TYPE_USER);
|
||||
$this->manageDeprecatedCircles($davCard->getAddressBookId());
|
||||
$this->manageDeprecatedMembers($davCard);
|
||||
}
|
||||
|
||||
|
||||
|
@ -244,7 +246,6 @@ class DavService {
|
|||
* @param DavCard $davCard
|
||||
*/
|
||||
private function manageDeprecatedMembers(DavCard $davCard) {
|
||||
// TODO: Check this.
|
||||
$circles = array_map(
|
||||
function(Circle $circle) {
|
||||
return $circle->getUniqueId();
|
||||
|
@ -389,7 +390,8 @@ class DavService {
|
|||
continue;
|
||||
}
|
||||
|
||||
$circle = new Circle(Circle::CIRCLES_PUBLIC, $group . ' - ' . $this->uuid(5));
|
||||
$user = $this->userManager->get($davCard->getOwner());
|
||||
$circle = new Circle($this->configService->contactsBackendType(), $group . ' - ' . $user->getDisplayName());
|
||||
$circle->setContactAddressBook($davCard->getAddressBookId());
|
||||
$circle->setContactGroupName($group);
|
||||
|
||||
|
@ -480,7 +482,7 @@ class DavService {
|
|||
* @throws Exception
|
||||
*/
|
||||
public function migration() {
|
||||
if ($this->configService->getAppValue(ConfigService::CIRCLES_CONTACT_BACKEND) !== '1') {
|
||||
if (!$this->configService->isContactsBackend()) {
|
||||
throw new Exception('Circles needs to be set as Contacts App Backend first');
|
||||
}
|
||||
|
||||
|
|
|
@ -458,6 +458,7 @@ class ShareByCircleProvider extends CircleProviderRequest implements IShareProvi
|
|||
public function getSharesByPath(Node $path) {
|
||||
$qb = $this->getBaseSelectSql();
|
||||
$this->limitToFiles($qb, [$path->getId()]);
|
||||
|
||||
$cursor = $qb->execute();
|
||||
|
||||
$shares = [];
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
Loading…
Reference in New Issue