From fe6ffc9bc5785aaf7f6a12f908fe7aaca0397955 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 23 Feb 2022 22:43:38 -0500 Subject: [PATCH] normalizeInstance(): add fixtures and tests for Fedibird, Mitra --- .../__fixtures__/fedibird-instance.json | 185 ++++++++++++++++++ app/soapbox/__fixtures__/mitra-instance.json | 13 ++ .../normalizers/__tests__/instance-test.js | 20 ++ 3 files changed, 218 insertions(+) create mode 100644 app/soapbox/__fixtures__/fedibird-instance.json create mode 100644 app/soapbox/__fixtures__/mitra-instance.json diff --git a/app/soapbox/__fixtures__/fedibird-instance.json b/app/soapbox/__fixtures__/fedibird-instance.json new file mode 100644 index 000000000..31e17e34e --- /dev/null +++ b/app/soapbox/__fixtures__/fedibird-instance.json @@ -0,0 +1,185 @@ +{ + "uri": "fedibird.com", + "title": "Fedibird", + "short_description": "多くの独自機能を備えた、連合志向の汎用Mastodonサーバです。Fediverseの活動拠点としてご利用ください。", + "description": "多くの独自機能を備えた、連合志向の汎用Mastodonサーバです。Fediverseの活動拠点としてご利用ください。", + "email": "support@fedibird.com", + "version": "3.4.1", + "urls": { + "streaming_api": "wss://fedibird.com" + }, + "stats": { + "user_count": 1964, + "status_count": 4590304, + "domain_count": 9024 + }, + "thumbnail": "https://s3.fedibird.com/site_uploads/files/000/000/001/original/fedibird_hero_image.png", + "languages": [ + "ja" + ], + "registrations": true, + "approval_required": false, + "invites_enabled": true, + "configuration": { + "statuses": { + "max_characters": 500, + "max_media_attachments": 4, + "characters_reserved_per_url": 23, + "min_expiration": 60, + "max_expiration": 37152000, + "supported_expires_actions": [ + "delete", + "mark" + ] + }, + "media_attachments": { + "supported_mime_types": [ + "image/jpeg", + "image/png", + "image/gif", + "image/webp", + "image/heif", + "image/heic", + "video/webm", + "video/mp4", + "video/quicktime", + "video/ogg", + "audio/wave", + "audio/wav", + "audio/x-wav", + "audio/x-pn-wave", + "audio/ogg", + "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": 4, + "max_characters_per_option": 50, + "min_expiration": 300, + "max_expiration": 2629746 + }, + "emoji_reactions": { + "max_reactions": 20 + } + }, + "feature_quote": true, + "fedibird_capabilities": [ + "favourite_hashtag", + "favourite_domain", + "favourite_list", + "status_expire", + "follow_no_delivery", + "follow_hashtag", + "subscribe_account", + "subscribe_domain", + "subscribe_keyword", + "timeline_home_visibility", + "timeline_no_local", + "timeline_domain", + "timeline_group", + "timeline_group_directory", + "visibility_mutual", + "visibility_limited", + "emoji_reaction", + "misskey_birthday", + "misskey_location" + ], + "contact_account": { + "id": "1", + "username": "noellabo", + "acct": "noellabo", + "display_name": "のえる", + "locked": false, + "bot": false, + "cat": false, + "discoverable": true, + "group": false, + "created_at": "2019-08-15T00:00:00.000Z", + "note": "

主に、Fediverseへの関心に基づいた投稿を行うアカウントです。DTP・印刷に関する話をしたり、同人の話をしたり、カレーをブーストしたりします。

Mastodonサーバ『Fedibird』の管理者アカウントでもあります。ご連絡は当アカウントへ、サーバインフォメーションについては https://fedibird.com/about/more@info を参照してください。

", + "url": "https://fedibird.com/@noellabo", + "avatar": "https://s3.fedibird.com/accounts/avatars/000/000/001/original/6ef3b7f18f726755.png", + "avatar_static": "https://s3.fedibird.com/accounts/avatars/000/000/001/original/6ef3b7f18f726755.png", + "header": "https://s3.fedibird.com/accounts/headers/000/000/001/original/6a5a51722c094835.jpg", + "header_static": "https://s3.fedibird.com/accounts/headers/000/000/001/original/6a5a51722c094835.jpg", + "followers_count": 1560, + "following_count": 758, + "subscribing_count": 121, + "statuses_count": 61325, + "last_status_at": "2022-02-24", + "emojis": [ + { + "shortcode": "liberapay", + "url": "https://s3.fedibird.com/custom_emojis/images/000/025/634/original/5b8620742973f844.png", + "static_url": "https://s3.fedibird.com/custom_emojis/images/000/025/634/static/5b8620742973f844.png", + "visible_in_picker": true + }, + { + "shortcode": "mastodon", + "url": "https://s3.fedibird.com/custom_emojis/images/000/008/396/original/1317b6f8efcf8318.png", + "static_url": "https://s3.fedibird.com/custom_emojis/images/000/008/396/static/1317b6f8efcf8318.png", + "visible_in_picker": true + } + ], + "fields": [ + { + "name": ":liberapay: Liberapay", + "value": "https://liberapay.com/noellabo", + "verified_at": "2020-10-22T03:04:43.206+00:00" + }, + { + "name": ":mastodon: DTP-Mstdn.jp", + "value": "https://dtp-mstdn.jp/@noellabo", + "verified_at": "2020-05-23T00:14:02.232+00:00" + }, + { + "name": "別宅", + "value": "https://gorone.xyz/@noellabo", + "verified_at": "2021-08-11T07:48:53.479+00:00" + }, + { + "name": "bluesky community", + "value": "https://mastodon.blueskycommunity.net/@noellabo", + "verified_at": "2021-11-13T04:28:30.593+00:00" + } + ], + "other_settings": { + "birthday": null, + "location": "埼玉県", + "cat_ears_color": "#d5c5c0", + "noindex": false, + "hide_network": false, + "hide_statuses_count": false, + "hide_following_count": false, + "hide_followers_count": false, + "enable_reaction": true + } + }, + "rules": [ + { + "id": "2", + "text": "日本の法律と社会規範に従った行動を心がけてください" + }, + { + "id": "3", + "text": "不快や脅威に対してはブロック・ミュート・フィルターで距離をとってください" + }, + { + "id": "1", + "text": "投稿する際は、適切な公開範囲・CW・閲覧注意を使用してください" + } + ] +} diff --git a/app/soapbox/__fixtures__/mitra-instance.json b/app/soapbox/__fixtures__/mitra-instance.json new file mode 100644 index 000000000..2c476ba30 --- /dev/null +++ b/app/soapbox/__fixtures__/mitra-instance.json @@ -0,0 +1,13 @@ +{ + "uri": "mitra.social", + "title": "Mitra", + "short_description": "Federated social network with smart contracts", + "description": "This is an instance of [Mitra](https://codeberg.org/silverpill/mitra), federated social network built on [ActivityPub](https://activitypub.rocks/) protocol.\nRegistration is invitation-only.\nAdmin:\n - [@silverpill@mitra.social](https://mitra.social/profile/dd4ebc18-269d-4c7b-a310-03d29c6ab551)\n - Matrix: @silverpill:poa.st\n", + "version": "3.0.0 (compatible; Mitra 0.4.0)", + "registrations": false, + "login_message": "Sign this message to log in to https://mitra.social. Do not sign this message on other sites!", + "post_character_limit": 5000, + "blockchain_explorer_url": null, + "blockchain_contract_address": null, + "ipfs_gateway_url": "https://ipfs.mitra.social" +} diff --git a/app/soapbox/normalizers/__tests__/instance-test.js b/app/soapbox/normalizers/__tests__/instance-test.js index 28eea3191..3496da046 100644 --- a/app/soapbox/normalizers/__tests__/instance-test.js +++ b/app/soapbox/normalizers/__tests__/instance-test.js @@ -98,4 +98,24 @@ describe('normalizeInstance()', () => { const result = normalizeInstance(instance); expect(result.toJS()).toMatchObject(expected); }); + + it('normalizes Fedibird instance', () => { + const instance = fromJS(require('soapbox/__fixtures__/fedibird-instance.json')); + const result = normalizeInstance(instance); + + // Sets description_limit + expect(result.get('description_limit')).toEqual(1500); + + // But otherwise, it's the same + expect(result.delete('description_limit')).toEqual(instance); + }); + + it('normalizes Mitra instance', () => { + const instance = fromJS(require('soapbox/__fixtures__/mitra-instance.json')); + const result = normalizeInstance(instance); + + // Adds configuration and description_limit + expect(result.get('configuration') instanceof ImmutableMap).toBe(true); + expect(result.get('description_limit')).toBe(1500); + }); });