Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing notification and mails #735

Merged
merged 1 commit into from
Jul 27, 2021
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
14 changes: 10 additions & 4 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
use OCA\Circles\Exceptions\RequestBuilderException;
use OCA\Circles\Exceptions\SingleCircleNotFoundException;
use OCA\Circles\Model\Probes\MemberProbe;
use OCA\Circles\Service\ConfigService;
use OCA\Circles\Service\FederatedUserService;
use OCA\Circles\Service\MemberService;
use OCP\Contacts\IManager;
Expand Down Expand Up @@ -81,11 +82,14 @@ class Notifier implements INotifier {
/** @var ICloudIdManager */
protected $cloudIdManager;

/** @var MemberService */
private $memberService;

/** @var FederatedUserService */
private $federatedUserService;

/** @var MemberService */
private $memberService;
/** @var ConfigService */
private $configService;


public function __construct(
Expand All @@ -95,7 +99,8 @@ public function __construct(
IURLGenerator $urlGenerator,
ICloudIdManager $cloudIdManager,
MemberService $memberService,
FederatedUserService $federatedUserService
FederatedUserService $federatedUserService,
ConfigService $configService
) {
$this->l10n = $l10n;
$this->factory = $factory;
Expand All @@ -105,6 +110,7 @@ public function __construct(

$this->federatedUserService = $federatedUserService;
$this->memberService = $memberService;
$this->configService = $configService;

$this->setup('app', Application::APP_ID);
}
Expand Down Expand Up @@ -203,7 +209,7 @@ private function prepareMemberNotification(INotification $notification) {
$subject = $this->l10n->t(
'%1$s sent a request to be a member of the Circle "%2$s"',
[
$member->getDisplayName(),
$this->configService->displayFederatedUser($member, true),
$member->getCircle()->getDisplayName()
]
);
Expand Down
8 changes: 4 additions & 4 deletions lib/Service/NotificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ public function notificationInvited(Member $member): void {
$declineAction = $notification->createAction();
$declineUrl = $this->linkToOCS('circles.Local.circleLeave', ['circleId' => $member->getCircleId()]);
$declineAction->setLabel('refuse')
->setLink($this->urlGenerator->getAbsoluteURL($declineUrl), 'PUT');
->setLink($declineUrl, 'PUT');
$notification->addAction($declineAction);

$acceptAction = $notification->createAction();
$acceptUrl = $this->linkToOCS('circles.Local.circleJoin', ['circleId' => $member->getCircleId()]);
$acceptAction->setLabel('accept')
->setLink($this->urlGenerator->getAbsoluteURL($acceptUrl), 'PUT');
->setLink($acceptUrl, 'PUT');
$notification->addAction($acceptAction);

$this->notificationManager->notify($notification);
Expand Down Expand Up @@ -157,7 +157,7 @@ public function notificationRequested(Member $member): void {
]
);
$declineAction->setLabel('refuse')
->setLink($this->urlGenerator->getAbsoluteURL($declineUrl), 'DELETE');
->setLink($declineUrl, 'DELETE');
$notification->addAction($declineAction);

$acceptAction = $notification->createAction();
Expand All @@ -169,7 +169,7 @@ public function notificationRequested(Member $member): void {
]
);
$acceptAction->setLabel('accept')
->setLink($this->urlGenerator->getAbsoluteURL($acceptUrl), 'PUT');
->setLink($acceptUrl, 'PUT');
$notification->addAction($acceptAction);

$this->notificationManager->notify($notification);
Expand Down
20 changes: 18 additions & 2 deletions lib/Service/SendMailService.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ public function generateMail(Circle $circle, Member $member, array $shares, arra
];
}

$template = $this->generateMailExitingShares($invitedBy, $circle->getDisplayName());
$template = $this->generateMailExitingShares(
$invitedBy,
$circle->getDisplayName(),
sizeof($links) > 1
);

$this->fillMailExistingShares($template, $links);
foreach ($mails as $mail) {
try {
Expand All @@ -124,13 +129,24 @@ public function generateMail(Circle $circle, Member $member, array $shares, arra
/**
* @param string $author
* @param string $circleName
* @param bool $multiple
*
* @return IEMailTemplate
*/
private function generateMailExitingShares(string $author, string $circleName): IEMailTemplate {
private function generateMailExitingShares(
string $author,
string $circleName,
bool $multiple = false
): IEMailTemplate {
$emailTemplate = $this->mailer->createEMailTemplate('circles.ExistingShareNotification', []);
$emailTemplate->addHeader();

if ($multiple) {
$text = $this->l10n->t('%s shared multiple files with "%s".', [$author, $circleName]);
} else {
$text = $this->l10n->t('%s shared a file with "%s".', [$author, $circleName]);
}

$text = $this->l10n->t('%s shared multiple files with "%s".', [$author, $circleName]);
$emailTemplate->addBodyText(htmlspecialchars($text), $text);

Expand Down