Files
tobi 409b286dc2 [bugfix] Fix statuses not being timelined + notified when dereffed rather than delivered (#4667)
This pull request pulls the "surfacing" logic in `processing/workers` into a separate `surfacing` package, which exposes a `surfacer` struct with functions set on it for things like notifying, timelining, emailing, and streaming.

The surfacer is then set on sub-processors, so that those sub-processors can call surfacing functions as necessary (during status creation etc).

To fix issues like https://codeberg.org/superseriousbusiness/gotosocial/issues/4627, where posts are not appearing in timelines or being notified for, because they entered the instance in ways other than being POSTed to an inbox, dereferencer functions now accept an optional  `newThreadEntryCallback` function that will be triggered for each *new* status dereferenced as part of (asynchronous) thread dereferencing.

As such, in common race conditions where we see a status by doing parent / search / thread dereferencing *BEFORE* that status actually gets POSTed to our inbox, the status should still be timelined + notified (as appropriate).

Closes https://codeberg.org/superseriousbusiness/gotosocial/issues/4627
Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4667
Co-authored-by: tobi <tobi.smethurst@protonmail.com>
Co-committed-by: tobi <tobi.smethurst@protonmail.com>
2026-02-05 16:28:08 +01:00

67 lines
2.2 KiB
Go

// 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/>.
package common
import (
"code.superseriousbusiness.org/gotosocial/internal/federation"
"code.superseriousbusiness.org/gotosocial/internal/filter/mutes"
"code.superseriousbusiness.org/gotosocial/internal/filter/status"
"code.superseriousbusiness.org/gotosocial/internal/filter/visibility"
"code.superseriousbusiness.org/gotosocial/internal/media"
"code.superseriousbusiness.org/gotosocial/internal/state"
"code.superseriousbusiness.org/gotosocial/internal/surfacing"
"code.superseriousbusiness.org/gotosocial/internal/typeutils"
)
// Processor provides a processor with logic
// common to multiple logical domains of the
// processing subsection of the codebase.
type Processor struct {
state *state.State
media *media.Manager
converter *typeutils.Converter
federator *federation.Federator
visFilter *visibility.Filter
muteFilter *mutes.Filter
statusFilter *status.Filter
surfacer *surfacing.Surfacer
}
// New returns a new Processor instance.
func New(
state *state.State,
media *media.Manager,
converter *typeutils.Converter,
federator *federation.Federator,
visFilter *visibility.Filter,
muteFilter *mutes.Filter,
statusFilter *status.Filter,
surfacer *surfacing.Surfacer,
) Processor {
return Processor{
state: state,
media: media,
converter: converter,
federator: federator,
visFilter: visFilter,
muteFilter: muteFilter,
statusFilter: statusFilter,
surfacer: surfacer,
}
}