Add a layer of safety around required ActivityPub Actor fields (#4703)
* fix(ap): add safe constructors, getters, and validators to ActivityPub actors to address #4701 * chore: replace nil check with the new Validate() method * chore(test): added test to verify the values extracted from actors * fix: return the specific error type + test for it * fix(ap): add recovery for each AP inbox worker for a worst case scenario * fix(ap): add additional safe accessor methods to other AP entities other than actors * chore(tests): add tests for the new safe accessors * fix(ap): handle empty public keys in AP actors
This commit is contained in:
@@ -308,13 +308,12 @@ func UpdateFollowersWithAccountUpdates() error {
|
||||
|
||||
// Add will save an ActivityPub object to the datastore.
|
||||
func Add(item vocab.Type, id string, isLiveNotification bool) error {
|
||||
iri := item.GetJSONLDId().GetIRI().String()
|
||||
typeString := item.GetTypeName()
|
||||
|
||||
if iri == "" {
|
||||
log.Errorln("Unable to get iri from item")
|
||||
return errors.New("Unable to get iri from item " + id)
|
||||
iri, err := apmodels.GetIRIStringFromJSONLDIdProperty(item.GetJSONLDId())
|
||||
if err != nil {
|
||||
log.Errorln("Unable to get iri from item:", err)
|
||||
return errors.Wrap(err, "unable to get iri from item "+id)
|
||||
}
|
||||
typeString := item.GetTypeName()
|
||||
|
||||
b, err := apmodels.Serialize(item)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user