diff --git a/src/embed/status.ts b/src/embed/status.ts
index 22dcc08..9e40fff 100644
--- a/src/embed/status.ts
+++ b/src/embed/status.ts
@@ -102,6 +102,7 @@ export const handleStatus = async (
let useIV =
isTelegram /*&& !tweet.possibly_sensitive*/ &&
!flags?.direct &&
+ !flags?.gallery &&
!flags?.api &&
(tweet.media?.photos?.[0] || // Force instant view for photos for now https://bugs.telegram.org/c/33679
tweet.media?.mosaic ||
@@ -402,15 +403,19 @@ export const handleStatus = async (
/* Push basic headers relating to author, Tweet text, and site name */
headers.push(
- ``,
``
);
if (!flags.gallery) {
headers.push(
+ ``,
``,
``,
);
+ } else {
+ headers.push(
+ ``
+ )
}
/* Special reply handling if authorText is not overriden */
@@ -431,10 +436,10 @@ export const handleStatus = async (
``.format(
{
base: Constants.HOST_URL,
- text: encodeURIComponent(truncateWithEllipsis(authorText, 255)),
+ text: flags.gallery ? tweet.author.name : encodeURIComponent(truncateWithEllipsis(authorText, 255)),
deprecatedFlag: flags?.deprecated ? '&deprecated=true' : '',
status: encodeURIComponent(status),
- author: encodeURIComponent(tweet.author?.screen_name || ''),
+ author: encodeURIComponent(tweet.author.screen_name || ''),
name: tweet.author.name || ''
}
)
diff --git a/src/realms/twitter/router.ts b/src/realms/twitter/router.ts
index de22204..a4014aa 100644
--- a/src/realms/twitter/router.ts
+++ b/src/realms/twitter/router.ts
@@ -98,6 +98,7 @@ twitter.get(
twitter.get('/version/', versionRoute);
twitter.get('/version', versionRoute);
twitter.get('/set_base_redirect', setRedirectRequest);
+/* Yes, I actually made the endpoint /owoembed. Deal with it. */
twitter.get('/owoembed', oembed);
twitter.get('/robots.txt', async c => c.text(Strings.ROBOTS_TXT));
diff --git a/src/realms/twitter/routes/oembed.ts b/src/realms/twitter/routes/oembed.ts
index 3285d42..fe3aa9b 100644
--- a/src/realms/twitter/routes/oembed.ts
+++ b/src/realms/twitter/routes/oembed.ts
@@ -3,20 +3,19 @@ import motd from '../../../../motd.json';
import { Constants } from '../../../constants';
import { Strings } from '../../../strings';
-/* Yes, I actually made the endpoint /owoembed. Deal with it. */
export const oembed = async (c: Context) => {
console.log('oembed hit!');
const { searchParams } = new URL(c.req.url);
/* Fallbacks */
- const text = searchParams.get('text') || 'Twitter';
- const author = searchParams.get('author') || 'jack';
- const status = searchParams.get('status') || '20';
+ const text = searchParams.get('text') ?? 'Twitter';
+ const author = searchParams.get('author') ?? 'jack';
+ const status = searchParams.get('status') ?? '20';
const random = Math.floor(Math.random() * Object.keys(motd).length);
const [name, url] = Object.entries(motd)[random];
- const test = {
+ const data: OEmbed = {
author_name: text,
author_url: `${Constants.TWITTER_ROOT}/${encodeURIComponent(author)}/status/${status}`,
/* Change provider name if tweet is on deprecated domain. */
@@ -27,8 +26,9 @@ export const oembed = async (c: Context) => {
type: 'link',
version: '1.0'
};
+
c.header('content-type', 'application/json');
c.status(200);
/* Stringify and send it on its way! */
- return c.text(JSON.stringify(test));
+ return c.text(JSON.stringify(data));
};
diff --git a/src/types/types.d.ts b/src/types/types.d.ts
index 17a5d8e..61360cb 100644
--- a/src/types/types.d.ts
+++ b/src/types/types.d.ts
@@ -197,3 +197,13 @@ interface SocialThread {
interface FetchResults {
status: number;
}
+
+interface OEmbed {
+ author_name?: string;
+ author_url?: string;
+ provider_name?: string;
+ provider_url?: string;
+ title?: string | null;
+ type: 'link';
+ version: '1.0';
+}
\ No newline at end of file