2023-03-12 15:00:57 +00:00
// GoToSocial
// Copyright (C) GoToSocial Authors admin@gotosocial.org
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
2021-03-13 16:07:05 +00:00
2021-05-08 12:25:55 +00:00
package typeutils_test
2021-03-13 16:07:05 +00:00
2021-04-19 17:42:19 +00:00
import (
2021-05-08 12:25:55 +00:00
"github.com/stretchr/testify/suite"
2021-11-13 16:29:43 +00:00
"github.com/superseriousbusiness/activity/streams/vocab"
2021-04-19 17:42:19 +00:00
"github.com/superseriousbusiness/gotosocial/internal/db"
2021-05-08 12:25:55 +00:00
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
2023-03-31 13:01:29 +00:00
"github.com/superseriousbusiness/gotosocial/internal/processing"
2023-03-01 18:26:53 +00:00
"github.com/superseriousbusiness/gotosocial/internal/state"
2021-05-08 12:25:55 +00:00
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
2023-05-25 08:37:38 +00:00
"github.com/superseriousbusiness/gotosocial/internal/visibility"
2021-09-14 10:23:56 +00:00
"github.com/superseriousbusiness/gotosocial/testrig"
2021-04-19 17:42:19 +00:00
)
2021-03-13 16:07:05 +00:00
2021-09-14 10:23:56 +00:00
const (
statusWithMentionsActivityJson = ` {
"@context" : [
"https://www.w3.org/ns/activitystreams" ,
{
"ostatus" : "http://ostatus.org#" ,
"atomUri" : "ostatus:atomUri" ,
"inReplyToAtomUri" : "ostatus:inReplyToAtomUri" ,
"conversation" : "ostatus:conversation" ,
"sensitive" : "as:sensitive" ,
"toot" : "http://joinmastodon.org/ns#" ,
"votersCount" : "toot:votersCount"
}
] ,
"id" : "http://fossbros-anonymous.io/users/foss_satan/statuses/106221634728637552/activity" ,
"type" : "Create" ,
"actor" : "http://fossbros-anonymous.io/users/foss_satan" ,
2022-05-28 17:59:55 +00:00
"published" : "2021-05-12T09:58:38.00Z" ,
2021-09-14 10:23:56 +00:00
"to" : [
"http://fossbros-anonymous.io/users/foss_satan/followers"
] ,
"cc" : [
"https://www.w3.org/ns/activitystreams#Public" ,
"http://localhost:8080/users/the_mighty_zork"
] ,
"object" : {
"id" : "http://fossbros-anonymous.io/users/foss_satan/statuses/106221634728637552" ,
"type" : "Note" ,
"summary" : null ,
"inReplyTo" : "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY" ,
2022-05-28 17:59:55 +00:00
"published" : "2021-05-12T09:58:38.00Z" ,
2021-09-14 10:23:56 +00:00
"url" : "https://ondergrond.org/@dumpsterqueer/106221634728637552" ,
"attributedTo" : "http://fossbros-anonymous.io/users/foss_satan" ,
"to" : [
"http://fossbros-anonymous.io/users/foss_satan/followers"
] ,
"cc" : [
"https://www.w3.org/ns/activitystreams#Public" ,
"http://localhost:8080/users/the_mighty_zork"
] ,
"sensitive" : false ,
"conversation" : "tag:ondergrond.org,2021-05-12:objectId=1132361:objectType=Conversation" ,
"content" : "<p><span class=\"h-card\"><a href=\"http://localhost:8080/@the_mighty_zork\" class=\"u-url mention\">@<span>the_mighty_zork</span></a></span> nice there it is:</p><p><a href=\"http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/activity\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"ellipsis\">social.pixie.town/users/f0x/st</span><span class=\"invisible\">atuses/106221628567855262/activity</span></a></p>" ,
"contentMap" : {
"en" : "<p><span class=\"h-card\"><a href=\"http://localhost:8080/@the_mighty_zork\" class=\"u-url mention\">@<span>the_mighty_zork</span></a></span> nice there it is:</p><p><a href=\"http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/activity\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"ellipsis\">social.pixie.town/users/f0x/st</span><span class=\"invisible\">atuses/106221628567855262/activity</span></a></p>"
} ,
"attachment" : [ ] ,
"tag" : [
{
"type" : "Mention" ,
"href" : "http://localhost:8080/users/the_mighty_zork" ,
"name" : "@the_mighty_zork@localhost:8080"
}
] ,
"replies" : {
"id" : "http://fossbros-anonymous.io/users/foss_satan/statuses/106221634728637552/replies" ,
"type" : "Collection" ,
"first" : {
"type" : "CollectionPage" ,
"next" : "http://fossbros-anonymous.io/users/foss_satan/statuses/106221634728637552/replies?only_other_accounts=true&page=true" ,
"partOf" : "http://fossbros-anonymous.io/users/foss_satan/statuses/106221634728637552/replies" ,
"items" : [ ]
}
}
}
} `
statusWithEmojisAndTagsAsActivityJson = ` {
"@context" : [
"https://www.w3.org/ns/activitystreams" ,
{
"ostatus" : "http://ostatus.org#" ,
"atomUri" : "ostatus:atomUri" ,
"inReplyToAtomUri" : "ostatus:inReplyToAtomUri" ,
"conversation" : "ostatus:conversation" ,
"sensitive" : "as:sensitive" ,
"toot" : "http://joinmastodon.org/ns#" ,
"votersCount" : "toot:votersCount" ,
"Hashtag" : "as:Hashtag" ,
"Emoji" : "toot:Emoji" ,
"focalPoint" : {
"@container" : "@list" ,
"@id" : "toot:focalPoint"
}
}
] ,
"id" : "http://fossbros-anonymous.io/users/foss_satan/statuses/106221567884565704/activity" ,
"type" : "Create" ,
"actor" : "http://fossbros-anonymous.io/users/foss_satan" ,
2022-05-28 17:59:55 +00:00
"published" : "2021-05-12T09:41:38.00Z" ,
2021-09-14 10:23:56 +00:00
"to" : [
"http://fossbros-anonymous.io/users/foss_satan/followers"
] ,
"cc" : [
"https://www.w3.org/ns/activitystreams#Public"
] ,
"object" : {
"id" : "http://fossbros-anonymous.io/users/foss_satan/statuses/106221567884565704" ,
"type" : "Note" ,
"summary" : null ,
"inReplyTo" : null ,
2022-05-28 17:59:55 +00:00
"published" : "2021-05-12T09:41:38.00Z" ,
2021-09-14 10:23:56 +00:00
"url" : "https://ondergrond.org/@dumpsterqueer/106221567884565704" ,
"attributedTo" : "http://fossbros-anonymous.io/users/foss_satan" ,
"to" : [
"http://fossbros-anonymous.io/users/foss_satan/followers"
] ,
"cc" : [
"https://www.w3.org/ns/activitystreams#Public"
] ,
"sensitive" : false ,
"atomUri" : "http://fossbros-anonymous.io/users/foss_satan/statuses/106221567884565704" ,
"inReplyToAtomUri" : null ,
"conversation" : "tag:ondergrond.org,2021-05-12:objectId=1132361:objectType=Conversation" ,
"content" : "<p>just testing activitypub representations of <a href=\"https://ondergrond.org/tags/tags\" class=\"mention hashtag\" rel=\"tag\">#<span>tags</span></a> and <a href=\"https://ondergrond.org/tags/emoji\" class=\"mention hashtag\" rel=\"tag\">#<span>emoji</span></a> :party_parrot: :amaze: :blobsunglasses: </p><p>don't mind me....</p>" ,
"contentMap" : {
"en" : "<p>just testing activitypub representations of <a href=\"https://ondergrond.org/tags/tags\" class=\"mention hashtag\" rel=\"tag\">#<span>tags</span></a> and <a href=\"https://ondergrond.org/tags/emoji\" class=\"mention hashtag\" rel=\"tag\">#<span>emoji</span></a> :party_parrot: :amaze: :blobsunglasses: </p><p>don't mind me....</p>"
} ,
"attachment" : [ ] ,
"tag" : [
{
"type" : "Hashtag" ,
"href" : "https://ondergrond.org/tags/tags" ,
"name" : "#tags"
} ,
{
"type" : "Hashtag" ,
"href" : "https://ondergrond.org/tags/emoji" ,
"name" : "#emoji"
} ,
{
"id" : "https://ondergrond.org/emojis/2390" ,
"type" : "Emoji" ,
"name" : ":party_parrot:" ,
2022-05-28 17:59:55 +00:00
"updated" : "2020-11-06T13:42:11.00Z" ,
2021-09-14 10:23:56 +00:00
"icon" : {
"type" : "Image" ,
"mediaType" : "image/gif" ,
"url" : "https://ondergrond.org/system/custom_emojis/images/000/002/390/original/ef133aac7ab23341.gif"
}
} ,
{
"id" : "https://ondergrond.org/emojis/2395" ,
"type" : "Emoji" ,
"name" : ":amaze:" ,
2022-05-28 17:59:55 +00:00
"updated" : "2020-09-26T12:29:56.00Z" ,
2021-09-14 10:23:56 +00:00
"icon" : {
"type" : "Image" ,
"mediaType" : "image/png" ,
"url" : "https://ondergrond.org/system/custom_emojis/images/000/002/395/original/2c7d9345e57367ed.png"
}
} ,
{
"id" : "https://ondergrond.org/emojis/764" ,
"type" : "Emoji" ,
"name" : ":blobsunglasses:" ,
2022-05-28 17:59:55 +00:00
"updated" : "2020-09-26T12:13:23.00Z" ,
2021-09-14 10:23:56 +00:00
"icon" : {
"type" : "Image" ,
"mediaType" : "image/png" ,
"url" : "https://ondergrond.org/system/custom_emojis/images/000/000/764/original/3f8eef9de773c90d.png"
}
}
] ,
"replies" : {
"id" : "http://fossbros-anonymous.io/users/foss_satan/statuses/106221567884565704/replies" ,
"type" : "Collection" ,
"first" : {
"type" : "CollectionPage" ,
"next" : "http://fossbros-anonymous.io/users/foss_satan/statuses/106221567884565704/replies?only_other_accounts=true&page=true" ,
"partOf" : "http://fossbros-anonymous.io/users/foss_satan/statuses/106221567884565704/replies" ,
"items" : [ ]
}
}
}
} `
gargronAsActivityJson = ` {
"@context" : [
"https://www.w3.org/ns/activitystreams" ,
"https://w3id.org/security/v1" ,
{
"manuallyApprovesFollowers" : "as:manuallyApprovesFollowers" ,
"toot" : "http://joinmastodon.org/ns#" ,
"featured" : {
"@id" : "toot:featured" ,
"@type" : "@id"
} ,
"featuredTags" : {
"@id" : "toot:featuredTags" ,
"@type" : "@id"
} ,
"alsoKnownAs" : {
"@id" : "as:alsoKnownAs" ,
"@type" : "@id"
} ,
"movedTo" : {
"@id" : "as:movedTo" ,
"@type" : "@id"
} ,
"schema" : "http://schema.org#" ,
"PropertyValue" : "schema:PropertyValue" ,
"value" : "schema:value" ,
"IdentityProof" : "toot:IdentityProof" ,
"discoverable" : "toot:discoverable" ,
"Device" : "toot:Device" ,
"Ed25519Signature" : "toot:Ed25519Signature" ,
"Ed25519Key" : "toot:Ed25519Key" ,
"Curve25519Key" : "toot:Curve25519Key" ,
"EncryptedMessage" : "toot:EncryptedMessage" ,
"publicKeyBase64" : "toot:publicKeyBase64" ,
"deviceId" : "toot:deviceId" ,
"claim" : {
"@type" : "@id" ,
"@id" : "toot:claim"
} ,
"fingerprintKey" : {
"@type" : "@id" ,
"@id" : "toot:fingerprintKey"
} ,
"identityKey" : {
"@type" : "@id" ,
"@id" : "toot:identityKey"
} ,
"devices" : {
"@type" : "@id" ,
"@id" : "toot:devices"
} ,
"messageFranking" : "toot:messageFranking" ,
"messageType" : "toot:messageType" ,
"cipherText" : "toot:cipherText" ,
"suspended" : "toot:suspended" ,
"focalPoint" : {
"@container" : "@list" ,
"@id" : "toot:focalPoint"
}
}
] ,
"id" : "https://mastodon.social/users/Gargron" ,
"type" : "Person" ,
"following" : "https://mastodon.social/users/Gargron/following" ,
"followers" : "https://mastodon.social/users/Gargron/followers" ,
"inbox" : "https://mastodon.social/users/Gargron/inbox" ,
"outbox" : "https://mastodon.social/users/Gargron/outbox" ,
"featured" : "https://mastodon.social/users/Gargron/collections/featured" ,
"featuredTags" : "https://mastodon.social/users/Gargron/collections/tags" ,
"preferredUsername" : "Gargron" ,
"name" : "Eugen" ,
"summary" : "<p>Developer of Mastodon and administrator of mastodon.social. I post service announcements, development updates, and personal stuff.</p>" ,
"url" : "https://mastodon.social/@Gargron" ,
"manuallyApprovesFollowers" : false ,
"discoverable" : true ,
"devices" : "https://mastodon.social/users/Gargron/collections/devices" ,
"alsoKnownAs" : [
"https://tooting.ai/users/Gargron"
] ,
"publicKey" : {
"id" : "https://mastodon.social/users/Gargron#main-key" ,
"owner" : "https://mastodon.social/users/Gargron" ,
"publicKeyPem" : "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvXc4vkECU2/CeuSo1wtn\nFoim94Ne1jBMYxTZ9wm2YTdJq1oiZKif06I2fOqDzY/4q/S9uccrE9Bkajv1dnkO\nVm31QjWlhVpSKynVxEWjVBO5Ienue8gND0xvHIuXf87o61poqjEoepvsQFElA5ym\novljWGSA/jpj7ozygUZhCXtaS2W5AD5tnBQUpcO0lhItYPYTjnmzcc4y2NbJV8hz\n2s2G8qKv8fyimE23gY1XrPJg+cRF+g4PqFXujjlJ7MihD9oqtLGxbu7o1cifTn3x\nBfIdPythWu5b4cujNsB3m3awJjVmx+MHQ9SugkSIYXV0Ina77cTNS0M2PYiH1PFR\nTwIDAQAB\n-----END PUBLIC KEY-----\n"
} ,
"tag" : [ ] ,
"attachment" : [
{
"type" : "PropertyValue" ,
"name" : "Patreon" ,
"value" : "<a href=\"https://www.patreon.com/mastodon\" rel=\"me nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://www.</span><span class=\"\">patreon.com/mastodon</span><span class=\"invisible\"></span></a>"
} ,
{
"type" : "PropertyValue" ,
"name" : "Homepage" ,
"value" : "<a href=\"https://zeonfederated.com\" rel=\"me nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"\">zeonfederated.com</span><span class=\"invisible\"></span></a>"
} ,
{
"type" : "IdentityProof" ,
"name" : "gargron" ,
"signatureAlgorithm" : "keybase" ,
"signatureValue" : "5cfc20c7018f2beefb42a68836da59a792e55daa4d118498c9b1898de7e845690f"
}
] ,
"endpoints" : {
"sharedInbox" : "https://mastodon.social/inbox"
} ,
"icon" : {
"type" : "Image" ,
"mediaType" : "image/jpeg" ,
"url" : "https://files.mastodon.social/accounts/avatars/000/000/001/original/d96d39a0abb45b92.jpg"
} ,
"image" : {
"type" : "Image" ,
"mediaType" : "image/png" ,
"url" : "https://files.mastodon.social/accounts/headers/000/000/001/original/c91b871f294ea63e.png"
}
} `
2022-04-26 08:47:21 +00:00
publicStatusActivityJson = `
{
"@context" : [
"https://www.w3.org/ns/activitystreams" ,
{
"ostatus" : "http://ostatus.org#" ,
"atomUri" : "ostatus:atomUri" ,
"inReplyToAtomUri" : "ostatus:inReplyToAtomUri" ,
"conversation" : "ostatus:conversation" ,
"sensitive" : "as:sensitive" ,
"toot" : "http://joinmastodon.org/ns#" ,
"votersCount" : "toot:votersCount"
}
] ,
"id" : "http://fossbros-anonymous.io/users/foss_satan/statuses/108138763199405167" ,
"type" : "Note" ,
"summary" : "reading: Punishment and Reward in the Corporate University" ,
"inReplyTo" : "http://fossbros-anonymous.io/users/foss_satan/statuses/108138729399508469" ,
2022-05-28 17:59:55 +00:00
"published" : "2022-04-15T23:49:37.00Z" ,
2022-04-26 08:47:21 +00:00
"url" : "http://fossbros-anonymous.io/@foss_satan/108138763199405167" ,
"attributedTo" : "http://fossbros-anonymous.io/users/foss_satan" ,
"to" : [
"https://www.w3.org/ns/activitystreams#Public"
] ,
"cc" : [
"http://fossbros-anonymous.io/users/foss_satan/followers"
] ,
"sensitive" : true ,
"atomUri" : "http://fossbros-anonymous.io/users/foss_satan/statuses/108138763199405167" ,
2022-05-23 15:10:48 +00:00
"inReplyToAtomUri" : "http://fossbros-anonymous.io/users/foss_satan/statuses/108138729399508469" ,
"content" : "<p>> So we have to examine critical thinking as a signifier, dynamic and ambiguous. It has a normative definition, a tacit definition, and an ideal definition. One of the hallmarks of graduate training is learning to comprehend those definitions and applying the correct one as needed for professional success.</p>" ,
"contentMap" : {
"en" : "<p>> So we have to examine critical thinking as a signifier, dynamic and ambiguous. It has a normative definition, a tacit definition, and an ideal definition. One of the hallmarks of graduate training is learning to comprehend those definitions and applying the correct one as needed for professional success.</p>"
} ,
"attachment" : [ ] ,
"tag" : [ ] ,
"replies" : {
"id" : "http://fossbros-anonymous.io/users/foss_satan/statuses/108138763199405167/replies" ,
"type" : "Collection" ,
"first" : {
"type" : "CollectionPage" ,
"next" : "http://fossbros-anonymous.io/users/foss_satan/statuses/108138763199405167/replies?only_other_accounts=true&page=true" ,
"partOf" : "http://fossbros-anonymous.io/users/foss_satan/statuses/108138763199405167/replies" ,
"items" : [ ]
}
}
}
`
publicStatusActivityJsonNoURL = `
{
"@context" : [
"https://www.w3.org/ns/activitystreams" ,
{
"ostatus" : "http://ostatus.org#" ,
"atomUri" : "ostatus:atomUri" ,
"inReplyToAtomUri" : "ostatus:inReplyToAtomUri" ,
"conversation" : "ostatus:conversation" ,
"sensitive" : "as:sensitive" ,
"toot" : "http://joinmastodon.org/ns#" ,
"votersCount" : "toot:votersCount"
}
] ,
"id" : "http://fossbros-anonymous.io/users/foss_satan/statuses/108138763199405167" ,
"type" : "Note" ,
"summary" : "reading: Punishment and Reward in the Corporate University" ,
"inReplyTo" : "http://fossbros-anonymous.io/users/foss_satan/statuses/108138729399508469" ,
2022-05-28 17:59:55 +00:00
"published" : "2022-04-15T23:49:37.00Z" ,
2022-05-23 15:10:48 +00:00
"attributedTo" : "http://fossbros-anonymous.io/users/foss_satan" ,
"to" : [
"https://www.w3.org/ns/activitystreams#Public"
] ,
"cc" : [
"http://fossbros-anonymous.io/users/foss_satan/followers"
] ,
"sensitive" : true ,
"atomUri" : "http://fossbros-anonymous.io/users/foss_satan/statuses/108138763199405167" ,
2022-04-26 08:47:21 +00:00
"inReplyToAtomUri" : "http://fossbros-anonymous.io/users/foss_satan/statuses/108138729399508469" ,
"content" : "<p>> So we have to examine critical thinking as a signifier, dynamic and ambiguous. It has a normative definition, a tacit definition, and an ideal definition. One of the hallmarks of graduate training is learning to comprehend those definitions and applying the correct one as needed for professional success.</p>" ,
"contentMap" : {
"en" : "<p>> So we have to examine critical thinking as a signifier, dynamic and ambiguous. It has a normative definition, a tacit definition, and an ideal definition. One of the hallmarks of graduate training is learning to comprehend those definitions and applying the correct one as needed for professional success.</p>"
} ,
"attachment" : [ ] ,
"tag" : [ ] ,
"replies" : {
"id" : "http://fossbros-anonymous.io/users/foss_satan/statuses/108138763199405167/replies" ,
"type" : "Collection" ,
"first" : {
"type" : "CollectionPage" ,
"next" : "http://fossbros-anonymous.io/users/foss_satan/statuses/108138763199405167/replies?only_other_accounts=true&page=true" ,
"partOf" : "http://fossbros-anonymous.io/users/foss_satan/statuses/108138763199405167/replies" ,
"items" : [ ]
}
}
}
`
2022-05-27 14:35:35 +00:00
owncastService = `
{
"@context" : [
"https://www.w3.org/ns/activitystreams" ,
"http://joinmastodon.org/ns" ,
"https://w3id.org/security/v1"
] ,
"attachment" : {
"name" : "Stream" ,
"type" : "PropertyValue" ,
"value" : "<a href=\"https://owncast.example.org\" rel=\"me nofollow noopener noreferrer\" target=\"_blank\">https://owncast.example.org</a>"
} ,
"discoverable" : true ,
"followers" : "https://owncast.example.org/federation/user/rgh/followers" ,
"icon" : {
"type" : "Image" ,
"url" : "https://owncast.example.org/logo/external"
} ,
"id" : "https://owncast.example.org/federation/user/rgh" ,
"image" : {
"type" : "Image" ,
"url" : "https://owncast.example.org/logo/external"
} ,
"inbox" : "https://owncast.example.org/federation/user/rgh/inbox" ,
"manuallyApprovesFollowers" : false ,
"name" : "Rob's Owncast Server" ,
"outbox" : "https://owncast.example.org/federation/user/rgh/outbox" ,
"preferredUsername" : "rgh" ,
"publicKey" : {
"id" : "https://owncast.example.org/federation/user/rgh#main-key" ,
"owner" : "https://owncast.example.org/federation/user/rgh" ,
"publicKeyPem" : "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAurN+lUNwcGV2poLNtaoT\naRtJzN6s4SDcBmIFk82lxhdMKC6/Nssm+hvDuxWGqL0+dHwSvrG11rA6irGuSzRk\niHjYyVwYe/p1CxqJxzUfZVJAWdsCFWy+HtDrTWs5sggj1MiL59uGxvkCep+OYBuG\nBI8CvSOMLrDp8soCg3EY+zSgpXtGMuRaaUukavsfuglApShB61ny7W8LG252iKC5\nmyO8L7l8TNa5BrIi/pRHLzvv9aWiCa8VKtvmqj+mClEhpkRhImSk5GPJXgouTTgl\ntT28NYYciSf9YYgZ0SNWHdLUCdkMF592j4+BbkPvdgzc70G4yyu2GcWnTzBuvF5X\nYwIDAQAB\n-----END PUBLIC KEY-----\n"
} ,
2022-05-28 17:59:55 +00:00
"published" : "2022-05-22T18:44:57.00Z" ,
2022-05-27 14:35:35 +00:00
"summary" : "linux audio stuff " ,
"tag" : [
{
"href" : "https://directory.owncast.online/tags/owncast" ,
"name" : "#owncast" ,
"type" : "Hashtag"
} ,
{
"href" : "https://directory.owncast.online/tags/streaming" ,
"name" : "#streaming" ,
"type" : "Hashtag"
}
] ,
"type" : "Service" ,
"url" : "https://owncast.example.org/federation/user/rgh"
}
`
2021-09-14 10:23:56 +00:00
)
type TypeUtilsTestSuite struct {
2021-05-08 12:25:55 +00:00
suite . Suite
2022-12-22 10:48:28 +00:00
db db . DB
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
state state . State
2022-12-22 10:48:28 +00:00
testAccounts map [ string ] * gtsmodel . Account
testStatuses map [ string ] * gtsmodel . Status
testAttachments map [ string ] * gtsmodel . MediaAttachment
testPeople map [ string ] vocab . ActivityStreamsPerson
testEmojis map [ string ] * gtsmodel . Emoji
2023-01-23 12:14:21 +00:00
testReports map [ string ] * gtsmodel . Report
2023-03-03 19:56:34 +00:00
testMentions map [ string ] * gtsmodel . Mention
2021-05-08 12:25:55 +00:00
typeconverter typeutils . TypeConverter
2021-03-13 16:07:05 +00:00
}
2021-09-14 10:23:56 +00:00
2023-03-31 13:01:29 +00:00
func ( suite * TypeUtilsTestSuite ) SetupTest ( ) {
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
suite . state . Caches . Init ( )
2023-03-01 18:26:53 +00:00
2021-12-07 12:31:39 +00:00
testrig . InitTestConfig ( )
2022-05-23 15:40:03 +00:00
testrig . InitTestLog ( )
2021-12-07 12:31:39 +00:00
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
suite . db = testrig . NewTestDB ( & suite . state )
2023-03-31 13:01:29 +00:00
suite . state . DB = suite . db
storage := testrig . NewInMemoryStorage ( )
suite . state . Storage = storage
2021-09-14 10:23:56 +00:00
suite . testAccounts = testrig . NewTestAccounts ( )
suite . testStatuses = testrig . NewTestStatuses ( )
2022-12-22 10:48:28 +00:00
suite . testAttachments = testrig . NewTestAttachments ( )
2021-09-14 10:23:56 +00:00
suite . testPeople = testrig . NewTestFediPeople ( )
2022-09-26 09:56:01 +00:00
suite . testEmojis = testrig . NewTestEmojis ( )
2023-01-23 12:14:21 +00:00
suite . testReports = testrig . NewTestReports ( )
2023-03-03 19:56:34 +00:00
suite . testMentions = testrig . NewTestMentions ( )
2021-12-07 12:31:39 +00:00
suite . typeconverter = typeutils . NewConverter ( suite . db )
2021-09-14 10:23:56 +00:00
testrig . StandardDBSetup ( suite . db , nil )
}
func ( suite * TypeUtilsTestSuite ) TearDownTest ( ) {
testrig . StandardDBTeardown ( suite . db )
2023-03-31 13:01:29 +00:00
testrig . StopWorkers ( & suite . state )
}
// GetProcessor is a utility function that instantiates a processor.
// Useful when a test in the test suite needs to change some state.
func ( suite * TypeUtilsTestSuite ) GetProcessor ( ) * processing . Processor {
testrig . StartWorkers ( & suite . state )
2023-05-25 08:37:38 +00:00
testrig . StartTimelines (
& suite . state ,
visibility . NewFilter ( & suite . state ) ,
testrig . NewTestTypeConverter ( suite . db ) ,
)
2023-03-31 13:01:29 +00:00
httpClient := testrig . NewMockHTTPClient ( nil , "../../testrig/media" )
transportController := testrig . NewTestTransportController ( & suite . state , httpClient )
mediaManager := testrig . NewTestMediaManager ( & suite . state )
federator := testrig . NewTestFederator ( & suite . state , transportController , mediaManager )
emailSender := testrig . NewEmailSender ( "../../web/template/" , nil )
return testrig . NewTestProcessor ( & suite . state , federator , emailSender , mediaManager )
2021-09-14 10:23:56 +00:00
}