File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,26 @@ module.exports = {
107
107
}
108
108
109
109
console . log ( vurl , vwidth , vheight ) ;
110
- const embeddableUrl = `${ EMBED_PROXY_URL } /?src=${ encodeURIComponent ( vurl ) } &width=${ vwidth } &height=${ vheight } ` ;
110
+ let embeddableUrl = '' ;
111
+
112
+ const v2Check = await fetch ( `${ EMBED_PROXY_URL } /v2/healthz` ) ;
113
+ if ( v2Check . ok ) {
114
+ const v2Res = await fetch ( `${ EMBED_PROXY_URL } /v2/add` , {
115
+ method : 'POST' ,
116
+ headers : {
117
+ 'Content-Type' : 'application/json' ,
118
+ } ,
119
+ body : JSON . stringify ( {
120
+ src : vurl ,
121
+ width : vwidth ,
122
+ height : vheight ,
123
+ } ) ,
124
+ } ) ;
125
+ const v2Json = await v2Res . json ( ) ;
126
+ embeddableUrl = `${ EMBED_PROXY_URL } /v2/~/${ v2Json . slug } ` ;
127
+ } else {
128
+ embeddableUrl = `${ EMBED_PROXY_URL } /?src=${ encodeURIComponent ( vurl ) } &width=${ vwidth } &height=${ vheight } ` ;
129
+ }
111
130
await replyMsg . edit ( `Done ${ embeddableUrl } ` ) ;
112
131
} ,
113
132
} ;
You can’t perform that action at this time.
0 commit comments