Merge pull request #5120 from nextcloud/backport-5118-use-language-of-recipient-not-admin
[stable12] Use the language of the recipient not the actor
This commit is contained in:
commit
7db495a246
|
@ -23,11 +23,13 @@ namespace OC\Settings;
|
|||
|
||||
use OC\Settings\Activity\Provider;
|
||||
use OCP\Activity\IManager as IActivityManager;
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IUserSession;
|
||||
use OCP\L10N\IFactory;
|
||||
use OCP\Mail\IMailer;
|
||||
|
||||
class Hooks {
|
||||
|
@ -42,15 +44,28 @@ class Hooks {
|
|||
protected $urlGenerator;
|
||||
/** @var IMailer */
|
||||
protected $mailer;
|
||||
/** @var IConfig */
|
||||
protected $config;
|
||||
/** @var IFactory */
|
||||
protected $languageFactory;
|
||||
/** @var IL10N */
|
||||
protected $l;
|
||||
|
||||
public function __construct(IActivityManager $activityManager, IUserManager $userManager, IUserSession $userSession, IURLGenerator $urlGenerator, IMailer $mailer, IL10N $l) {
|
||||
public function __construct(IActivityManager $activityManager,
|
||||
IUserManager $userManager,
|
||||
IUserSession $userSession,
|
||||
IURLGenerator $urlGenerator,
|
||||
IMailer $mailer,
|
||||
IConfig $config,
|
||||
IFactory $languageFactory,
|
||||
IL10N $l) {
|
||||
$this->activityManager = $activityManager;
|
||||
$this->userManager = $userManager;
|
||||
$this->userSession = $userSession;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->mailer = $mailer;
|
||||
$this->config = $config;
|
||||
$this->languageFactory = $languageFactory;
|
||||
$this->l = $l;
|
||||
}
|
||||
|
||||
|
@ -77,6 +92,14 @@ class Hooks {
|
|||
$actor = $this->userSession->getUser();
|
||||
if ($actor instanceof IUser) {
|
||||
if ($actor->getUID() !== $user->getUID()) {
|
||||
$this->l = $this->languageFactory->get(
|
||||
'settings',
|
||||
$this->config->getUserValue(
|
||||
$user->getUID(), 'core', 'lang',
|
||||
$this->config->getSystemValue('default_language', 'en')
|
||||
)
|
||||
);
|
||||
|
||||
$text = $this->l->t('%1$s changed your password on %2$s.', [$actor->getDisplayName(), $instanceUrl]);
|
||||
$event->setAuthor($actor->getUID())
|
||||
->setSubject(Provider::PASSWORD_CHANGED_BY, [$actor->getUID()]);
|
||||
|
@ -133,6 +156,14 @@ class Hooks {
|
|||
$actor = $this->userSession->getUser();
|
||||
if ($actor instanceof IUser) {
|
||||
if ($actor->getUID() !== $user->getUID()) {
|
||||
$this->l = $this->languageFactory->get(
|
||||
'settings',
|
||||
$this->config->getUserValue(
|
||||
$user->getUID(), 'core', 'lang',
|
||||
$this->config->getSystemValue('default_language', 'en')
|
||||
)
|
||||
);
|
||||
|
||||
$text = $this->l->t('%1$s changed your email address on %2$s.', [$actor->getDisplayName(), $instanceUrl]);
|
||||
$event->setAuthor($actor->getUID())
|
||||
->setSubject(Provider::EMAIL_CHANGED_BY, [$actor->getUID()]);
|
||||
|
|
Loading…
Reference in New Issue