diff --git a/app/soapbox/__fixtures__/mk.json b/app/soapbox/__fixtures__/mk.json
new file mode 100644
index 000000000..a7c841f1e
--- /dev/null
+++ b/app/soapbox/__fixtures__/mk.json
@@ -0,0 +1,123 @@
+{
+ "acct": "mk",
+ "avatar": "https://media.spinster.xyz/4043b9fb3f9d468aa48a8d68294f338914d9d54b2816aa1c789f548efe6c6239.jpg",
+ "avatar_static": "https://media.spinster.xyz/4043b9fb3f9d468aa48a8d68294f338914d9d54b2816aa1c789f548efe6c6239.jpg",
+ "bot": false,
+ "created_at": "2019-08-01T22:06:30.000Z",
+ "display_name": "M. K. Fain",
+ "emojis": [
+ {
+ "shortcode": "4w",
+ "static_url": "https://spinster.xyz/emoji/custom/4w.png",
+ "url": "https://spinster.xyz/emoji/custom/4w.png",
+ "visible_in_picker": false
+ },
+ {
+ "shortcode": "spinster",
+ "static_url": "https://spinster.xyz/emoji/custom/spinster.png",
+ "url": "https://spinster.xyz/emoji/custom/spinster.png",
+ "visible_in_picker": false
+ }
+ ],
+ "fields": [
+ {
+ "name": "Website",
+ "value": "https://marykatefain.com"
+ },
+ {
+ "name": "Twitter",
+ "value": "https://twitter.com/mkay_fain"
+ },
+ {
+ "name": "Patreon",
+ "value": "https://www.patreon.com/mkfain"
+ },
+ {
+ "name": "Paypal",
+ "value": "https://www.paypal.com/donate?hosted_button_id=NYXHYFQ6CRWJJ"
+ },
+ {
+ "name": "Facebook",
+ "value": "https://www.facebook.com/M-K-Fain-102559968375112"
+ },
+ {
+ "name": "Dog Pics",
+ "value": "https://www.instagram.com/mmkaayyy92"
+ },
+ {
+ "name": "$BTC",
+ "value": "bc1q7fp347muhnuxrtu0pft6eswn0e7pldhssdg8py"
+ }
+ ],
+ "followers_count": 5687,
+ "following_count": 18017,
+ "fqn": "mk@spinster.xyz",
+ "header": "https://media.spinster.xyz/3a5f9d5ef06940d0c319f8f0135b1153a8a42cefd10eace97378875c0347da71.png",
+ "header_static": "https://media.spinster.xyz/3a5f9d5ef06940d0c319f8f0135b1153a8a42cefd10eace97378875c0347da71.png",
+ "id": "9y4BZYXEDuQ6K1zW9g",
+ "last_status_at": "2022-02-27T01:58:21",
+ "locked": false,
+ "note": ":spinster: Admin of @spinster
:4w: Editor of @4WPub
Sorry I didn't reply to you.
Boost ≠ agree. All opinions my own.",
+ "pleroma": {
+ "accepts_chat_messages": true,
+ "also_known_as": [],
+ "ap_id": "https://spinster.xyz/users/mk",
+ "background_image": null,
+ "favicon": "https://spinster.xyz/favicon.png",
+ "hide_favorites": true,
+ "hide_followers": false,
+ "hide_followers_count": false,
+ "hide_follows": false,
+ "hide_follows_count": false,
+ "is_admin": true,
+ "is_confirmed": true,
+ "is_moderator": false,
+ "is_suggested": true,
+ "relationship": {},
+ "skip_thread_containment": false,
+ "tags": [
+ "verified"
+ ]
+ },
+ "source": {
+ "fields": [
+ {
+ "name": "Website",
+ "value": "https://marykatefain.com"
+ },
+ {
+ "name": "Twitter",
+ "value": "https://twitter.com/mkay_fain"
+ },
+ {
+ "name": "Patreon",
+ "value": "https://www.patreon.com/mkfain"
+ },
+ {
+ "name": "Paypal",
+ "value": "https://www.paypal.com/donate?hosted_button_id=NYXHYFQ6CRWJJ"
+ },
+ {
+ "name": "Facebook",
+ "value": "https://www.facebook.com/M-K-Fain-102559968375112"
+ },
+ {
+ "name": "Dog Pics",
+ "value": "https://www.instagram.com/mmkaayyy92"
+ },
+ {
+ "name": "$BTC",
+ "value": "bc1q7fp347muhnuxrtu0pft6eswn0e7pldhssdg8py"
+ }
+ ],
+ "note": ":spinster: Admin of @spinster\r\n:4w: Editor of @4WPub\r\n\r\nSorry I didn't reply to you.\r\n\r\nBoost ≠ agree. All opinions my own.",
+ "pleroma": {
+ "actor_type": "Person",
+ "discoverable": false
+ },
+ "sensitive": false
+ },
+ "statuses_count": 9580,
+ "url": "https://spinster.xyz/users/mk",
+ "username": "mk"
+}
diff --git a/app/soapbox/__fixtures__/realDonaldTrump.json b/app/soapbox/__fixtures__/realDonaldTrump.json
new file mode 100644
index 000000000..c9cf20076
--- /dev/null
+++ b/app/soapbox/__fixtures__/realDonaldTrump.json
@@ -0,0 +1,26 @@
+{
+ "id": "107780257626128497",
+ "username": "realDonaldTrump",
+ "acct": "realDonaldTrump",
+ "display_name": "Donald J. Trump",
+ "locked": false,
+ "bot": false,
+ "discoverable": null,
+ "group": false,
+ "created_at": "2022-02-11T00:00:00.000Z",
+ "note": "
45th President of the United States of America
", + "url": "https://truthsocial.com/@realDonaldTrump", + "avatar": "https://static-assets.truthsocial.com/tmtg:prime-truth-social-assets/accounts/avatars/107/780/257/626/128/497/original/573cf5cc8281e7e9.jpeg", + "avatar_static": "https://static-assets.truthsocial.com/tmtg:prime-truth-social-assets/accounts/avatars/107/780/257/626/128/497/original/573cf5cc8281e7e9.jpeg", + "header": "https://static-assets.truthsocial.com/tmtg:prime-truth-social-assets/accounts/headers/107/780/257/626/128/497/original/3c1acf607b065ded.jpeg", + "header_static": "https://static-assets.truthsocial.com/tmtg:prime-truth-social-assets/accounts/headers/107/780/257/626/128/497/original/3c1acf607b065ded.jpeg", + "followers_count": 51507, + "following_count": 1, + "statuses_count": 1, + "last_status_at": "2022-02-14", + "verified": true, + "location": "", + "website": "", + "emojis": [], + "fields": [] +} diff --git a/app/soapbox/normalizers/__tests__/account-test.js b/app/soapbox/normalizers/__tests__/account-test.js index d6584f96b..f00dd57c5 100644 --- a/app/soapbox/normalizers/__tests__/account-test.js +++ b/app/soapbox/normalizers/__tests__/account-test.js @@ -36,4 +36,22 @@ describe('normalizeAccount()', () => { expect(result.getIn(['pleroma', 'is_confirmed'])).toBe(true); expect(result.getIn(['pleroma', 'is_approved'])).toBe(true); }); + + it('normalizes a verified Pleroma user', () => { + const account = fromJS(require('soapbox/__fixtures__/mk.json')); + const result = normalizeAccount(account); + expect(result.get('verified')).toBe(true); + }); + + it('normalizes an unverified Pleroma user', () => { + const account = fromJS(require('soapbox/__fixtures__/pleroma-account.json')); + const result = normalizeAccount(account); + expect(result.get('verified')).toBe(false); + }); + + it('normalizes a verified Truth Social user', () => { + const account = fromJS(require('soapbox/__fixtures__/realDonaldTrump.json')); + const result = normalizeAccount(account); + expect(result.get('verified')).toBe(true); + }); }); diff --git a/app/soapbox/normalizers/account.js b/app/soapbox/normalizers/account.js index da942473f..aa49f647f 100644 --- a/app/soapbox/normalizers/account.js +++ b/app/soapbox/normalizers/account.js @@ -1,4 +1,4 @@ -import { Map as ImmutableMap } from 'immutable'; +import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; import { mergeDefined } from 'soapbox/utils/normalizers'; @@ -28,9 +28,20 @@ const normalizeBirthday = account => { return account.set('birthday', birthday); }; +// Normalize Truth Social/Pleroma verified +const normalizeVerified = account => { + return account.update('verified', verified => { + return [ + verified === true, + account.getIn(['pleroma', 'tags'], ImmutableList()).includes('verified'), + ].some(Boolean); + }); +}; + export const normalizeAccount = account => { return account.withMutations(account => { normalizePleromaLegacyFields(account); + normalizeVerified(account); normalizeBirthday(account); }); }; diff --git a/app/soapbox/utils/accounts.js b/app/soapbox/utils/accounts.js index 3cf2c7cd5..af6dfdbbb 100644 --- a/app/soapbox/utils/accounts.js +++ b/app/soapbox/utils/accounts.js @@ -64,9 +64,7 @@ export const isLocal = account => { export const isRemote = account => !isLocal(account); -export const isVerified = account => ( - account.getIn(['pleroma', 'tags'], ImmutableList()).includes('verified') -); +export const isVerified = account => account.get('verified') === true; export const accountToMention = account => { return ImmutableMap({