Code Duplication    Length = 32-32 lines in 2 locations

lib/FilesHooks.php 2 locations

@@ 480-511 (lines=32) @@
477
	 * @param int $fileId
478
	 * @param string $oldFileName
479
	 */
480
	protected function generateDeleteActivities($users, $pathMap, $fileId, $oldFileName) {
481
		if (empty($users)) {
482
			return;
483
		}
484
485
		$filteredStreamUsers = $this->userSettings->filterUsersBySetting($users, 'stream', Files::TYPE_SHARE_DELETED);
486
		$filteredEmailUsers = $this->userSettings->filterUsersBySetting($users, 'email', Files::TYPE_SHARE_DELETED);
487
488
		foreach ($users as $user) {
489
			if (empty($filteredStreamUsers[$user]) && empty($filteredEmailUsers[$user])) {
490
				continue;
491
			}
492
493
			$path = $pathMap[$user];
494
495
			if ($user === $this->currentUser->getUID()) {
496
				$userSubject = 'deleted_self';
497
				$userParams = [[$fileId => $path . '/' . $oldFileName]];
498
			} else {
499
				$userSubject = 'deleted_by';
500
				$userParams = [[$fileId => $path . '/' . $oldFileName], $this->currentUser->getUserIdentifier()];
501
			}
502
503
			$this->addNotificationsForUser(
504
				$user, $userSubject, $userParams,
505
				$fileId, $path . '/' . $oldFileName, true,
506
				!empty($filteredStreamUsers[$user]),
507
				$filteredEmailUsers[$user] ?? false,
508
				Files::TYPE_SHARE_DELETED
509
			);
510
		}
511
	}
512
513
	/**
514
	 * @param string[] $users
@@ 519-550 (lines=32) @@
516
	 * @param int $fileId
517
	 * @param string $fileName
518
	 */
519
	protected function generateAddActivities($users, $pathMap, $fileId, $fileName) {
520
		if (empty($users)) {
521
			return;
522
		}
523
524
		$filteredStreamUsers = $this->userSettings->filterUsersBySetting($users, 'stream', Files::TYPE_SHARE_CREATED);
525
		$filteredEmailUsers = $this->userSettings->filterUsersBySetting($users, 'email', Files::TYPE_SHARE_CREATED);
526
527
		foreach ($users as $user) {
528
			if (empty($filteredStreamUsers[$user]) && empty($filteredEmailUsers[$user])) {
529
				continue;
530
			}
531
532
			$path = $pathMap[$user];
533
534
			if ($user === $this->currentUser->getUID()) {
535
				$userSubject = 'created_self';
536
				$userParams = [[$fileId => $path . '/' . $fileName]];
537
			} else {
538
				$userSubject = 'created_by';
539
				$userParams = [[$fileId => $path . '/' . $fileName], $this->currentUser->getUserIdentifier()];
540
			}
541
542
			$this->addNotificationsForUser(
543
				$user, $userSubject, $userParams,
544
				$fileId, $path . '/' . $fileName, true,
545
				!empty($filteredStreamUsers[$user]),
546
				$filteredEmailUsers[$user] ?? false,
547
				Files::TYPE_SHARE_CREATED
548
			);
549
		}
550
	}
551
552
	/**
553
	 * @param string[] $users