Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
734bd769
Unverified
Commit
734bd769
authored
8 months ago
by
Yash Rajpal
Committed by
GitHub
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
regression: Email notification for end-to-end encrypted message (#32694)
parent
a9f8c8e2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/meteor/app/lib/server/functions/notifications/email.js
+5
-5
5 additions, 5 deletions
apps/meteor/app/lib/server/functions/notifications/email.js
apps/meteor/tests/unit/app/mailer/getEmailContent.spec.ts
+95
-0
95 additions, 0 deletions
apps/meteor/tests/unit/app/mailer/getEmailContent.spec.ts
with
100 additions
and
5 deletions
apps/meteor/app/lib/server/functions/notifications/email.js
+
5
−
5
View file @
734bd769
...
...
@@ -21,7 +21,7 @@ Meteor.startup(() => {
});
});
async
function
getEmailContent
({
message
,
user
,
room
})
{
export
async
function
getEmailContent
({
message
,
user
,
room
})
{
const
lng
=
(
user
&&
user
.
language
)
||
settings
.
get
(
'
Language
'
)
||
'
en
'
;
const
roomName
=
escapeHTML
(
`#
${
await
roomCoordinator
.
getRoomName
(
room
.
t
,
room
)}
`
);
...
...
@@ -35,6 +35,10 @@ async function getEmailContent({ message, user, room }) {
lng
,
});
if
(
message
.
t
===
'
e2e
'
&&
!
message
.
file
)
{
return
settings
.
get
(
'
Email_notification_show_message
'
)
?
i18n
.
t
(
'
Encrypted_message_preview_unavailable
'
,
{
lng
})
:
header
;
}
if
(
message
.
msg
!==
''
)
{
if
(
!
settings
.
get
(
'
Email_notification_show_message
'
))
{
return
header
;
...
...
@@ -42,10 +46,6 @@ async function getEmailContent({ message, user, room }) {
let
messageContent
=
escapeHTML
(
message
.
msg
);
if
(
message
.
t
===
'
e2e
'
)
{
messageContent
=
i18n
.
t
(
'
Encrypted_message_preview_unavailable
'
,
{
lng
});
}
message
=
await
callbacks
.
run
(
'
renderMessage
'
,
message
);
if
(
message
.
tokens
&&
message
.
tokens
.
length
>
0
)
{
message
.
tokens
.
forEach
((
token
)
=>
{
...
...
This diff is collapsed.
Click to expand it.
apps/meteor/tests/unit/app/mailer/getEmailContent.spec.ts
0 → 100644
+
95
−
0
View file @
734bd769
/* eslint-disable @typescript-eslint/no-empty-function */
import
{
expect
}
from
'
chai
'
;
import
{
describe
,
it
}
from
'
mocha
'
;
import
proxyquire
from
'
proxyquire
'
;
const
mocks
=
{
'
@rocket.chat/string-helpers
'
:
{
escapeHTML
:
(
str
:
string
)
=>
str
,
},
'
meteor/meteor
'
:
{
Meteor
:
{
startup
:
()
=>
{},
},
},
'
../../../../../lib/callbacks
'
:
{
callbacks
:
{
run
:
()
=>
{},
},
},
'
../../../../../server/lib/i18n
'
:
{
i18n
:
{
t
:
(
trans
:
string
)
=>
trans
,
},
},
'
../../../../../server/lib/rooms/roomCoordinator
'
:
{
roomCoordinator
:
{
getRoomDirectives
:
()
=>
({
isGroupChat
:
()
=>
true
,
}),
getRoomName
:
()
=>
''
,
},
},
'
../../../../mailer/server/api
'
:
{
getTemplate
:
()
=>
{},
send
:
()
=>
{},
replace
:
()
=>
{},
},
'
../../../../settings/server
'
:
{
settings
:
{
get
:
()
=>
true
,
watch
:
()
=>
{},
},
},
'
../../../../metrics/server
'
:
{
metrics
:
{},
},
'
../../../../utils/server/getURL
'
:
{
getURL
:
()
=>
{},
},
};
const
message
=
{
u
:
{
name
:
'
rocket.cat
'
,
username
:
'
rocket.cat
'
,
},
};
const
room
=
{
fname
:
'
room
'
,
name
:
'
room
'
,
t
:
'
p
'
,
};
describe
(
'
getEmailContent
'
,
()
=>
{
it
(
'
should return preview string for encrypted message
'
,
async
()
=>
{
const
{
getEmailContent
}
=
proxyquire
.
noCallThru
().
load
(
'
../../../../app/lib/server/functions/notifications/email.js
'
,
mocks
);
const
result
=
await
getEmailContent
({
message
:
{
...
message
,
t
:
'
e2e
'
},
user
:
undefined
,
room
,
});
expect
(
result
).
to
.
be
.
equal
(
'
Encrypted_message_preview_unavailable
'
);
});
it
(
'
should return header for encrypted message if Email_notification_show_message is turned off
'
,
async
()
=>
{
const
{
getEmailContent
}
=
proxyquire
.
noCallThru
().
load
(
'
../../../../app/lib/server/functions/notifications/email.js
'
,
{
...
mocks
,
'
../../../../settings/server
'
:
{
settings
:
{
get
:
()
=>
false
,
watch
:
()
=>
{},
},
},
});
const
result
=
await
getEmailContent
({
message
:
{
...
message
,
t
:
'
e2e
'
},
user
:
undefined
,
room
,
});
expect
(
result
).
to
.
be
.
equal
(
'
User_sent_a_message_on_channel
'
);
});
});
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