normalizeAccount(): normalize "verified" field
This commit is contained in:
parent
e72feaafba
commit
3095ee5db1
|
@ -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": "<a href=\"https://marykatefain.com\" rel=\"ugc\">https://marykatefain.com</a>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Twitter",
|
||||||
|
"value": "<a href=\"https://twitter.com/mkay_fain\" rel=\"ugc\">https://twitter.com/mkay_fain</a>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Patreon",
|
||||||
|
"value": "<a href=\"https://www.patreon.com/mkfain\" rel=\"ugc\">https://www.patreon.com/mkfain</a>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Paypal",
|
||||||
|
"value": "<a href=\"https://www.paypal.com/donate?hosted_button_id=NYXHYFQ6CRWJJ\" rel=\"ugc\">https://www.paypal.com/donate?hosted_button_id=NYXHYFQ6CRWJJ</a>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Facebook",
|
||||||
|
"value": "<a href=\"https://www.facebook.com/M-K-Fain-102559968375112\" rel=\"ugc\">https://www.facebook.com/M-K-Fain-102559968375112</a>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Dog Pics",
|
||||||
|
"value": "<a href=\"https://www.instagram.com/mmkaayyy92\" rel=\"ugc\">https://www.instagram.com/mmkaayyy92</a>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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 <span class=\"h-card\"><a class=\"u-url mention\" data-user=\"9y4BZYU2PlrsA8UyBM\" href=\"https://spinster.xyz/users/spinster\" rel=\"ugc\">@<span>spinster</span></a></span><br/>:4w: Editor of <span class=\"h-card\"><a class=\"u-url mention\" data-user=\"9y4BxBsU76tt0CCgBE\" href=\"https://spinster.xyz/users/4WPub\" rel=\"ugc\">@<span>4WPub</span></a></span><br/><br/>Sorry I didn't reply to you.<br/><br/>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"
|
||||||
|
}
|
|
@ -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": "<p>45th President of the United States of America</p>",
|
||||||
|
"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": []
|
||||||
|
}
|
|
@ -36,4 +36,22 @@ describe('normalizeAccount()', () => {
|
||||||
expect(result.getIn(['pleroma', 'is_confirmed'])).toBe(true);
|
expect(result.getIn(['pleroma', 'is_confirmed'])).toBe(true);
|
||||||
expect(result.getIn(['pleroma', 'is_approved'])).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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -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';
|
import { mergeDefined } from 'soapbox/utils/normalizers';
|
||||||
|
|
||||||
|
@ -28,9 +28,20 @@ const normalizeBirthday = account => {
|
||||||
return account.set('birthday', birthday);
|
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 => {
|
export const normalizeAccount = account => {
|
||||||
return account.withMutations(account => {
|
return account.withMutations(account => {
|
||||||
normalizePleromaLegacyFields(account);
|
normalizePleromaLegacyFields(account);
|
||||||
|
normalizeVerified(account);
|
||||||
normalizeBirthday(account);
|
normalizeBirthday(account);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -64,9 +64,7 @@ export const isLocal = account => {
|
||||||
|
|
||||||
export const isRemote = account => !isLocal(account);
|
export const isRemote = account => !isLocal(account);
|
||||||
|
|
||||||
export const isVerified = account => (
|
export const isVerified = account => account.get('verified') === true;
|
||||||
account.getIn(['pleroma', 'tags'], ImmutableList()).includes('verified')
|
|
||||||
);
|
|
||||||
|
|
||||||
export const accountToMention = account => {
|
export const accountToMention = account => {
|
||||||
return ImmutableMap({
|
return ImmutableMap({
|
||||||
|
|
Loading…
Reference in New Issue