Skip to content

Commit

Permalink
Merge pull request #12 from neos-love/develop
Browse files Browse the repository at this point in the history
13.3.4-neos-love.2
  • Loading branch information
rassi0429 authored Feb 6, 2023
2 parents cbac93d + 5e70fa7 commit 2dbbdfb
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "misskey",
"version": "13.3.4-neos-love.1",
"version": "13.3.4-neos-love.2",
"codename": "nasubi",
"repository": {
"type": "git",
Expand Down
6 changes: 3 additions & 3 deletions packages/backend/src/server/api/ApiServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,21 @@ export class ApiServerService {
reply.send();
return;
}

this.apiCallService.handleMultipartRequest(ep, request, reply);
});
} else {
fastify.all<{
Params: { endpoint: string; },
Body: Record<string, unknown>,
Querystring: Record<string, unknown>,
}>('/' + endpoint.name, { bodyLimit: 1024 * 1024 }, (request, reply) => {
}>('/' + endpoint.name, { bodyLimit: 1024 * 32 }, (request, reply) => {
if (request.method === 'GET' && !endpoint.meta.allowGet) {
reply.code(405);
reply.send();
return;
}

this.apiCallService.handleRequest(ep, request, reply);
});
}
Expand Down
72 changes: 72 additions & 0 deletions packages/frontend/src/components/MkUrlPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@
<div v-else-if="tweetId && tweetExpanded" ref="twitter" :class="$style.twitter">
<iframe ref="tweet" scrolling="no" frameborder="no" :style="{ position: 'relative', width: '100%', height: `${tweetHeight}px` }" :src="`https://platform.twitter.com/embed/index.html?embedId=${embedId}&amp;hideCard=false&amp;hideThread=false&amp;lang=en&amp;theme=${$store.state.darkMode ? 'dark' : 'light'}&amp;id=${tweetId}`"></iframe>
</div>
<div v-else-if="neosSessionId" :class="$style.twitter">
<div :class="[$style.link, { [$style.compact]: compact }]" rel="nofollow noopener" >
<article :class="$style.body">
<header :class="$style.header">
<h1 :class="$style.title">{{neosSessionData.name}}</h1>
<h1 :class="$style.text">{{neosSessionData.hostUserId}}</h1>
</header>
<div :class="$style.action">
<MkButton @click="copySessionUrl">{{neosButtonCopyText}}</MkButton>
<MkButton @click="openNeosLink">γ‚»γƒƒγ‚·γƒ§γƒ³ε‚εŠ </MkButton>
</div>
</article>
</div>
</div>
<div v-else :class="$style.urlPreview">
<component :is="self ? 'MkA' : 'a'" :class="[$style.link, { [$style.compact]: compact }]" :[attr]="self ? url.substr(local.length) : url" rel="nofollow noopener" :target="target" :title="url">
<div v-if="thumbnail" :class="$style.thumbnail" :style="`background-image: url('${thumbnail}')`">
Expand Down Expand Up @@ -52,6 +66,8 @@ import * as os from '@/os';
import { deviceKind } from '@/scripts/device-kind';
import MkButton from '@/components/MkButton.vue';
import { versatileLang } from '@/scripts/intl-const';
import MkMediaImage from "@/components/MkMediaImage.vue";
import copyToClipboard from "@/scripts/copy-to-clipboard";
const props = withDefaults(defineProps<{
url: string;
Expand All @@ -62,6 +78,19 @@ const props = withDefaults(defineProps<{
compact: false,
});
type neosSessionData = {
name: string | null,
hostUserId: string | null,
thumbnail: string | null
}
const defaultNeosSessionData = () => {
return {
name: null,
hostUserId: null,
thumbnail: null
}
}
const MOBILE_THRESHOLD = 500;
const isMobile = $ref(deviceKind === 'smartphone' || window.innerWidth <= MOBILE_THRESHOLD);
Expand All @@ -81,11 +110,17 @@ let player = $ref({
});
let playerEnabled = $ref(false);
let tweetId = $ref<string | null>(null);
let neosSessionId = $ref<string | null>(null);
let neosButtonCopyText = $ref<string>("ε‚εŠ γ‚³γƒΌγƒ‰γ‚’γ‚³γƒ”γƒΌ");
let neosSessionData = $ref<neosSessionData>(defaultNeosSessionData())
let neosWorldRecordId = $ref<string | null>(null);
let tweetExpanded = $ref(props.detail);
const embedId = `embed${Math.random().toString().replace(/\D/, '')}`;
let tweetHeight = $ref(150);
let unknownUrl = $ref(false);
const requestUrl = new URL(props.url);
if (!['http:', 'https:'].includes(requestUrl.protocol)) throw new Error('invalid url');
Expand All @@ -94,6 +129,43 @@ if (requestUrl.hostname === 'twitter.com' || requestUrl.hostname === 'mobile.twi
if (m) tweetId = m[1];
}
// neos customize
const openNeosLink = () => {
window.open("http://cloudx.azurewebsites.net/open/session/" + neosSessionId, '_blank');
}
const copySessionUrl = () => {
const result = copyToClipboard("https://util.kokoa.dev/v1/neos/join.json?url=neos-session:///" + neosSessionId)
if(result) {
neosButtonCopyText = "OK! Neosγ«θ²Όγ‚Šδ»˜γ‘γ¦γ­"
setTimeout(() => {
neosButtonCopyText = "ε‚εŠ γ‚³γƒΌγƒ‰γ‚’γ‚³γƒ”γƒΌ"
}, 2000)
}
}
// detect neos session url
if (requestUrl.hostname === 'cloudx.azurewebsites.net') {
const m = requestUrl.pathname.match(/^\/.+\/session\/(.+)/);
const w = requestUrl.pathname.match(/^\/.+\/world\/(.+)/);
if (m) neosSessionId = m[1];
if (w) neosWorldRecordId = w[1]
if(m) {
const data = await fetch("https://api.neos.com/api/sessions/" + m[1], {})
const json = await data.json()
if(data.status == 200) {
neosSessionData = {
name: json.name,
hostUserId: json.hostUserId,
thumbnail: json.thumbnail
}
} else {
neosSessionData.name = "(γŸγΆγ‚“)γƒ—γƒ©γ‚€γƒ™γƒΌγƒˆγ‚»γƒƒγ‚·γƒ§γƒ³"
}
}
}
if (requestUrl.hostname === 'music.youtube.com' && requestUrl.pathname.match('^/(?:watch|channel)')) {
requestUrl.hostname = 'www.youtube.com';
}
Expand Down

0 comments on commit 2dbbdfb

Please sign in to comment.