Merge remote-tracking branch 'origin/develop' into next
This commit is contained in:
commit
24a78f7740
4 changed files with 235 additions and 1 deletions
207
app/soapbox/__fixtures__/pleroma-status-reply-with-mentions.json
Normal file
207
app/soapbox/__fixtures__/pleroma-status-reply-with-mentions.json
Normal file
|
@ -0,0 +1,207 @@
|
|||
{
|
||||
"account": {
|
||||
"acct": "alex",
|
||||
"avatar": "https://media.gleasonator.com/6d64aecb17348b23aaff78db4687b9476cb0da1c07cc6a819c2e6ec7144c18b1.png",
|
||||
"avatar_static": "https://media.gleasonator.com/6d64aecb17348b23aaff78db4687b9476cb0da1c07cc6a819c2e6ec7144c18b1.png",
|
||||
"bot": false,
|
||||
"created_at": "2020-01-08T01:25:43.000Z",
|
||||
"display_name": "Alex Gleason",
|
||||
"emojis": [],
|
||||
"fields": [
|
||||
{
|
||||
"name": "Website",
|
||||
"value": "<a href=\"https://alexgleason.me\" rel=\"ugc\">https://alexgleason.me</a>"
|
||||
},
|
||||
{
|
||||
"name": "Soapbox",
|
||||
"value": "<a href=\"https://soapbox.pub\" rel=\"ugc\">https://soapbox.pub</a>"
|
||||
},
|
||||
{
|
||||
"name": "Email",
|
||||
"value": "alex@alexgleason.me"
|
||||
},
|
||||
{
|
||||
"name": "Gender identity",
|
||||
"value": "Soyboy"
|
||||
},
|
||||
{
|
||||
"name": "Donate (PayPal)",
|
||||
"value": "<a href=\"https://paypal.me/gleasonator\" rel=\"ugc\">https://paypal.me/gleasonator</a>"
|
||||
},
|
||||
{
|
||||
"name": "$BTC",
|
||||
"value": "bc1q9cx35adpm73aq2fw40ye6ts8hfxqzjr5unwg0n"
|
||||
},
|
||||
{
|
||||
"name": "$ETH",
|
||||
"value": "0xAc9aB5Fc04Dc1cB1789Af75b523Bd23C70B2D717"
|
||||
},
|
||||
{
|
||||
"name": "$DOGE",
|
||||
"value": "D5zVZs6jrRakaPVGiErkQiHt9sayzm6V5D"
|
||||
},
|
||||
{
|
||||
"name": "$XMR",
|
||||
"value": "45JDCLrjJ4bgVUSbbs2yjy9m5Mf4VLPW8fG7jw9sq5u69rXZZopQogZNeyYkMBnXpkaip4p4QwaaJNhdTotPa9g44DBCzdK"
|
||||
}
|
||||
],
|
||||
"followers_count": 2536,
|
||||
"following_count": 1587,
|
||||
"fqn": "alex@gleasonator.com",
|
||||
"header": "https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png",
|
||||
"header_static": "https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png",
|
||||
"id": "9v5bmRalQvjOy0ECcC",
|
||||
"last_status_at": "2022-03-26T15:13:42",
|
||||
"locked": false,
|
||||
"note": "I create Fediverse software that empowers people online.<br/><br/>I'm vegan btw<br/><br/>Note: If you have a question for me, please tag me publicly. This gives the opportunity for others to chime in, and bystanders to learn.",
|
||||
"pleroma": {
|
||||
"accepts_chat_messages": true,
|
||||
"also_known_as": [
|
||||
"https://mitra.social/users/alex"
|
||||
],
|
||||
"ap_id": "https://gleasonator.com/users/alex",
|
||||
"background_image": null,
|
||||
"birthday": "1993-07-03",
|
||||
"favicon": "https://gleasonator.com/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,
|
||||
"location": null,
|
||||
"relationship": {},
|
||||
"skip_thread_containment": false,
|
||||
"tags": []
|
||||
},
|
||||
"source": {
|
||||
"fields": [
|
||||
{
|
||||
"name": "Website",
|
||||
"value": "https://alexgleason.me"
|
||||
},
|
||||
{
|
||||
"name": "Soapbox",
|
||||
"value": "https://soapbox.pub"
|
||||
},
|
||||
{
|
||||
"name": "Email",
|
||||
"value": "alex@alexgleason.me"
|
||||
},
|
||||
{
|
||||
"name": "Gender identity",
|
||||
"value": "Soyboy"
|
||||
},
|
||||
{
|
||||
"name": "Donate (PayPal)",
|
||||
"value": "https://paypal.me/gleasonator"
|
||||
},
|
||||
{
|
||||
"name": "$BTC",
|
||||
"value": "bc1q9cx35adpm73aq2fw40ye6ts8hfxqzjr5unwg0n"
|
||||
},
|
||||
{
|
||||
"name": "$ETH",
|
||||
"value": "0xAc9aB5Fc04Dc1cB1789Af75b523Bd23C70B2D717"
|
||||
},
|
||||
{
|
||||
"name": "$DOGE",
|
||||
"value": "D5zVZs6jrRakaPVGiErkQiHt9sayzm6V5D"
|
||||
},
|
||||
{
|
||||
"name": "$XMR",
|
||||
"value": "45JDCLrjJ4bgVUSbbs2yjy9m5Mf4VLPW8fG7jw9sq5u69rXZZopQogZNeyYkMBnXpkaip4p4QwaaJNhdTotPa9g44DBCzdK"
|
||||
}
|
||||
],
|
||||
"note": "I create Fediverse software that empowers people online.\r\n\r\nI'm vegan btw\r\n\r\nNote: If you have a question for me, please tag me publicly. This gives the opportunity for others to chime in, and bystanders to learn.",
|
||||
"pleroma": {
|
||||
"actor_type": "Person",
|
||||
"discoverable": false
|
||||
},
|
||||
"sensitive": false
|
||||
},
|
||||
"statuses_count": 23825,
|
||||
"url": "https://gleasonator.com/users/alex",
|
||||
"username": "alex"
|
||||
},
|
||||
"application": {
|
||||
"name": "Soapbox FE",
|
||||
"website": "https://soapbox.pub/"
|
||||
},
|
||||
"bookmarked": false,
|
||||
"card": null,
|
||||
"content": "<p>DMs are definitely only federated to the servers of the recipients tho. So if I DM a kfcc user, the kfcc admins can see it, but no other instance admins can.</p>",
|
||||
"created_at": "2022-03-21T05:04:45.000Z",
|
||||
"emojis": [],
|
||||
"favourited": false,
|
||||
"favourites_count": 5,
|
||||
"id": "AHcweewcCh0iPUtMdk",
|
||||
"in_reply_to_account_id": "9v5bo8xPghEnkedGzo",
|
||||
"in_reply_to_id": "AHcwFrnbH1Xb2RqxhQ",
|
||||
"language": null,
|
||||
"media_attachments": [],
|
||||
"mentions": [
|
||||
{
|
||||
"acct": "crunklord420@kiwifarms.cc",
|
||||
"id": "9v5bo8xPghEnkedGzo",
|
||||
"url": "https://kiwifarms.cc/users/crunklord420",
|
||||
"username": "crunklord420"
|
||||
},
|
||||
{
|
||||
"acct": "becassine@kiwifarms.cc",
|
||||
"id": "A6W9i7UOhgpBBOkcEK",
|
||||
"url": "https://kiwifarms.cc/users/becassine",
|
||||
"username": "becassine"
|
||||
},
|
||||
{
|
||||
"acct": "King_Porgi@poa.st",
|
||||
"id": "A5U7Z228z3h3dBdg6C",
|
||||
"url": "https://poa.st/users/King_Porgi",
|
||||
"username": "King_Porgi"
|
||||
},
|
||||
{
|
||||
"acct": "ademan@thebag.social",
|
||||
"id": "A79wLvOahABnWFnwWm",
|
||||
"url": "https://thebag.social/users/ademan",
|
||||
"username": "ademan"
|
||||
}
|
||||
],
|
||||
"muted": false,
|
||||
"pinned": false,
|
||||
"pleroma": {
|
||||
"content": {
|
||||
"text/plain": "DMs are definitely only federated to the servers of the recipients tho. So if I DM a kfcc user, the kfcc admins can see it, but no other instance admins can."
|
||||
},
|
||||
"content_type": null,
|
||||
"conversation_id": "AHcrQt04eG9qB87g3s",
|
||||
"direct_conversation_id": null,
|
||||
"emoji_reactions": [],
|
||||
"expires_at": null,
|
||||
"in_reply_to_account_acct": "crunklord420@kiwifarms.cc",
|
||||
"local": true,
|
||||
"parent_visible": true,
|
||||
"pinned_at": null,
|
||||
"quote": null,
|
||||
"quote_url": null,
|
||||
"quote_visible": false,
|
||||
"spoiler_text": {
|
||||
"text/plain": ""
|
||||
},
|
||||
"thread_muted": false
|
||||
},
|
||||
"poll": null,
|
||||
"reblog": null,
|
||||
"reblogged": false,
|
||||
"reblogs_count": 0,
|
||||
"replies_count": 2,
|
||||
"sensitive": false,
|
||||
"spoiler_text": "",
|
||||
"tags": [],
|
||||
"text": null,
|
||||
"uri": "https://gleasonator.com/objects/0981bab7-a086-4ed9-b938-adc3ed9d5f51",
|
||||
"url": "https://gleasonator.com/notice/AHcweewcCh0iPUtMdk",
|
||||
"visibility": "public"
|
||||
}
|
|
@ -55,6 +55,7 @@ export const StatusRecord = ImmutableRecord({
|
|||
|
||||
// Internal fields
|
||||
contentHtml: '',
|
||||
filtered: false,
|
||||
hidden: false,
|
||||
search_index: '',
|
||||
spoilerHtml: '',
|
||||
|
|
|
@ -136,6 +136,26 @@ Promoting free speech, even for people and ideas you dislike`;
|
|||
const result = reducer(undefined, action).getIn(['103874034847713213', 'search_index']);
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
it('builds search_index with mentions', () => {
|
||||
const status = require('soapbox/__fixtures__/pleroma-status-reply-with-mentions.json');
|
||||
const action = { type: STATUS_IMPORT, status };
|
||||
|
||||
const expected = `DMs are definitely only federated to the servers of the recipients tho. So if I DM a kfcc user, the kfcc admins can see it, but no other instance admins can.
|
||||
|
||||
|
||||
|
||||
crunklord420
|
||||
|
||||
becassine
|
||||
|
||||
King_Porgi
|
||||
|
||||
ademan`;
|
||||
|
||||
const result = reducer(undefined, action).getIn(['AHcweewcCh0iPUtMdk', 'search_index']);
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('STATUS_CREATE_REQUEST', () => {
|
||||
|
|
|
@ -58,14 +58,20 @@ const getPollOptionTitles = ({ poll }: StatusRecord): ImmutableList<string> => {
|
|||
}
|
||||
};
|
||||
|
||||
// Gets usernames of mentioned users from status
|
||||
const getMentionedUsernames = (status: StatusRecord): ImmutableList<string> => {
|
||||
return status.mentions?.map(({ username }: { username: string }) => username);
|
||||
};
|
||||
|
||||
// Creates search text from the status
|
||||
const buildSearchContent = (status: StatusRecord): string => {
|
||||
const pollOptionTitles = getPollOptionTitles(status);
|
||||
const mentionedUsernames = getMentionedUsernames(status);
|
||||
|
||||
const fields = ImmutableList([
|
||||
status.spoiler_text,
|
||||
status.content,
|
||||
]).concat(pollOptionTitles);
|
||||
]).concat(pollOptionTitles).concat(mentionedUsernames);
|
||||
|
||||
return unescapeHTML(fields.join('\n\n')) || '';
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue