Fix for #660
Campaign preview and campaign test send pulls the first entry in the RSS feed and substitutes its data in `[RSS_ENTRY_*]`
This commit is contained in:
parent
588cf34810
commit
8cb24feca1
11 changed files with 262 additions and 57 deletions
|
@ -10,7 +10,7 @@ import {getCampaignLabels} from './helpers';
|
|||
import {Table} from "../lib/table";
|
||||
import {Button, Icon, ModalDialog} from "../lib/bootstrap-components";
|
||||
import axios from "../lib/axios";
|
||||
import {getPublicUrl, getUrl} from "../lib/urls";
|
||||
import {getPublicUrl, getSandboxUrl, getUrl} from "../lib/urls";
|
||||
import interoperableErrors from '../../../shared/interoperable-errors';
|
||||
import {CampaignStatus, CampaignType} from "../../../shared/campaigns";
|
||||
import moment from 'moment-timezone';
|
||||
|
@ -58,10 +58,29 @@ class PreviewForTestUserModalDialog extends Component {
|
|||
|
||||
async previewAsync() {
|
||||
if (this.isFormWithoutErrors()) {
|
||||
const campaignCid = this.props.entity.cid;
|
||||
const entity = this.props.entity;
|
||||
const campaignCid = entity.cid;
|
||||
const [listCid, subscriptionCid] = this.getFormValue('testUser').split(':');
|
||||
|
||||
window.open(getPublicUrl(`archive/${campaignCid}/${listCid}/${subscriptionCid}`, {withLocale: true}), '_blank');
|
||||
if (entity.type === CampaignType.RSS) {
|
||||
const result = await axios.post(getUrl('rest/restricted-access-token'), {
|
||||
method: 'rssPreview',
|
||||
params: {
|
||||
campaignCid,
|
||||
listCid
|
||||
}
|
||||
});
|
||||
|
||||
const accessToken = result.data;
|
||||
window.open(getSandboxUrl(`campaigns/rss-preview/${campaignCid}/${listCid}/${subscriptionCid}`, accessToken, {withLocale: true}), '_blank');
|
||||
|
||||
} else if (entity.type === CampaignType.REGULAR) {
|
||||
window.open(getPublicUrl(`archive/${campaignCid}/${listCid}/${subscriptionCid}`, {withLocale: true}), '_blank');
|
||||
|
||||
} else {
|
||||
throw new Error('Preview not supported');
|
||||
}
|
||||
|
||||
} else {
|
||||
this.showFormValidation();
|
||||
}
|
||||
|
|
|
@ -15,9 +15,15 @@ function getTrustedUrl(path) {
|
|||
return mailtrainConfig.trustedUrlBase + (path || '');
|
||||
}
|
||||
|
||||
function getSandboxUrl(path, customRestrictedAccessToken) {
|
||||
function getSandboxUrl(path, customRestrictedAccessToken, opts) {
|
||||
const localRestrictedAccessToken = customRestrictedAccessToken || restrictedAccessToken;
|
||||
return mailtrainConfig.sandboxUrlBase + localRestrictedAccessToken + '/' + (path || '');
|
||||
const url = new URL(localRestrictedAccessToken + '/' + (path || ''), mailtrainConfig.sandboxUrlBase);
|
||||
|
||||
if (opts && opts.withLocale) {
|
||||
url.searchParams.append('locale', i18n.language);
|
||||
}
|
||||
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
function getPublicUrl(path, opts) {
|
||||
|
|
|
@ -683,6 +683,14 @@ export function getEditForm(owner, typeKey, prefix = '') {
|
|||
<Trans i18nKey="rssEntryImageUrl">RSS entry image URL</Trans>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
{tg('RSS_ENTRY_CUSTOM_TAGS')}
|
||||
</th>
|
||||
<td>
|
||||
<Trans>Mailtrain custom tags. The custom tags can be passed in via <code>mt:entries-json</code> element in RSS entry. The text contents of the elements is interpreted as JSON-formatted object..</Trans>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue