1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-11 00:20:54 +00:00
* Changed: Show the verified badge on rich chat embeds for Twitch partner channels.
* API Added: More flexible support for tokens when building chat embeds.
* API Added: Experiment for using the API to look-up links, rather than the socket cluster.
This commit is contained in:
SirStendec 2020-07-26 21:26:42 -04:00
parent a4fa1d1491
commit 05e8428a4a
7 changed files with 96 additions and 12 deletions

View file

@ -1,6 +1,7 @@
<script>
import {has, timeout} from 'utilities/object';
import {ALLOWED_ATTRIBUTES, ALLOWED_TAGS} from 'utilities/constants';
const ERROR_IMAGE = 'https://static-cdn.jtvnw.net/emoticons/v1/58765/2.0';
@ -95,9 +96,34 @@ export default {
else if ( typeof token !== 'object' )
out.push(token);
else {
const el = h(token.tag || 'span', {
else if ( token.type === 't') {
const content = {};
if ( token.content )
for(const [key,val] of Object.entries(token.content))
content[key] = this.renderTokens(val, h);
out = out.concat(this.tList(token.key, token.phrase, content));
} else {
const tag = token.tag || 'span';
if ( ! ALLOWED_TAGS.includes(tag) ) {
console.log('Skipping disallowed tag', tag);
continue;
}
const attrs = {};
if ( token.attrs ) {
for(const [key,val] of Object.entries(token.attrs)) {
if ( ! ALLOWED_ATTRIBUTES.includes(key) && ! key.startsWith('data-') )
console.log('Skipping disallowed attribute', key);
else
attrs[key] = val;
}
}
const el = h(tag, {
class: token.class,
attrs
}, this.renderTokens(token.content, h));
out.push(el);

View file

@ -1536,10 +1536,15 @@ export default class Chat extends Module {
cbs[success ? 0 : 1](data);
}
if ( this.experiments.getAssignment('api_links') )
timeout(fetch(`https://api-test.frankerfacez.com/v2/link?url=${encodeURIComponent(url)}`).then(r => r.json()), 15000)
.then(data => handle(true, data))
.catch(err => handle(false, err));
timeout(this.socket.call('get_link', url), 15000)
.then(data => handle(true, data))
.catch(err => handle(false, err));
else
timeout(this.socket.call('get_link', url), 15000)
.then(data => handle(true, data))
.catch(err => handle(false, err));
});
}
}

View file

@ -143,6 +143,16 @@ export const Users = {
];
}
if ( user.roles?.isPartner ) {
if ( ! title_tokens )
title_tokens = [title];
title_tokens = {tag: 'div', class: 'tw-flex tw-align-items-center', content: [
{tag: 'div', content: title_tokens},
{tag: 'figure', class: 'tw-mg-l-05 ffz-i-verified tw-c-text-link', content: []}
]};
}
return {
url: token.url,
accent: user.primaryColorHex ? `#${user.primaryColorHex}` : null,