mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 14:52:26 -05:00
Handle forwarded messages (#273)
* correct path of foss_satan * add APIri and notes * test create forward note * rename target => receiving account * split up create into separate funcs * update extractFromCtx * tidy up from federator processing * foss satan => http not https * check if status in db * mock dereference of status from IRI * add forward message deref test * update test with activities * add remote_account_2 to test rig
This commit is contained in:
parent
3dc7644ae6
commit
367bdca250
18 changed files with 765 additions and 383 deletions
|
|
@ -289,29 +289,26 @@ func (f *federatingDB) collectIRIs(ctx context.Context, iris []*url.URL) (vocab.
|
|||
|
||||
// extractFromCtx extracts some useful values from a context passed into the federatingDB via the API:
|
||||
// - The target account that owns the inbox or URI being interacted with.
|
||||
// - The requesting account that posted to the inbox.
|
||||
// - A channel that messages for the processor can be placed into.
|
||||
func extractFromCtx(ctx context.Context) (*gtsmodel.Account, chan messages.FromFederator, error) {
|
||||
var targetAcct *gtsmodel.Account
|
||||
targetAcctI := ctx.Value(util.APAccount)
|
||||
if targetAcctI != nil {
|
||||
var ok bool
|
||||
targetAcct, ok = targetAcctI.(*gtsmodel.Account)
|
||||
if !ok {
|
||||
return nil, nil, errors.New("extractFromCtx: account value in context not parseable")
|
||||
}
|
||||
// If a value is not present, nil will be returned for it. It's up to the caller to check this and respond appropriately.
|
||||
func extractFromCtx(ctx context.Context) (receivingAccount, requestingAccount *gtsmodel.Account, fromFederatorChan chan messages.FromFederator) {
|
||||
receivingAccountI := ctx.Value(util.APReceivingAccount)
|
||||
if receivingAccountI != nil {
|
||||
receivingAccount = receivingAccountI.(*gtsmodel.Account)
|
||||
}
|
||||
|
||||
requestingAcctI := ctx.Value(util.APRequestingAccount)
|
||||
if requestingAcctI != nil {
|
||||
requestingAccount = requestingAcctI.(*gtsmodel.Account)
|
||||
}
|
||||
|
||||
var fromFederatorChan chan messages.FromFederator
|
||||
fromFederatorChanI := ctx.Value(util.APFromFederatorChanKey)
|
||||
if fromFederatorChanI != nil {
|
||||
var ok bool
|
||||
fromFederatorChan, ok = fromFederatorChanI.(chan messages.FromFederator)
|
||||
if !ok {
|
||||
return nil, nil, errors.New("extractFromCtx: fromFederatorChan value in context not parseable")
|
||||
}
|
||||
fromFederatorChan = fromFederatorChanI.(chan messages.FromFederator)
|
||||
}
|
||||
|
||||
return targetAcct, fromFederatorChan, nil
|
||||
return
|
||||
}
|
||||
|
||||
func marshalItem(item vocab.Type) (string, error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue