Passed
Push — master ( 902adb...3cf321 )
by Christoph
10:44 queued 11s
created
apps/contactsinteraction/lib/AddressBook.php 2 patches
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -41,138 +41,138 @@
 block discarded – undo
41 41
 
42 42
 class AddressBook extends ExternalAddressBook implements IACL {
43 43
 
44
-	public const URI = 'recent';
45
-
46
-	use ACLTrait;
47
-
48
-	/** @var RecentContactMapper */
49
-	private $mapper;
50
-
51
-	/** @var IL10N */
52
-	private $l10n;
53
-
54
-	/** @var string */
55
-	private $principalUri;
56
-
57
-	public function __construct(RecentContactMapper $mapper,
58
-								IL10N $l10n,
59
-								string $principalUri) {
60
-		parent::__construct(Application::APP_ID, self::URI);
61
-
62
-		$this->mapper = $mapper;
63
-		$this->l10n = $l10n;
64
-		$this->principalUri = $principalUri;
65
-	}
66
-
67
-	/**
68
-	 * @inheritDoc
69
-	 */
70
-	public function delete(): void {
71
-		throw new Exception("This addressbook is immutable");
72
-	}
73
-
74
-	/**
75
-	 * @inheritDoc
76
-	 */
77
-	function createFile($name, $data = null) {
78
-		throw new Exception("This addressbook is immutable");
79
-	}
80
-
81
-	/**
82
-	 * @inheritDoc
83
-	 * @throws NotFound
84
-	 */
85
-	public function getChild($name) {
86
-		try {
87
-			return new Card(
88
-				$this->mapper->find(
89
-					$this->getUid(),
90
-					(int)$name
91
-				),
92
-				$this->principalUri,
93
-				$this->getACL()
94
-			);
95
-		} catch (DoesNotExistException $ex) {
96
-			throw new NotFound("Contact does not exist: " . $ex->getMessage(), 0, $ex);
97
-		}
98
-	}
99
-
100
-	/**
101
-	 * @inheritDoc
102
-	 */
103
-	public function getChildren(): array {
104
-		return array_map(
105
-			function (RecentContact $contact) {
106
-				return new Card(
107
-					$contact,
108
-					$this->principalUri,
109
-					$this->getACL()
110
-				);
111
-			},
112
-			$this->mapper->findAll($this->getUid())
113
-		);
114
-	}
115
-
116
-	/**
117
-	 * @inheritDoc
118
-	 */
119
-	public function childExists($name) {
120
-		try {
121
-			$this->mapper->find(
122
-				$this->getUid(),
123
-				(int)$name
124
-			);
125
-			return true;
126
-		} catch (DoesNotExistException $e) {
127
-			return false;
128
-		}
129
-	}
130
-
131
-	/**
132
-	 * @inheritDoc
133
-	 */
134
-	public function getLastModified() {
135
-		throw new NotImplemented();
136
-	}
137
-
138
-	/**
139
-	 * @inheritDoc
140
-	 */
141
-	public function propPatch(PropPatch $propPatch) {
142
-		throw new Exception("This addressbook is immutable");
143
-	}
144
-
145
-	/**
146
-	 * @inheritDoc
147
-	 */
148
-	public function getProperties($properties) {
149
-		return [
150
-			'principaluri' => $this->principalUri,
151
-			'{DAV:}displayname' => $this->l10n->t('Recently contacted'),
152
-			'{' . Plugin::NS_OWNCLOUD . '}read-only' => true,
153
-		];
154
-	}
155
-
156
-	public function getOwner(): string {
157
-		return $this->principalUri;
158
-	}
159
-
160
-	/**
161
-	 * @inheritDoc
162
-	 */
163
-	public function getACL() {
164
-		return [
165
-			[
166
-				'privilege' => '{DAV:}read',
167
-				'principal' => $this->getOwner(),
168
-				'protected' => true,
169
-			],
170
-		];
171
-	}
172
-
173
-	private function getUid(): string {
174
-		list(, $uid) = \Sabre\Uri\split($this->principalUri);
175
-		return $uid;
176
-	}
44
+    public const URI = 'recent';
45
+
46
+    use ACLTrait;
47
+
48
+    /** @var RecentContactMapper */
49
+    private $mapper;
50
+
51
+    /** @var IL10N */
52
+    private $l10n;
53
+
54
+    /** @var string */
55
+    private $principalUri;
56
+
57
+    public function __construct(RecentContactMapper $mapper,
58
+                                IL10N $l10n,
59
+                                string $principalUri) {
60
+        parent::__construct(Application::APP_ID, self::URI);
61
+
62
+        $this->mapper = $mapper;
63
+        $this->l10n = $l10n;
64
+        $this->principalUri = $principalUri;
65
+    }
66
+
67
+    /**
68
+     * @inheritDoc
69
+     */
70
+    public function delete(): void {
71
+        throw new Exception("This addressbook is immutable");
72
+    }
73
+
74
+    /**
75
+     * @inheritDoc
76
+     */
77
+    function createFile($name, $data = null) {
78
+        throw new Exception("This addressbook is immutable");
79
+    }
80
+
81
+    /**
82
+     * @inheritDoc
83
+     * @throws NotFound
84
+     */
85
+    public function getChild($name) {
86
+        try {
87
+            return new Card(
88
+                $this->mapper->find(
89
+                    $this->getUid(),
90
+                    (int)$name
91
+                ),
92
+                $this->principalUri,
93
+                $this->getACL()
94
+            );
95
+        } catch (DoesNotExistException $ex) {
96
+            throw new NotFound("Contact does not exist: " . $ex->getMessage(), 0, $ex);
97
+        }
98
+    }
99
+
100
+    /**
101
+     * @inheritDoc
102
+     */
103
+    public function getChildren(): array {
104
+        return array_map(
105
+            function (RecentContact $contact) {
106
+                return new Card(
107
+                    $contact,
108
+                    $this->principalUri,
109
+                    $this->getACL()
110
+                );
111
+            },
112
+            $this->mapper->findAll($this->getUid())
113
+        );
114
+    }
115
+
116
+    /**
117
+     * @inheritDoc
118
+     */
119
+    public function childExists($name) {
120
+        try {
121
+            $this->mapper->find(
122
+                $this->getUid(),
123
+                (int)$name
124
+            );
125
+            return true;
126
+        } catch (DoesNotExistException $e) {
127
+            return false;
128
+        }
129
+    }
130
+
131
+    /**
132
+     * @inheritDoc
133
+     */
134
+    public function getLastModified() {
135
+        throw new NotImplemented();
136
+    }
137
+
138
+    /**
139
+     * @inheritDoc
140
+     */
141
+    public function propPatch(PropPatch $propPatch) {
142
+        throw new Exception("This addressbook is immutable");
143
+    }
144
+
145
+    /**
146
+     * @inheritDoc
147
+     */
148
+    public function getProperties($properties) {
149
+        return [
150
+            'principaluri' => $this->principalUri,
151
+            '{DAV:}displayname' => $this->l10n->t('Recently contacted'),
152
+            '{' . Plugin::NS_OWNCLOUD . '}read-only' => true,
153
+        ];
154
+    }
155
+
156
+    public function getOwner(): string {
157
+        return $this->principalUri;
158
+    }
159
+
160
+    /**
161
+     * @inheritDoc
162
+     */
163
+    public function getACL() {
164
+        return [
165
+            [
166
+                'privilege' => '{DAV:}read',
167
+                'principal' => $this->getOwner(),
168
+                'protected' => true,
169
+            ],
170
+        ];
171
+    }
172
+
173
+    private function getUid(): string {
174
+        list(, $uid) = \Sabre\Uri\split($this->principalUri);
175
+        return $uid;
176
+    }
177 177
 
178 178
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -87,13 +87,13 @@  discard block
 block discarded – undo
87 87
 			return new Card(
88 88
 				$this->mapper->find(
89 89
 					$this->getUid(),
90
-					(int)$name
90
+					(int) $name
91 91
 				),
92 92
 				$this->principalUri,
93 93
 				$this->getACL()
94 94
 			);
95 95
 		} catch (DoesNotExistException $ex) {
96
-			throw new NotFound("Contact does not exist: " . $ex->getMessage(), 0, $ex);
96
+			throw new NotFound("Contact does not exist: ".$ex->getMessage(), 0, $ex);
97 97
 		}
98 98
 	}
99 99
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	public function getChildren(): array {
104 104
 		return array_map(
105
-			function (RecentContact $contact) {
105
+			function(RecentContact $contact) {
106 106
 				return new Card(
107 107
 					$contact,
108 108
 					$this->principalUri,
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		try {
121 121
 			$this->mapper->find(
122 122
 				$this->getUid(),
123
-				(int)$name
123
+				(int) $name
124 124
 			);
125 125
 			return true;
126 126
 		} catch (DoesNotExistException $e) {
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		return [
150 150
 			'principaluri' => $this->principalUri,
151 151
 			'{DAV:}displayname' => $this->l10n->t('Recently contacted'),
152
-			'{' . Plugin::NS_OWNCLOUD . '}read-only' => true,
152
+			'{'.Plugin::NS_OWNCLOUD.'}read-only' => true,
153 153
 		];
154 154
 	}
155 155
 
Please login to merge, or discard this patch.
apps/contactsinteraction/lib/BackgroundJob/CleanupJob.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -31,22 +31,22 @@
 block discarded – undo
31 31
 
32 32
 class CleanupJob extends TimedJob {
33 33
 
34
-	/** @var RecentContactMapper */
35
-	private $mapper;
34
+    /** @var RecentContactMapper */
35
+    private $mapper;
36 36
 
37
-	public function __construct(ITimeFactory $time,
38
-								RecentContactMapper $mapper) {
39
-		parent::__construct($time);
37
+    public function __construct(ITimeFactory $time,
38
+                                RecentContactMapper $mapper) {
39
+        parent::__construct($time);
40 40
 
41
-		$this->setInterval(12 * 60 * 60);
41
+        $this->setInterval(12 * 60 * 60);
42 42
 
43
-		$this->mapper = $mapper;
44
-	}
43
+        $this->mapper = $mapper;
44
+    }
45 45
 
46
-	protected function run($argument) {
47
-		$time = $this->time->getDateTime();
48
-		$time->modify('-7days');
49
-		$this->mapper->cleanUp($time->getTimestamp());
50
-	}
46
+    protected function run($argument) {
47
+        $time = $this->time->getDateTime();
48
+        $time->modify('-7days');
49
+        $this->mapper->cleanUp($time->getTimestamp());
50
+    }
51 51
 
52 52
 }
Please login to merge, or discard this patch.
apps/contactsinteraction/lib/Migration/Version010000Date20200304152605.php 2 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -33,61 +33,61 @@
 block discarded – undo
33 33
 
34 34
 class Version010000Date20200304152605 extends SimpleMigrationStep {
35 35
 
36
-	/**
37
-	 * @param IOutput $output
38
-	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
39
-	 * @param array $options
40
-	 *
41
-	 * @return ISchemaWrapper
42
-	 */
43
-	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper {
44
-		/** @var ISchemaWrapper $schema */
45
-		$schema = $schemaClosure();
36
+    /**
37
+     * @param IOutput $output
38
+     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
39
+     * @param array $options
40
+     *
41
+     * @return ISchemaWrapper
42
+     */
43
+    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper {
44
+        /** @var ISchemaWrapper $schema */
45
+        $schema = $schemaClosure();
46 46
 
47
-		$table = $schema->createTable(RecentContactMapper::TABLE_NAME);
48
-		$table->addColumn('id', 'integer', [
49
-			'autoincrement' => true,
50
-			'notnull' => true,
51
-			'length' => 4,
52
-		]);
53
-		$table->addColumn('actor_uid', 'string', [
54
-			'notnull' => true,
55
-			'length' => 64,
56
-		]);
57
-		$table->addColumn('uid', 'string', [
58
-			'notnull' => false,
59
-			'length' => 64,
60
-		]);
61
-		$table->addColumn('email', 'string', [
62
-			'notnull' => false,
63
-			'length' => 255,
64
-		]);
65
-		$table->addColumn('federated_cloud_id', 'string', [
66
-			'notnull' => false,
67
-			'length' => 255,
68
-		]);
69
-		$table->addColumn('card', 'blob', [
70
-			'notnull' => true,
71
-		]);
72
-		$table->addColumn('last_contact', 'integer', [
73
-			'notnull' => true,
74
-			'length' => 4,
75
-		]);
76
-		$table->setPrimaryKey(['id']);
77
-		// To find all recent entries
78
-		$table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME . '_actor_uid');
79
-		// To find a specific entry
80
-		$table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME . '_id_uid');
81
-		// To find all recent entries with a given UID
82
-		$table->addIndex(['uid'], RecentContactMapper::TABLE_NAME . '_uid');
83
-		// To find all recent entries with a given email address
84
-		$table->addIndex(['email'], RecentContactMapper::TABLE_NAME . '_email');
85
-		// To find all recent entries with a give federated cloud id
86
-		$table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME . '_fed_id');
87
-		// For the cleanup
88
-		$table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME . '_last_contact');
47
+        $table = $schema->createTable(RecentContactMapper::TABLE_NAME);
48
+        $table->addColumn('id', 'integer', [
49
+            'autoincrement' => true,
50
+            'notnull' => true,
51
+            'length' => 4,
52
+        ]);
53
+        $table->addColumn('actor_uid', 'string', [
54
+            'notnull' => true,
55
+            'length' => 64,
56
+        ]);
57
+        $table->addColumn('uid', 'string', [
58
+            'notnull' => false,
59
+            'length' => 64,
60
+        ]);
61
+        $table->addColumn('email', 'string', [
62
+            'notnull' => false,
63
+            'length' => 255,
64
+        ]);
65
+        $table->addColumn('federated_cloud_id', 'string', [
66
+            'notnull' => false,
67
+            'length' => 255,
68
+        ]);
69
+        $table->addColumn('card', 'blob', [
70
+            'notnull' => true,
71
+        ]);
72
+        $table->addColumn('last_contact', 'integer', [
73
+            'notnull' => true,
74
+            'length' => 4,
75
+        ]);
76
+        $table->setPrimaryKey(['id']);
77
+        // To find all recent entries
78
+        $table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME . '_actor_uid');
79
+        // To find a specific entry
80
+        $table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME . '_id_uid');
81
+        // To find all recent entries with a given UID
82
+        $table->addIndex(['uid'], RecentContactMapper::TABLE_NAME . '_uid');
83
+        // To find all recent entries with a given email address
84
+        $table->addIndex(['email'], RecentContactMapper::TABLE_NAME . '_email');
85
+        // To find all recent entries with a give federated cloud id
86
+        $table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME . '_fed_id');
87
+        // For the cleanup
88
+        $table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME . '_last_contact');
89 89
 
90
-		return $schema;
91
-	}
90
+        return $schema;
91
+    }
92 92
 
93 93
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -75,17 +75,17 @@
 block discarded – undo
75 75
 		]);
76 76
 		$table->setPrimaryKey(['id']);
77 77
 		// To find all recent entries
78
-		$table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME . '_actor_uid');
78
+		$table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME.'_actor_uid');
79 79
 		// To find a specific entry
80
-		$table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME . '_id_uid');
80
+		$table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME.'_id_uid');
81 81
 		// To find all recent entries with a given UID
82
-		$table->addIndex(['uid'], RecentContactMapper::TABLE_NAME . '_uid');
82
+		$table->addIndex(['uid'], RecentContactMapper::TABLE_NAME.'_uid');
83 83
 		// To find all recent entries with a given email address
84
-		$table->addIndex(['email'], RecentContactMapper::TABLE_NAME . '_email');
84
+		$table->addIndex(['email'], RecentContactMapper::TABLE_NAME.'_email');
85 85
 		// To find all recent entries with a give federated cloud id
86
-		$table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME . '_fed_id');
86
+		$table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME.'_fed_id');
87 87
 		// For the cleanup
88
-		$table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME . '_last_contact');
88
+		$table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME.'_last_contact');
89 89
 
90 90
 		return $schema;
91 91
 	}
Please login to merge, or discard this patch.
apps/contactsinteraction/lib/AppInfo/Application.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,16 +37,16 @@
 block discarded – undo
37 37
 
38 38
 class Application extends App {
39 39
 
40
-	public const APP_ID = 'contactsinteraction';
40
+    public const APP_ID = 'contactsinteraction';
41 41
 
42
-	public function __construct() {
43
-		parent::__construct(self::APP_ID);
42
+    public function __construct() {
43
+        parent::__construct(self::APP_ID);
44 44
 
45
-		$this->registerListeners($this->getContainer()->query(IEventDispatcher::class));
46
-	}
45
+        $this->registerListeners($this->getContainer()->query(IEventDispatcher::class));
46
+    }
47 47
 
48
-	private function registerListeners(IEventDispatcher $dispatcher): void {
49
-		$dispatcher->addServiceListener(ContactInteractedWithEvent::class, ContactInteractionListener::class);
50
-	}
48
+    private function registerListeners(IEventDispatcher $dispatcher): void {
49
+        $dispatcher->addServiceListener(ContactInteractedWithEvent::class, ContactInteractionListener::class);
50
+    }
51 51
 
52 52
 }
Please login to merge, or discard this patch.
apps/contactsinteraction/lib/Card.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -33,105 +33,105 @@
 block discarded – undo
33 33
 
34 34
 class Card implements ICard, IACL {
35 35
 
36
-	use ACLTrait;
37
-
38
-	/** @var RecentContact */
39
-	private $contact;
40
-
41
-	/** @var string */
42
-	private $principal;
43
-
44
-	/** @var array */
45
-	private $acls;
46
-
47
-	public function __construct(RecentContact $contact, string $principal, array $acls) {
48
-		$this->contact = $contact;
49
-		$this->principal = $principal;
50
-		$this->acls = $acls;
51
-	}
52
-
53
-	/**
54
-	 * @inheritDoc
55
-	 */
56
-	function getOwner(): ?string {
57
-		$this->principal;
58
-	}
59
-
60
-	/**
61
-	 * @inheritDoc
62
-	 */
63
-	function getACL(): array {
64
-		return $this->acls;
65
-	}
66
-
67
-	/**
68
-	 * @inheritDoc
69
-	 */
70
-	function setAcls(array $acls): void {
71
-		throw new NotImplemented();
72
-	}
73
-
74
-	/**
75
-	 * @inheritDoc
76
-	 */
77
-	function put($data): ?string {
78
-		throw new NotImplemented();
79
-	}
80
-
81
-	/**
82
-	 * @inheritDoc
83
-	 */
84
-	function get() {
85
-		return $this->contact->getCard();
86
-	}
87
-
88
-	/**
89
-	 * @inheritDoc
90
-	 */
91
-	function getContentType(): ?string {
92
-		return 'text/vcard; charset=utf-8';
93
-	}
94
-
95
-	/**
96
-	 * @inheritDoc
97
-	 */
98
-	function getETag(): ?string {
99
-		return null;
100
-	}
101
-
102
-	/**
103
-	 * @inheritDoc
104
-	 */
105
-	function getSize(): int {
106
-		throw new NotImplemented();
107
-	}
108
-
109
-	/**
110
-	 * @inheritDoc
111
-	 */
112
-	function delete(): void {
113
-		throw new NotImplemented();
114
-	}
115
-
116
-	/**
117
-	 * @inheritDoc
118
-	 */
119
-	function getName(): string {
120
-		return (string) $this->contact->getId();
121
-	}
122
-
123
-	/**
124
-	 * @inheritDoc
125
-	 */
126
-	function setName($name): void {
127
-		throw new NotImplemented();
128
-	}
129
-
130
-	/**
131
-	 * @inheritDoc
132
-	 */
133
-	function getLastModified(): ?int {
134
-		return $this->contact->getLastContact();
135
-	}
36
+    use ACLTrait;
37
+
38
+    /** @var RecentContact */
39
+    private $contact;
40
+
41
+    /** @var string */
42
+    private $principal;
43
+
44
+    /** @var array */
45
+    private $acls;
46
+
47
+    public function __construct(RecentContact $contact, string $principal, array $acls) {
48
+        $this->contact = $contact;
49
+        $this->principal = $principal;
50
+        $this->acls = $acls;
51
+    }
52
+
53
+    /**
54
+     * @inheritDoc
55
+     */
56
+    function getOwner(): ?string {
57
+        $this->principal;
58
+    }
59
+
60
+    /**
61
+     * @inheritDoc
62
+     */
63
+    function getACL(): array {
64
+        return $this->acls;
65
+    }
66
+
67
+    /**
68
+     * @inheritDoc
69
+     */
70
+    function setAcls(array $acls): void {
71
+        throw new NotImplemented();
72
+    }
73
+
74
+    /**
75
+     * @inheritDoc
76
+     */
77
+    function put($data): ?string {
78
+        throw new NotImplemented();
79
+    }
80
+
81
+    /**
82
+     * @inheritDoc
83
+     */
84
+    function get() {
85
+        return $this->contact->getCard();
86
+    }
87
+
88
+    /**
89
+     * @inheritDoc
90
+     */
91
+    function getContentType(): ?string {
92
+        return 'text/vcard; charset=utf-8';
93
+    }
94
+
95
+    /**
96
+     * @inheritDoc
97
+     */
98
+    function getETag(): ?string {
99
+        return null;
100
+    }
101
+
102
+    /**
103
+     * @inheritDoc
104
+     */
105
+    function getSize(): int {
106
+        throw new NotImplemented();
107
+    }
108
+
109
+    /**
110
+     * @inheritDoc
111
+     */
112
+    function delete(): void {
113
+        throw new NotImplemented();
114
+    }
115
+
116
+    /**
117
+     * @inheritDoc
118
+     */
119
+    function getName(): string {
120
+        return (string) $this->contact->getId();
121
+    }
122
+
123
+    /**
124
+     * @inheritDoc
125
+     */
126
+    function setName($name): void {
127
+        throw new NotImplemented();
128
+    }
129
+
130
+    /**
131
+     * @inheritDoc
132
+     */
133
+    function getLastModified(): ?int {
134
+        return $this->contact->getLastContact();
135
+    }
136 136
 
137 137
 }
Please login to merge, or discard this patch.
apps/contactsinteraction/lib/Db/RecentContact.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -43,31 +43,31 @@
 block discarded – undo
43 43
  */
44 44
 class RecentContact extends Entity {
45 45
 
46
-	/** @var string */
47
-	protected $actorUid;
46
+    /** @var string */
47
+    protected $actorUid;
48 48
 
49
-	/** @var string|null */
50
-	protected $uid;
49
+    /** @var string|null */
50
+    protected $uid;
51 51
 
52
-	/** @var string|null */
53
-	protected $email;
52
+    /** @var string|null */
53
+    protected $email;
54 54
 
55
-	/** @var string|null */
56
-	protected $federatedCloudId;
55
+    /** @var string|null */
56
+    protected $federatedCloudId;
57 57
 
58
-	/** @var string */
59
-	protected $card;
58
+    /** @var string */
59
+    protected $card;
60 60
 
61
-	/** @var int */
62
-	protected $lastContact;
61
+    /** @var int */
62
+    protected $lastContact;
63 63
 
64
-	public function __construct() {
65
-		$this->addType('actorUid', 'string');
66
-		$this->addType('uid', 'string');
67
-		$this->addType('email', 'string');
68
-		$this->addType('federatedCloudId', 'string');
69
-		$this->addType('card', 'string');
70
-		$this->addType('lastContact', 'int');
71
-	}
64
+    public function __construct() {
65
+        $this->addType('actorUid', 'string');
66
+        $this->addType('uid', 'string');
67
+        $this->addType('email', 'string');
68
+        $this->addType('federatedCloudId', 'string');
69
+        $this->addType('card', 'string');
70
+        $this->addType('lastContact', 'int');
71
+    }
72 72
 
73 73
 }
Please login to merge, or discard this patch.
apps/contactsinteraction/lib/Db/CardSearchDao.php 2 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -31,62 +31,62 @@
 block discarded – undo
31 31
 
32 32
 class CardSearchDao {
33 33
 
34
-	/** @var IDBConnection */
35
-	private $db;
34
+    /** @var IDBConnection */
35
+    private $db;
36 36
 
37
-	public function __construct(IDBConnection $db) {
38
-		$this->db = $db;
39
-	}
37
+    public function __construct(IDBConnection $db) {
38
+        $this->db = $db;
39
+    }
40 40
 
41
-	public function findExisting(IUser $user,
42
-								 ?string $uid,
43
-								 ?string $email,
44
-								 ?string $cloudId): ?string {
45
-		$addressbooksQuery = $this->db->getQueryBuilder();
46
-		$cardQuery = $this->db->getQueryBuilder();
47
-		$propQuery = $this->db->getQueryBuilder();
41
+    public function findExisting(IUser $user,
42
+                                 ?string $uid,
43
+                                 ?string $email,
44
+                                 ?string $cloudId): ?string {
45
+        $addressbooksQuery = $this->db->getQueryBuilder();
46
+        $cardQuery = $this->db->getQueryBuilder();
47
+        $propQuery = $this->db->getQueryBuilder();
48 48
 
49
-		$propOr = $propQuery->expr()->orX();
50
-		if ($uid !== null) {
51
-			$propOr->add($propQuery->expr()->andX(
52
-				$propQuery->expr()->eq('name', $cardQuery->createNamedParameter('UID')),
53
-				$propQuery->expr()->eq('value', $cardQuery->createNamedParameter($uid))
54
-			));
55
-		}
56
-		if ($email !== null) {
57
-			$propOr->add($propQuery->expr()->andX(
58
-				$propQuery->expr()->eq('name', $cardQuery->createNamedParameter('EMAIL')),
59
-				$propQuery->expr()->eq('value', $cardQuery->createNamedParameter($email))
60
-			));
61
-		}
62
-		if ($cloudId !== null) {
63
-			$propOr->add($propQuery->expr()->andX(
64
-				$propQuery->expr()->eq('name', $cardQuery->createNamedParameter('CLOUD')),
65
-				$propQuery->expr()->eq('value', $cardQuery->createNamedParameter($cloudId))
66
-			));
67
-		}
68
-		$addressbooksQuery->selectDistinct('id')
69
-			->from('addressbooks')
70
-			->where($addressbooksQuery->expr()->eq('principaluri', $cardQuery->createNamedParameter("principals/users/" . $user->getUID())));
71
-		$propQuery->selectDistinct('cardid')
72
-			->from('cards_properties')
73
-			->where($propQuery->expr()->in('addressbookid', $propQuery->createFunction($addressbooksQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY))
74
-			->andWhere($propOr)
75
-			->groupBy('cardid');
76
-		$cardQuery->select('carddata')
77
-			->from('cards')
78
-			->where($cardQuery->expr()->in('id', $cardQuery->createFunction($propQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY))
79
-			->andWhere($cardQuery->expr()->in('addressbookid', $cardQuery->createFunction($addressbooksQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY))
80
-			->setMaxResults(1);
81
-		$result = $cardQuery->execute();
82
-		/** @var string|false $card */
83
-		$card = $result->fetchColumn(0);
49
+        $propOr = $propQuery->expr()->orX();
50
+        if ($uid !== null) {
51
+            $propOr->add($propQuery->expr()->andX(
52
+                $propQuery->expr()->eq('name', $cardQuery->createNamedParameter('UID')),
53
+                $propQuery->expr()->eq('value', $cardQuery->createNamedParameter($uid))
54
+            ));
55
+        }
56
+        if ($email !== null) {
57
+            $propOr->add($propQuery->expr()->andX(
58
+                $propQuery->expr()->eq('name', $cardQuery->createNamedParameter('EMAIL')),
59
+                $propQuery->expr()->eq('value', $cardQuery->createNamedParameter($email))
60
+            ));
61
+        }
62
+        if ($cloudId !== null) {
63
+            $propOr->add($propQuery->expr()->andX(
64
+                $propQuery->expr()->eq('name', $cardQuery->createNamedParameter('CLOUD')),
65
+                $propQuery->expr()->eq('value', $cardQuery->createNamedParameter($cloudId))
66
+            ));
67
+        }
68
+        $addressbooksQuery->selectDistinct('id')
69
+            ->from('addressbooks')
70
+            ->where($addressbooksQuery->expr()->eq('principaluri', $cardQuery->createNamedParameter("principals/users/" . $user->getUID())));
71
+        $propQuery->selectDistinct('cardid')
72
+            ->from('cards_properties')
73
+            ->where($propQuery->expr()->in('addressbookid', $propQuery->createFunction($addressbooksQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY))
74
+            ->andWhere($propOr)
75
+            ->groupBy('cardid');
76
+        $cardQuery->select('carddata')
77
+            ->from('cards')
78
+            ->where($cardQuery->expr()->in('id', $cardQuery->createFunction($propQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY))
79
+            ->andWhere($cardQuery->expr()->in('addressbookid', $cardQuery->createFunction($addressbooksQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY))
80
+            ->setMaxResults(1);
81
+        $result = $cardQuery->execute();
82
+        /** @var string|false $card */
83
+        $card = $result->fetchColumn(0);
84 84
 
85
-		if ($card === false) {
86
-			return null;
87
-		}
85
+        if ($card === false) {
86
+            return null;
87
+        }
88 88
 
89
-		return $card;
90
-	}
89
+        return $card;
90
+    }
91 91
 
92 92
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
 		}
68 68
 		$addressbooksQuery->selectDistinct('id')
69 69
 			->from('addressbooks')
70
-			->where($addressbooksQuery->expr()->eq('principaluri', $cardQuery->createNamedParameter("principals/users/" . $user->getUID())));
70
+			->where($addressbooksQuery->expr()->eq('principaluri', $cardQuery->createNamedParameter("principals/users/".$user->getUID())));
71 71
 		$propQuery->selectDistinct('cardid')
72 72
 			->from('cards_properties')
73 73
 			->where($propQuery->expr()->in('addressbookid', $propQuery->createFunction($addressbooksQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY))
Please login to merge, or discard this patch.
apps/contactsinteraction/lib/Db/RecentContactMapper.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -32,87 +32,87 @@
 block discarded – undo
32 32
 
33 33
 class RecentContactMapper extends QBMapper {
34 34
 
35
-	public const TABLE_NAME = 'recent_contact';
36
-
37
-	public function __construct(IDBConnection $db) {
38
-		parent::__construct($db, self::TABLE_NAME);
39
-	}
40
-
41
-	/**
42
-	 * @return RecentContact[]
43
-	 */
44
-	public function findAll(string $uid): array {
45
-		$qb = $this->db->getQueryBuilder();
46
-
47
-		$select = $qb
48
-			->select('*')
49
-			->from($this->getTableName())
50
-			->where($qb->expr()->eq('actor_uid', $qb->createNamedParameter($uid)));
51
-
52
-		return $this->findEntities($select);
53
-	}
54
-
55
-	/**
56
-	 * @param string $uid
57
-	 * @param int $id
58
-	 *
59
-	 * @return RecentContact
60
-	 * @throws DoesNotExistException
61
-	 */
62
-	public function find(string $uid, int $id): RecentContact {
63
-		$qb = $this->db->getQueryBuilder();
64
-
65
-		$select = $qb
66
-			->select('*')
67
-			->from($this->getTableName())
68
-			->where($qb->expr()->eq('id', $qb->createNamedParameter($id, $qb::PARAM_INT)))
69
-			->andWhere($qb->expr()->eq('actor_uid', $qb->createNamedParameter($uid)));
70
-
71
-		return $this->findEntity($select);
72
-	}
73
-
74
-	/**
75
-	 * @param IUser $user
76
-	 * @param string|null $uid
77
-	 * @param string|null $email
78
-	 * @param string|null $cloudId
79
-	 *
80
-	 * @return RecentContact[]
81
-	 */
82
-	public function findMatch(IUser $user,
83
-							  ?string $uid,
84
-							  ?string $email,
85
-							  ?string $cloudId): array {
86
-		$qb = $this->db->getQueryBuilder();
87
-
88
-		$or = $qb->expr()->orX();
89
-		if ($uid !== null) {
90
-			$or->add($qb->expr()->eq('uid', $qb->createNamedParameter($uid)));
91
-		}
92
-		if ($email !== null) {
93
-			$or->add($qb->expr()->eq('email', $qb->createNamedParameter($email)));
94
-		}
95
-		if ($cloudId !== null) {
96
-			$or->add($qb->expr()->eq('federated_cloud_id', $qb->createNamedParameter($cloudId)));
97
-		}
98
-
99
-		$select = $qb
100
-			->select('*')
101
-			->from($this->getTableName())
102
-			->where($or)
103
-			->andWhere($qb->expr()->eq('actor_uid', $qb->createNamedParameter($user->getUID())));
104
-
105
-		return $this->findEntities($select);
106
-	}
107
-
108
-	public function cleanUp(int $olderThan): void {
109
-		$qb = $this->db->getQueryBuilder();
110
-
111
-		$delete = $qb
112
-			->delete($this->getTableName())
113
-			->where($qb->expr()->lt('last_contact', $qb->createNamedParameter($olderThan)));
114
-
115
-		$delete->execute();
116
-	}
35
+    public const TABLE_NAME = 'recent_contact';
36
+
37
+    public function __construct(IDBConnection $db) {
38
+        parent::__construct($db, self::TABLE_NAME);
39
+    }
40
+
41
+    /**
42
+     * @return RecentContact[]
43
+     */
44
+    public function findAll(string $uid): array {
45
+        $qb = $this->db->getQueryBuilder();
46
+
47
+        $select = $qb
48
+            ->select('*')
49
+            ->from($this->getTableName())
50
+            ->where($qb->expr()->eq('actor_uid', $qb->createNamedParameter($uid)));
51
+
52
+        return $this->findEntities($select);
53
+    }
54
+
55
+    /**
56
+     * @param string $uid
57
+     * @param int $id
58
+     *
59
+     * @return RecentContact
60
+     * @throws DoesNotExistException
61
+     */
62
+    public function find(string $uid, int $id): RecentContact {
63
+        $qb = $this->db->getQueryBuilder();
64
+
65
+        $select = $qb
66
+            ->select('*')
67
+            ->from($this->getTableName())
68
+            ->where($qb->expr()->eq('id', $qb->createNamedParameter($id, $qb::PARAM_INT)))
69
+            ->andWhere($qb->expr()->eq('actor_uid', $qb->createNamedParameter($uid)));
70
+
71
+        return $this->findEntity($select);
72
+    }
73
+
74
+    /**
75
+     * @param IUser $user
76
+     * @param string|null $uid
77
+     * @param string|null $email
78
+     * @param string|null $cloudId
79
+     *
80
+     * @return RecentContact[]
81
+     */
82
+    public function findMatch(IUser $user,
83
+                              ?string $uid,
84
+                              ?string $email,
85
+                              ?string $cloudId): array {
86
+        $qb = $this->db->getQueryBuilder();
87
+
88
+        $or = $qb->expr()->orX();
89
+        if ($uid !== null) {
90
+            $or->add($qb->expr()->eq('uid', $qb->createNamedParameter($uid)));
91
+        }
92
+        if ($email !== null) {
93
+            $or->add($qb->expr()->eq('email', $qb->createNamedParameter($email)));
94
+        }
95
+        if ($cloudId !== null) {
96
+            $or->add($qb->expr()->eq('federated_cloud_id', $qb->createNamedParameter($cloudId)));
97
+        }
98
+
99
+        $select = $qb
100
+            ->select('*')
101
+            ->from($this->getTableName())
102
+            ->where($or)
103
+            ->andWhere($qb->expr()->eq('actor_uid', $qb->createNamedParameter($user->getUID())));
104
+
105
+        return $this->findEntities($select);
106
+    }
107
+
108
+    public function cleanUp(int $olderThan): void {
109
+        $qb = $this->db->getQueryBuilder();
110
+
111
+        $delete = $qb
112
+            ->delete($this->getTableName())
113
+            ->where($qb->expr()->lt('last_contact', $qb->createNamedParameter($olderThan)));
114
+
115
+        $delete->execute();
116
+    }
117 117
 
118 118
 }
Please login to merge, or discard this patch.
apps/contactsinteraction/lib/Listeners/ContactInteractionListener.php 2 patches
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -42,130 +42,130 @@
 block discarded – undo
42 42
 
43 43
 class ContactInteractionListener implements IEventListener {
44 44
 
45
-	/** @var RecentContactMapper */
46
-	private $mapper;
47
-
48
-	/** @var CardSearchDao */
49
-	private $cardSearchDao;
50
-
51
-	/** @var IUserManager */
52
-	private $userManager;
53
-
54
-	/** @var ITimeFactory */
55
-	private $timeFactory;
56
-
57
-	/** @var IL10N */
58
-	private $l10n;
59
-
60
-	/** @var ILogger */
61
-	private $logger;
62
-
63
-	public function __construct(RecentContactMapper $mapper,
64
-								CardSearchDao $cardSearchDao,
65
-								IUserManager $userManager,
66
-								ITimeFactory $timeFactory,
67
-								IL10N $l10nFactory,
68
-								ILogger $logger) {
69
-		$this->mapper = $mapper;
70
-		$this->cardSearchDao = $cardSearchDao;
71
-		$this->userManager = $userManager;
72
-		$this->timeFactory = $timeFactory;
73
-		$this->l10n = $l10nFactory;
74
-		$this->logger = $logger;
75
-	}
76
-
77
-	public function handle(Event $event): void {
78
-		if (!($event instanceof ContactInteractedWithEvent)) {
79
-			return;
80
-		}
81
-
82
-		if ($event->getUid() === null && $event->getEmail() === null && $event->getFederatedCloudId() === null) {
83
-			$this->logger->warning("Contact interaction event has no user identifier set");
84
-			return;
85
-		}
86
-
87
-		$existing = $this->mapper->findMatch(
88
-			$event->getActor(),
89
-			$event->getUid(),
90
-			$event->getEmail(),
91
-			$event->getFederatedCloudId()
92
-		);
93
-		if (!empty($existing)) {
94
-			$now = $this->timeFactory->getTime();
95
-			foreach ($existing as $c) {
96
-				$c->setLastContact($now);
97
-				$this->mapper->update($c);
98
-			}
99
-
100
-			return;
101
-		}
102
-
103
-		$contact = new RecentContact();
104
-		$contact->setActorUid($event->getActor()->getUID());
105
-		if ($event->getUid() !== null) {
106
-			$contact->setUid($event->getUid());
107
-		}
108
-		if ($event->getEmail() !== null) {
109
-			$contact->setEmail($event->getEmail());
110
-		}
111
-		if ($event->getFederatedCloudId() !== null) {
112
-			$contact->setFederatedCloudId($event->getFederatedCloudId());
113
-		}
114
-		$contact->setLastContact($this->timeFactory->getTime());
115
-
116
-		$copy = $this->cardSearchDao->findExisting(
117
-			$event->getActor(),
118
-			$event->getUid(),
119
-			$event->getEmail(),
120
-			$event->getFederatedCloudId()
121
-		);
122
-		if ($copy !== null) {
123
-			try {
124
-				$parsed = Reader::read($copy, Reader::OPTION_FORGIVING);
125
-				$parsed->CATEGORIES = $this->l10n->t('Recently contacted');
126
-				$contact->setCard($parsed->serialize());
127
-			} catch (Throwable $e) {
128
-				$this->logger->logException($e, [
129
-					'message' => 'Could not parse card to add recent category: ' . $e->getMessage(),
130
-					'level' => ILogger::WARN,
131
-				]);
132
-				$contact->setCard($copy);
133
-			}
134
-		} else {
135
-			$contact->setCard($this->generateCard($contact));
136
-		}
137
-		$this->mapper->insert($contact);
138
-	}
139
-
140
-	private function getDisplayName(?string $uid): ?string {
141
-		if ($uid === null) {
142
-			return null;
143
-		}
144
-		if (($user = $this->userManager->get($uid)) === null) {
145
-			return null;
146
-		}
147
-
148
-		return $user->getDisplayName();
149
-	}
150
-
151
-	private function generateCard(RecentContact $contact): string {
152
-		$props = [
153
-			'URI' => UUIDUtil::getUUID(),
154
-			'FN' => $this->getDisplayName($contact->getUid()) ?? $contact->getEmail() ?? $contact->getFederatedCloudId(),
155
-			'CATEGORIES' => $this->l10n->t('Recently contacted'),
156
-		];
157
-
158
-		if ($contact->getUid() !== null) {
159
-			$props['X-NEXTCLOUD-UID'] = $contact->getUid();
160
-		}
161
-		if ($contact->getEmail() !== null) {
162
-			$props['EMAIL'] = $contact->getEmail();
163
-		}
164
-		if ($contact->getFederatedCloudId() !== null) {
165
-			$props['CLOUD'] = $contact->getFederatedCloudId();
166
-		}
167
-
168
-		return (new VCard($props))->serialize();
169
-	}
45
+    /** @var RecentContactMapper */
46
+    private $mapper;
47
+
48
+    /** @var CardSearchDao */
49
+    private $cardSearchDao;
50
+
51
+    /** @var IUserManager */
52
+    private $userManager;
53
+
54
+    /** @var ITimeFactory */
55
+    private $timeFactory;
56
+
57
+    /** @var IL10N */
58
+    private $l10n;
59
+
60
+    /** @var ILogger */
61
+    private $logger;
62
+
63
+    public function __construct(RecentContactMapper $mapper,
64
+                                CardSearchDao $cardSearchDao,
65
+                                IUserManager $userManager,
66
+                                ITimeFactory $timeFactory,
67
+                                IL10N $l10nFactory,
68
+                                ILogger $logger) {
69
+        $this->mapper = $mapper;
70
+        $this->cardSearchDao = $cardSearchDao;
71
+        $this->userManager = $userManager;
72
+        $this->timeFactory = $timeFactory;
73
+        $this->l10n = $l10nFactory;
74
+        $this->logger = $logger;
75
+    }
76
+
77
+    public function handle(Event $event): void {
78
+        if (!($event instanceof ContactInteractedWithEvent)) {
79
+            return;
80
+        }
81
+
82
+        if ($event->getUid() === null && $event->getEmail() === null && $event->getFederatedCloudId() === null) {
83
+            $this->logger->warning("Contact interaction event has no user identifier set");
84
+            return;
85
+        }
86
+
87
+        $existing = $this->mapper->findMatch(
88
+            $event->getActor(),
89
+            $event->getUid(),
90
+            $event->getEmail(),
91
+            $event->getFederatedCloudId()
92
+        );
93
+        if (!empty($existing)) {
94
+            $now = $this->timeFactory->getTime();
95
+            foreach ($existing as $c) {
96
+                $c->setLastContact($now);
97
+                $this->mapper->update($c);
98
+            }
99
+
100
+            return;
101
+        }
102
+
103
+        $contact = new RecentContact();
104
+        $contact->setActorUid($event->getActor()->getUID());
105
+        if ($event->getUid() !== null) {
106
+            $contact->setUid($event->getUid());
107
+        }
108
+        if ($event->getEmail() !== null) {
109
+            $contact->setEmail($event->getEmail());
110
+        }
111
+        if ($event->getFederatedCloudId() !== null) {
112
+            $contact->setFederatedCloudId($event->getFederatedCloudId());
113
+        }
114
+        $contact->setLastContact($this->timeFactory->getTime());
115
+
116
+        $copy = $this->cardSearchDao->findExisting(
117
+            $event->getActor(),
118
+            $event->getUid(),
119
+            $event->getEmail(),
120
+            $event->getFederatedCloudId()
121
+        );
122
+        if ($copy !== null) {
123
+            try {
124
+                $parsed = Reader::read($copy, Reader::OPTION_FORGIVING);
125
+                $parsed->CATEGORIES = $this->l10n->t('Recently contacted');
126
+                $contact->setCard($parsed->serialize());
127
+            } catch (Throwable $e) {
128
+                $this->logger->logException($e, [
129
+                    'message' => 'Could not parse card to add recent category: ' . $e->getMessage(),
130
+                    'level' => ILogger::WARN,
131
+                ]);
132
+                $contact->setCard($copy);
133
+            }
134
+        } else {
135
+            $contact->setCard($this->generateCard($contact));
136
+        }
137
+        $this->mapper->insert($contact);
138
+    }
139
+
140
+    private function getDisplayName(?string $uid): ?string {
141
+        if ($uid === null) {
142
+            return null;
143
+        }
144
+        if (($user = $this->userManager->get($uid)) === null) {
145
+            return null;
146
+        }
147
+
148
+        return $user->getDisplayName();
149
+    }
150
+
151
+    private function generateCard(RecentContact $contact): string {
152
+        $props = [
153
+            'URI' => UUIDUtil::getUUID(),
154
+            'FN' => $this->getDisplayName($contact->getUid()) ?? $contact->getEmail() ?? $contact->getFederatedCloudId(),
155
+            'CATEGORIES' => $this->l10n->t('Recently contacted'),
156
+        ];
157
+
158
+        if ($contact->getUid() !== null) {
159
+            $props['X-NEXTCLOUD-UID'] = $contact->getUid();
160
+        }
161
+        if ($contact->getEmail() !== null) {
162
+            $props['EMAIL'] = $contact->getEmail();
163
+        }
164
+        if ($contact->getFederatedCloudId() !== null) {
165
+            $props['CLOUD'] = $contact->getFederatedCloudId();
166
+        }
167
+
168
+        return (new VCard($props))->serialize();
169
+    }
170 170
 
171 171
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@
 block discarded – undo
126 126
 				$contact->setCard($parsed->serialize());
127 127
 			} catch (Throwable $e) {
128 128
 				$this->logger->logException($e, [
129
-					'message' => 'Could not parse card to add recent category: ' . $e->getMessage(),
129
+					'message' => 'Could not parse card to add recent category: '.$e->getMessage(),
130 130
 					'level' => ILogger::WARN,
131 131
 				]);
132 132
 				$contact->setCard($copy);
Please login to merge, or discard this patch.