mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 12:02:25 -05:00
[chore] chore rationalise http return codes for activitypub handlers (#2540)
* some small code fixups and changes * add check in ResolveIncomingActivity for transient activity types (i.e. activity ID is nil) * update test to handle new transient behaviour
This commit is contained in:
parent
906639ad7e
commit
67e11a1a61
5 changed files with 29 additions and 30 deletions
|
|
@ -45,16 +45,11 @@ func (f *federatingDB) Reject(ctx context.Context, reject vocab.ActivityStreamsR
|
|||
return nil // Already processed.
|
||||
}
|
||||
|
||||
rejectObject := reject.GetActivityStreamsObject()
|
||||
if rejectObject == nil {
|
||||
return errors.New("Reject: no object set on vocab.ActivityStreamsReject")
|
||||
}
|
||||
for _, obj := range ap.ExtractObjects(reject) {
|
||||
|
||||
for iter := rejectObject.Begin(); iter != rejectObject.End(); iter = iter.Next() {
|
||||
// check if the object is an IRI
|
||||
if iter.IsIRI() {
|
||||
if obj.IsIRI() {
|
||||
// we have just the URI of whatever is being rejected, so we need to find out what it is
|
||||
rejectedObjectIRI := iter.GetIRI()
|
||||
rejectedObjectIRI := obj.GetIRI()
|
||||
if uris.IsFollowPath(rejectedObjectIRI) {
|
||||
// REJECT FOLLOW
|
||||
followReq, err := f.state.DB.GetFollowRequestByURI(ctx, rejectedObjectIRI.String())
|
||||
|
|
@ -71,15 +66,10 @@ func (f *federatingDB) Reject(ctx context.Context, reject vocab.ActivityStreamsR
|
|||
}
|
||||
}
|
||||
|
||||
// check if iter is an AP object / type
|
||||
if iter.GetType() == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if iter.GetType().GetTypeName() == ap.ActivityFollow {
|
||||
if t := obj.GetType(); t != nil {
|
||||
// we have the whole object so we can figure out what we're rejecting
|
||||
// REJECT FOLLOW
|
||||
asFollow, ok := iter.GetType().(vocab.ActivityStreamsFollow)
|
||||
asFollow, ok := t.(vocab.ActivityStreamsFollow)
|
||||
if !ok {
|
||||
return errors.New("Reject: couldn't parse follow into vocab.ActivityStreamsFollow")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ func (f *federatingDB) Undo(ctx context.Context, undo vocab.ActivityStreamsUndo)
|
|||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
return errs.Combine()
|
||||
}
|
||||
|
||||
func (f *federatingDB) undoFollow(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue