Skip to content

Commit

Permalink
Merge pull request #7080 from RocketChat/email-setting-migration
Browse files Browse the repository at this point in the history
[NEW] Migration to add <html> tags to email header and footer
  • Loading branch information
engelgabriel authored May 25, 2017
2 parents 2fc4fd6 + 2f234f6 commit 8d968bb
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions server/startup/migrations/v095.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
RocketChat.Migrations.add({
version: 95,
up() {
if (RocketChat && RocketChat.models && RocketChat.models.Settings) {
const emailHeader = RocketChat.models.Settings.findOne({ _id: 'Email_Header' });
const emailFooter = RocketChat.models.Settings.findOne({ _id: 'Email_Footer' });
const startWithHTML = emailHeader.value.match(/^<html>/);
const endsWithHTML = emailFooter.value.match(/<\/hmtl>$/);

if (!startWithHTML) {
RocketChat.models.Settings.update(
{ _id: 'Email_Header' },
{ $set: { value: `<html>${ emailHeader.value }`} }
);
}

if (!endsWithHTML) {
RocketChat.models.Settings.update(
{ _id: 'Email_Footer' },
{ $set: { value: `${ emailFooter.value }</hmtl>`} }
);
}
}
}
});

0 comments on commit 8d968bb

Please sign in to comment.