Friendiiverse/Source/ApiTransform.js

86 lines
1.5 KiB
JavaScript
Raw Normal View History

2023-04-20 22:08:38 +02:00
/*
var TransSchemas = {
Mastodon: {
Account: {
"__": "Author",
"url": "Url",
2023-04-20 00:19:19 +02:00
"avatar": "Picture",
"header": "Banner",
},
Instance: {
"thumbnail": "Banner",
},
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-22 17:09:59 +02:00
Note: { // TODO: Figure out renotes
Content: {
Mastodon: "content",
Misskey: "text",
},
Profile: {
Mastodon: "account",
Misskey: "user",
},
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-22 17:09:59 +02:00
Type: {}, // user, bot, channel, group
2023-04-20 18:13:47 +02:00
Url: {
Mastodon: "url",
2023-04-20 00:19:19 +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
},
2023-04-22 10:06:31 +02:00
/*
2023-04-20 00:19:19 +02:00
Instance(Data) {
return JsonTransformA(Data, TransSchemas.Mastodon.Instance, TransSchemas.Mastodon);
},
2023-04-20 22:08:38 +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-20 22:08:38 +02:00
Misskey: {
},
};