2023-04-20 22:08:38 +02:00
|
|
|
/*
|
2023-04-19 18:06:08 +02:00
|
|
|
var TransSchemas = {
|
|
|
|
Mastodon: {
|
|
|
|
Account: {
|
|
|
|
"__": "Author",
|
|
|
|
"url": "Url",
|
2023-04-20 00:19:19 +02:00
|
|
|
"avatar": "Picture",
|
|
|
|
"header": "Banner",
|
|
|
|
},
|
|
|
|
Instance: {
|
|
|
|
"thumbnail": "Banner",
|
2023-04-19 18:06:08 +02:00
|
|
|
},
|
|
|
|
Status: {
|
|
|
|
"__": "Note",
|
|
|
|
"account": {"__": "Account"},
|
|
|
|
"content": "Content",
|
|
|
|
"created_at": "Time",
|
|
|
|
"url": "Url",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2023-04-20 22:08:38 +02:00
|
|
|
*/
|
2023-04-20 18:13:47 +02:00
|
|
|
|
|
|
|
var ApiSchema = {
|
2023-04-23 19:46:01 +02:00
|
|
|
__All__: {
|
|
|
|
SourceInstance: {
|
|
|
|
__Eval__: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Note: {
|
2023-04-22 17:09:59 +02:00
|
|
|
Content: {
|
|
|
|
Mastodon: "content",
|
|
|
|
Misskey: "text",
|
|
|
|
},
|
|
|
|
Profile: {
|
|
|
|
Mastodon: "account",
|
|
|
|
Misskey: "user",
|
|
|
|
},
|
2023-04-23 00:48:14 +02:00
|
|
|
Quoting: {
|
|
|
|
Mastodon: "reblog",
|
|
|
|
},
|
2023-04-22 17:09:59 +02:00
|
|
|
Time: {
|
|
|
|
Mastodon: "created_at",
|
|
|
|
Misskey: "createdAt",
|
|
|
|
},
|
|
|
|
Url: {
|
|
|
|
Mastodon: "url",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Profile: {
|
|
|
|
Avatar: {}, // would "Character" be better?
|
2023-04-20 18:13:47 +02:00
|
|
|
Banner: {
|
|
|
|
Mastodon: "header",
|
2023-04-20 22:08:38 +02:00
|
|
|
Misskey: "bannerUrl",
|
|
|
|
},
|
|
|
|
Description: {
|
|
|
|
Mastodon: "note",
|
|
|
|
Misskey: "description",
|
2023-04-20 18:13:47 +02:00
|
|
|
},
|
|
|
|
Icon: {
|
|
|
|
Mastodon: "avatar",
|
2023-04-20 22:08:38 +02:00
|
|
|
Misskey: "avatarUrl",
|
2023-04-20 15:17:00 +02:00
|
|
|
},
|
2023-04-20 18:13:47 +02:00
|
|
|
Name: {
|
|
|
|
Mastodon: "display_name",
|
2023-04-20 22:08:38 +02:00
|
|
|
Misskey: "name",
|
2023-04-20 15:17:00 +02:00
|
|
|
},
|
2023-04-23 00:48:14 +02:00
|
|
|
Type: { // user, bot, channel, group
|
2023-04-23 19:46:01 +02:00
|
|
|
Mastodon: {__EvalSet__: `
|
|
|
|
if (TreeOld.bot) 'Bot';
|
|
|
|
else
|
|
|
|
if (TreeOld.group) 'Group';
|
2023-04-23 00:48:14 +02:00
|
|
|
`},
|
|
|
|
},
|
2023-04-20 18:13:47 +02:00
|
|
|
Url: {
|
|
|
|
Mastodon: "url",
|
2023-04-20 00:19:19 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2023-04-19 18:06:08 +02:00
|
|
|
|
2023-04-23 00:48:14 +02:00
|
|
|
function ApiTransform(Data, FromSource, DestType) {
|
|
|
|
return JsonTransformB(Data, ApiSchema, ApiSchema[DestType], FromSource);
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2023-04-19 18:06:08 +02:00
|
|
|
var TransParsers = {
|
|
|
|
Mastodon: {
|
|
|
|
Account(Data) {
|
2023-04-22 10:06:31 +02:00
|
|
|
//return JsonTransformA(Data, TransSchemas.Mastodon.Author, TransSchemas.Mastodon);
|
2023-04-22 17:09:59 +02:00
|
|
|
return JsonTransformB(Data, ApiSchema, ApiSchema.Profile, 'Mastodon');
|
2023-04-20 00:19:19 +02:00
|
|
|
},
|
|
|
|
Instance(Data) {
|
|
|
|
return JsonTransformA(Data, TransSchemas.Mastodon.Instance, TransSchemas.Mastodon);
|
2023-04-19 18:06:08 +02:00
|
|
|
},
|
|
|
|
Status(Data) {
|
2023-04-20 18:13:47 +02:00
|
|
|
//return JsonTransformA(Data, TransSchemas.Mastodon.Status, TransSchemas.Mastodon);
|
|
|
|
return JsonTransformB(Data, ApiSchema, ApiSchema.Note, 'Mastodon');
|
2023-04-19 18:06:08 +02:00
|
|
|
},
|
|
|
|
},
|
2023-04-20 22:08:38 +02:00
|
|
|
Misskey: {
|
|
|
|
},
|
2023-04-19 18:06:08 +02:00
|
|
|
};
|
2023-04-23 00:48:14 +02:00
|
|
|
*/
|