Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
b7046d39
Unverified
Commit
b7046d39
authored
8 years ago
by
Roeland Jago Douma
Browse files
Options
Downloads
Patches
Plain Diff
Remove internal share mail function
Signed-off-by:
Roeland Jago Douma
<
roeland@famdouma.nl
>
parent
57e61250
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/private/Share/MailNotifications.php
+0
-80
0 additions, 80 deletions
lib/private/Share/MailNotifications.php
tests/lib/Share/MailNotificationsTest.php
+0
-48
0 additions, 48 deletions
tests/lib/Share/MailNotificationsTest.php
with
0 additions
and
128 deletions
lib/private/Share/MailNotifications.php
+
0
−
80
View file @
b7046d39
...
...
@@ -88,75 +88,6 @@ class MailNotifications {
$this
->
senderDisplayName
=
$this
->
user
->
getDisplayName
();
}
/**
* inform users if a file was shared with them
*
* @param IUser[] $recipientList list of recipients
* @param string $itemSource shared item source
* @param string $itemType shared item type
* @return array list of user to whom the mail send operation failed
*/
public
function
sendInternalShareMail
(
$recipientList
,
$itemSource
,
$itemType
)
{
$noMail
=
[];
foreach
(
$recipientList
as
$recipient
)
{
$recipientDisplayName
=
$recipient
->
getDisplayName
();
$to
=
$recipient
->
getEMailAddress
();
if
(
$to
===
''
)
{
$noMail
[]
=
$recipientDisplayName
;
continue
;
}
$items
=
$this
->
getItemSharedWithUser
(
$itemSource
,
$itemType
,
$recipient
);
$filename
=
trim
(
$items
[
0
][
'file_target'
],
'/'
);
$subject
=
(
string
)
$this
->
l
->
t
(
'%s shared »%s« with you'
,
array
(
$this
->
senderDisplayName
,
$filename
));
$expiration
=
null
;
if
(
isset
(
$items
[
0
][
'expiration'
]))
{
try
{
$date
=
new
DateTime
(
$items
[
0
][
'expiration'
]);
$expiration
=
$date
->
getTimestamp
();
}
catch
(
\Exception
$e
)
{
$this
->
logger
->
error
(
"Couldn't read date: "
.
$e
->
getMessage
(),
[
'app'
=>
'sharing'
]);
}
}
$link
=
$this
->
urlGenerator
->
linkToRouteAbsolute
(
'files.viewcontroller.showFile'
,
[
'fileId'
=>
$items
[
0
][
'item_source'
]]
);
list
(
$htmlBody
,
$textBody
)
=
$this
->
createMailBody
(
$filename
,
$link
,
$expiration
,
'internal'
);
// send it out now
try
{
$message
=
$this
->
mailer
->
createMessage
();
$message
->
setSubject
(
$subject
);
$message
->
setTo
([
$to
=>
$recipientDisplayName
]);
$message
->
setHtmlBody
(
$htmlBody
);
$message
->
setPlainBody
(
$textBody
);
$message
->
setFrom
([
Util
::
getDefaultEmailAddress
(
'sharing-noreply'
)
=>
(
string
)
$this
->
l
->
t
(
'%s via %s'
,
[
$this
->
senderDisplayName
,
$this
->
defaults
->
getName
()
]),
]);
if
(
!
is_null
(
$this
->
replyTo
))
{
$message
->
setReplyTo
([
$this
->
replyTo
]);
}
$this
->
mailer
->
send
(
$message
);
}
catch
(
\Exception
$e
)
{
$this
->
logger
->
error
(
"Can't send mail to inform the user about an internal share: "
.
$e
->
getMessage
(),
[
'app'
=>
'sharing'
]);
$noMail
[]
=
$recipientDisplayName
;
}
}
return
$noMail
;
}
/**
* inform recipient about public link share
*
...
...
@@ -224,15 +155,4 @@ class MailNotifications {
return
[
$htmlMail
,
$plainTextMail
];
}
/**
* @param string $itemSource
* @param string $itemType
* @param IUser $recipient
* @return array
*/
protected
function
getItemSharedWithUser
(
$itemSource
,
$itemType
,
$recipient
)
{
return
Share
::
getItemSharedWithUser
(
$itemType
,
$itemSource
,
$recipient
->
getUID
());
}
}
This diff is collapsed.
Click to expand it.
tests/lib/Share/MailNotificationsTest.php
+
0
−
48
View file @
b7046d39
...
...
@@ -208,54 +208,6 @@ class MailNotificationsTest extends \Test\TestCase {
$this
->
assertSame
([
'lukas@owncloud.com'
],
$mailNotifications
->
sendLinkShareMail
(
'lukas@owncloud.com'
,
'MyFile'
,
'https://owncloud.com/file/?foo=bar'
,
3600
));
}
public
function
testSendInternalShareMail
()
{
$this
->
setupMailerMock
(
'TestUser shared »welcome.txt« with you'
,
[
'recipient@owncloud.com'
=>
'Recipient'
],
false
);
/** @var MailNotifications | \PHPUnit_Framework_MockObject_MockObject $mailNotifications */
$mailNotifications
=
$this
->
getMockBuilder
(
MailNotifications
::
class
)
->
setMethods
([
'getItemSharedWithUser'
])
->
setConstructorArgs
([
$this
->
user
,
$this
->
l10n
,
$this
->
mailer
,
$this
->
logger
,
$this
->
defaults
,
$this
->
urlGenerator
])
->
getMock
();
$mailNotifications
->
method
(
'getItemSharedWithUser'
)
->
withAnyParameters
()
->
willReturn
([
[
'file_target'
=>
'/welcome.txt'
,
'item_source'
=>
123
],
]);
$recipient
=
$this
->
getMockBuilder
(
'\OCP\IUser'
)
->
disableOriginalConstructor
()
->
getMock
();
$recipient
->
expects
(
$this
->
once
())
->
method
(
'getEMailAddress'
)
->
willReturn
(
'recipient@owncloud.com'
);
$recipient
->
expects
(
$this
->
once
())
->
method
(
'getDisplayName'
)
->
willReturn
(
'Recipient'
);
$this
->
urlGenerator
->
expects
(
$this
->
once
())
->
method
(
'linkToRouteAbsolute'
)
->
with
(
$this
->
equalTo
(
'files.viewcontroller.showFile'
),
$this
->
equalTo
([
'fileId'
=>
123
,
])
);
$recipientList
=
[
$recipient
];
$result
=
$mailNotifications
->
sendInternalShareMail
(
$recipientList
,
'3'
,
'file'
);
$this
->
assertSame
([],
$result
);
}
/**
* @param string $subject
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment