Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use https://zenuml.com/sequence-diagram in share link #606

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions firebase-functions/paddle-webhook/functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,21 @@ exports.sync_diagram = functions.https.onRequest(async (req, res) => {
console.log('decoded token:', decoded);
const user = {name: decoded.name, id: decoded.user_id, email: decoded.email, email_verified: decoded.email_verified, picture: decoded.picture};

const hostname = process.env.LARASITE_HOST || 'sequence-diagram.zenuml.com';
const baseUrlHttps = `https://${hostname}`;
const baseUrlHttp = `http://${hostname}`;
const publicBaseUrl = process.env.PUBLIC_LARASITE_BASE_URL || 'https://zenuml.com/sequence-diagram';
console.log('using publicBaseUrl:', publicBaseUrl);

const replaceBaseUrlInShareLink = (responseData) => {
const data = JSON.parse(responseData);
data.page_share = data.page_share.replace(baseUrlHttp, publicBaseUrl).replace(baseUrlHttps, publicBaseUrl);
return JSON.stringify(data);
}

const options = {
hostname: process.env.LARASITE_HOST || 'sequence-diagram.zenuml.com',
port: process.env.LARASITE_PORT || 443,
hostname,
port: 443,
path: '/diagrams',
method: 'POST',
headers: {
Expand All @@ -49,7 +61,7 @@ exports.sync_diagram = functions.https.onRequest(async (req, res) => {
});

response.on('end', () => {
res.send(responseData);
res.send(replaceBaseUrlInShareLink(responseData));
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/services/syncService.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import firebase from 'firebase/app';
async function syncDiagram(currentItem) {
const token = await firebase.auth().currentUser.getIdToken(true);

const data = { token, id: currentItem.id, name: currentItem.title, content: currentItem.js, description: JSON.stringify({ source: 'app.zenuml.com' }), imageBase64: currentItem.imageBase64 };
const data = { token, id: currentItem.id, name: currentItem.title, content: currentItem.js, description: 'Shared diagram from https://app.zenuml.com', imageBase64: currentItem.imageBase64 };
console.log('calling /sync-diagram with data:', data)

const result = await (await fetch('/sync-diagram', { method: 'POST', body: JSON.stringify(data), headers: { 'Content-Type': 'application/json' } })).json()
Expand Down