2023-02-12 02:23:30 +01:00
import { Entity } from "@calckey/megalodon" ;
2023-02-18 20:58:02 +01:00
import { fetchMeta } from "@/misc/fetch-meta.js" ;
2023-02-22 09:44:47 +01:00
import { Users , Notes } from "@/models/index.js" ;
import { IsNull , MoreThan } from "typeorm" ;
2023-02-18 20:58:02 +01:00
2023-02-09 23:21:50 +01:00
// TODO: add calckey features
2023-02-18 20:58:02 +01:00
export async function getInstance ( response : Entity.Instance ) {
const meta = await fetchMeta ( true ) ;
2023-02-22 09:44:47 +01:00
const totalUsers = Users . count ( { where : { host : IsNull ( ) } } ) ;
const totalStatuses = Notes . count ( { where : { userHost : IsNull ( ) } } ) ;
2023-02-09 23:21:50 +01:00
return {
uri : response.uri ,
2023-02-28 17:23:04 +01:00
title : response.title || "Calckey" ,
short_description : response.description.substring ( 0 , 50 ) || "See real server website" ,
description : response.description || "This is a vanilla Calckey Instance. It doesnt seem to have a description. BTW you are using the Mastodon api to access this server :)" ,
2023-02-09 23:21:50 +01:00
email : response.email || "" ,
2023-02-28 17:23:04 +01:00
version : "3.0.0 compatible (3.5+ Calckey)" , //I hope this version string is correct, we will need to test it.
2023-02-09 23:21:50 +01:00
urls : response.urls ,
2023-02-22 09:44:47 +01:00
stats : {
2023-02-23 16:12:53 +01:00
user_count : ( await totalUsers ) ,
status_count : ( await totalStatuses ) ,
2023-02-22 09:44:47 +01:00
domain_count : response.stats.domain_count
} ,
2023-02-28 17:23:04 +01:00
thumbnail : response.thumbnail || 'https://http.cat/404' ,
2023-02-18 20:58:02 +01:00
languages : meta.langs ,
registrations : ! meta . disableRegistration || response . registrations ,
2023-02-09 23:21:50 +01:00
approval_required : ! response . registrations ,
invites_enabled : response.registrations ,
configuration : {
accounts : {
max_featured_tags : 20 ,
} ,
statuses : {
max_characters : 3000 ,
max_media_attachments : 4 ,
characters_reserved_per_url : response.uri.length ,
} ,
media_attachments : {
supported_mime_types : [
"image/jpeg" ,
"image/png" ,
"image/gif" ,
"image/heic" ,
"image/heif" ,
"image/webp" ,
"image/avif" ,
"video/webm" ,
"video/mp4" ,
"video/quicktime" ,
"video/ogg" ,
"audio/wave" ,
"audio/wav" ,
"audio/x-wav" ,
"audio/x-pn-wave" ,
"audio/vnd.wave" ,
"audio/ogg" ,
"audio/vorbis" ,
"audio/mpeg" ,
"audio/mp3" ,
"audio/webm" ,
"audio/flac" ,
"audio/aac" ,
"audio/m4a" ,
"audio/x-m4a" ,
"audio/mp4" ,
"audio/3gpp" ,
"video/x-ms-asf" ,
] ,
image_size_limit : 10485760 ,
image_matrix_limit : 16777216 ,
video_size_limit : 41943040 ,
video_frame_rate_limit : 60 ,
video_matrix_limit : 2304000 ,
} ,
polls : {
max_options : 8 ,
max_characters_per_option : 50 ,
min_expiration : 300 ,
max_expiration : 2629746 ,
} ,
} ,
contact_account : {
id : "1" ,
username : "admin" ,
acct : "admin" ,
display_name : "admin" ,
locked : true ,
bot : true ,
discoverable : false ,
group : false ,
2023-02-23 16:32:21 +01:00
created_at : new Date ( ) . toISOString ( ) ,
2023-02-23 16:42:57 +01:00
note : "<p>Please refer to the original instance for the actual admin contact.</p>" ,
url : ` ${ response . uri } / ` ,
avatar : ` ${ response . uri } /static-assets/badges/info.png ` ,
avatar_static : ` ${ response . uri } /static-assets/badges/info.png ` ,
2023-02-09 23:21:50 +01:00
header : "https://http.cat/404" ,
header_static : "https://http.cat/404" ,
followers_count : - 1 ,
following_count : 0 ,
statuses_count : 0 ,
2023-02-23 16:32:21 +01:00
last_status_at : new Date ( ) . toISOString ( ) ,
2023-02-09 23:21:50 +01:00
noindex : true ,
emojis : [ ] ,
fields : [ ] ,
} ,
rules : [ ] ,
} ;
}