gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

gen_json_resolver.go (35647B)


      1 // Code generated by astool. DO NOT EDIT.
      2 
      3 package streams
      4 
      5 import (
      6 	"context"
      7 	"errors"
      8 	"fmt"
      9 	vocab "github.com/superseriousbusiness/activity/streams/vocab"
     10 	"strings"
     11 )
     12 
     13 // JSONResolver resolves a JSON-deserialized map into its concrete ActivityStreams
     14 // type
     15 type JSONResolver struct {
     16 	callbacks []interface{}
     17 }
     18 
     19 // NewJSONResolver creates a new Resolver that takes a JSON-deserialized generic
     20 // map and determines the correct concrete Go type. The callback function is
     21 // guaranteed to receive a value whose underlying ActivityStreams type matches
     22 // the concrete interface name in its signature. The callback functions must
     23 // be of the form:
     24 //
     25 //   func(context.Context, <TypeInterface>) error
     26 //
     27 // where TypeInterface is the code-generated interface for an ActivityStream
     28 // type. An error is returned if a callback function does not match this
     29 // signature.
     30 func NewJSONResolver(callbacks ...interface{}) (*JSONResolver, error) {
     31 	for _, cb := range callbacks {
     32 		// Each callback function must satisfy one known function signature, or else we will generate a runtime error instead of silently fail.
     33 		switch cb.(type) {
     34 		case func(context.Context, vocab.ActivityStreamsAccept) error:
     35 			// Do nothing, this callback has a correct signature.
     36 		case func(context.Context, vocab.ActivityStreamsActivity) error:
     37 			// Do nothing, this callback has a correct signature.
     38 		case func(context.Context, vocab.ActivityStreamsAdd) error:
     39 			// Do nothing, this callback has a correct signature.
     40 		case func(context.Context, vocab.ActivityStreamsAnnounce) error:
     41 			// Do nothing, this callback has a correct signature.
     42 		case func(context.Context, vocab.ActivityStreamsApplication) error:
     43 			// Do nothing, this callback has a correct signature.
     44 		case func(context.Context, vocab.ActivityStreamsArrive) error:
     45 			// Do nothing, this callback has a correct signature.
     46 		case func(context.Context, vocab.ActivityStreamsArticle) error:
     47 			// Do nothing, this callback has a correct signature.
     48 		case func(context.Context, vocab.ActivityStreamsAudio) error:
     49 			// Do nothing, this callback has a correct signature.
     50 		case func(context.Context, vocab.ActivityStreamsBlock) error:
     51 			// Do nothing, this callback has a correct signature.
     52 		case func(context.Context, vocab.ForgeFedBranch) error:
     53 			// Do nothing, this callback has a correct signature.
     54 		case func(context.Context, vocab.ActivityStreamsCollection) error:
     55 			// Do nothing, this callback has a correct signature.
     56 		case func(context.Context, vocab.ActivityStreamsCollectionPage) error:
     57 			// Do nothing, this callback has a correct signature.
     58 		case func(context.Context, vocab.ForgeFedCommit) error:
     59 			// Do nothing, this callback has a correct signature.
     60 		case func(context.Context, vocab.ActivityStreamsCreate) error:
     61 			// Do nothing, this callback has a correct signature.
     62 		case func(context.Context, vocab.ActivityStreamsDelete) error:
     63 			// Do nothing, this callback has a correct signature.
     64 		case func(context.Context, vocab.ActivityStreamsDislike) error:
     65 			// Do nothing, this callback has a correct signature.
     66 		case func(context.Context, vocab.ActivityStreamsDocument) error:
     67 			// Do nothing, this callback has a correct signature.
     68 		case func(context.Context, vocab.TootEmoji) error:
     69 			// Do nothing, this callback has a correct signature.
     70 		case func(context.Context, vocab.ActivityStreamsEndpoints) error:
     71 			// Do nothing, this callback has a correct signature.
     72 		case func(context.Context, vocab.ActivityStreamsEvent) error:
     73 			// Do nothing, this callback has a correct signature.
     74 		case func(context.Context, vocab.ActivityStreamsFlag) error:
     75 			// Do nothing, this callback has a correct signature.
     76 		case func(context.Context, vocab.ActivityStreamsFollow) error:
     77 			// Do nothing, this callback has a correct signature.
     78 		case func(context.Context, vocab.ActivityStreamsGroup) error:
     79 			// Do nothing, this callback has a correct signature.
     80 		case func(context.Context, vocab.TootIdentityProof) error:
     81 			// Do nothing, this callback has a correct signature.
     82 		case func(context.Context, vocab.ActivityStreamsIgnore) error:
     83 			// Do nothing, this callback has a correct signature.
     84 		case func(context.Context, vocab.ActivityStreamsImage) error:
     85 			// Do nothing, this callback has a correct signature.
     86 		case func(context.Context, vocab.ActivityStreamsIntransitiveActivity) error:
     87 			// Do nothing, this callback has a correct signature.
     88 		case func(context.Context, vocab.ActivityStreamsInvite) error:
     89 			// Do nothing, this callback has a correct signature.
     90 		case func(context.Context, vocab.ActivityStreamsJoin) error:
     91 			// Do nothing, this callback has a correct signature.
     92 		case func(context.Context, vocab.ActivityStreamsLeave) error:
     93 			// Do nothing, this callback has a correct signature.
     94 		case func(context.Context, vocab.ActivityStreamsLike) error:
     95 			// Do nothing, this callback has a correct signature.
     96 		case func(context.Context, vocab.ActivityStreamsLink) error:
     97 			// Do nothing, this callback has a correct signature.
     98 		case func(context.Context, vocab.ActivityStreamsListen) error:
     99 			// Do nothing, this callback has a correct signature.
    100 		case func(context.Context, vocab.ActivityStreamsMention) error:
    101 			// Do nothing, this callback has a correct signature.
    102 		case func(context.Context, vocab.ActivityStreamsMove) error:
    103 			// Do nothing, this callback has a correct signature.
    104 		case func(context.Context, vocab.ActivityStreamsNote) error:
    105 			// Do nothing, this callback has a correct signature.
    106 		case func(context.Context, vocab.ActivityStreamsObject) error:
    107 			// Do nothing, this callback has a correct signature.
    108 		case func(context.Context, vocab.ActivityStreamsOffer) error:
    109 			// Do nothing, this callback has a correct signature.
    110 		case func(context.Context, vocab.ActivityStreamsOrderedCollection) error:
    111 			// Do nothing, this callback has a correct signature.
    112 		case func(context.Context, vocab.ActivityStreamsOrderedCollectionPage) error:
    113 			// Do nothing, this callback has a correct signature.
    114 		case func(context.Context, vocab.ActivityStreamsOrganization) error:
    115 			// Do nothing, this callback has a correct signature.
    116 		case func(context.Context, vocab.ActivityStreamsPage) error:
    117 			// Do nothing, this callback has a correct signature.
    118 		case func(context.Context, vocab.ActivityStreamsPerson) error:
    119 			// Do nothing, this callback has a correct signature.
    120 		case func(context.Context, vocab.ActivityStreamsPlace) error:
    121 			// Do nothing, this callback has a correct signature.
    122 		case func(context.Context, vocab.ActivityStreamsProfile) error:
    123 			// Do nothing, this callback has a correct signature.
    124 		case func(context.Context, vocab.SchemaPropertyValue) error:
    125 			// Do nothing, this callback has a correct signature.
    126 		case func(context.Context, vocab.W3IDSecurityV1PublicKey) error:
    127 			// Do nothing, this callback has a correct signature.
    128 		case func(context.Context, vocab.ForgeFedPush) error:
    129 			// Do nothing, this callback has a correct signature.
    130 		case func(context.Context, vocab.ActivityStreamsQuestion) error:
    131 			// Do nothing, this callback has a correct signature.
    132 		case func(context.Context, vocab.ActivityStreamsRead) error:
    133 			// Do nothing, this callback has a correct signature.
    134 		case func(context.Context, vocab.ActivityStreamsReject) error:
    135 			// Do nothing, this callback has a correct signature.
    136 		case func(context.Context, vocab.ActivityStreamsRelationship) error:
    137 			// Do nothing, this callback has a correct signature.
    138 		case func(context.Context, vocab.ActivityStreamsRemove) error:
    139 			// Do nothing, this callback has a correct signature.
    140 		case func(context.Context, vocab.ForgeFedRepository) error:
    141 			// Do nothing, this callback has a correct signature.
    142 		case func(context.Context, vocab.ActivityStreamsService) error:
    143 			// Do nothing, this callback has a correct signature.
    144 		case func(context.Context, vocab.ActivityStreamsTentativeAccept) error:
    145 			// Do nothing, this callback has a correct signature.
    146 		case func(context.Context, vocab.ActivityStreamsTentativeReject) error:
    147 			// Do nothing, this callback has a correct signature.
    148 		case func(context.Context, vocab.ForgeFedTicket) error:
    149 			// Do nothing, this callback has a correct signature.
    150 		case func(context.Context, vocab.ForgeFedTicketDependency) error:
    151 			// Do nothing, this callback has a correct signature.
    152 		case func(context.Context, vocab.ActivityStreamsTombstone) error:
    153 			// Do nothing, this callback has a correct signature.
    154 		case func(context.Context, vocab.ActivityStreamsTravel) error:
    155 			// Do nothing, this callback has a correct signature.
    156 		case func(context.Context, vocab.ActivityStreamsUndo) error:
    157 			// Do nothing, this callback has a correct signature.
    158 		case func(context.Context, vocab.ActivityStreamsUpdate) error:
    159 			// Do nothing, this callback has a correct signature.
    160 		case func(context.Context, vocab.ActivityStreamsVideo) error:
    161 			// Do nothing, this callback has a correct signature.
    162 		case func(context.Context, vocab.ActivityStreamsView) error:
    163 			// Do nothing, this callback has a correct signature.
    164 		default:
    165 			return nil, errors.New("a callback function is of the wrong signature and would never be called")
    166 		}
    167 	}
    168 	return &JSONResolver{callbacks: callbacks}, nil
    169 }
    170 
    171 // toAliasMap converts a JSONLD context into a map of vocabulary name to alias.
    172 func toAliasMap(i interface{}) (m map[string]string) {
    173 	m = make(map[string]string)
    174 	toHttpHttpsFn := func(s string) (ok bool, http, https string) {
    175 		if strings.HasPrefix(s, "http://") {
    176 			ok = true
    177 			http = s
    178 			https = "https" + strings.TrimPrefix(s, "http")
    179 		} else if strings.HasPrefix(s, "https://") {
    180 			ok = true
    181 			https = s
    182 			http = "http" + strings.TrimPrefix(s, "https")
    183 		}
    184 		return
    185 	}
    186 	switch v := i.(type) {
    187 	case string:
    188 		// Single entry, no alias.
    189 		if ok, http, https := toHttpHttpsFn(v); ok {
    190 			m[http] = ""
    191 			m[https] = ""
    192 		} else {
    193 			m[v] = ""
    194 		}
    195 	case []interface{}:
    196 		// Recursively apply.
    197 		for _, elem := range v {
    198 			r := toAliasMap(elem)
    199 			for k, val := range r {
    200 				m[k] = val
    201 			}
    202 		}
    203 	case map[string]interface{}:
    204 		// Map any aliases.
    205 		for k, val := range v {
    206 			// Only handle string aliases.
    207 			switch conc := val.(type) {
    208 			case string:
    209 				m[k] = conc
    210 			}
    211 		}
    212 	}
    213 	return
    214 }
    215 
    216 // Resolve determines the ActivityStreams type of the payload, then applies the
    217 // first callback function whose signature accepts the ActivityStreams value's
    218 // type. This strictly assures that the callback function will only be passed
    219 // ActivityStream objects whose type matches its interface. Returns an error
    220 // if the ActivityStreams type does not match callbackers or is not a type
    221 // handled by the generated code. If multiple types are present, it will check
    222 // each one in order and apply only the first one. It returns an unhandled
    223 // error for a multi-typed object if none of the types were able to be handled.
    224 func (this JSONResolver) Resolve(ctx context.Context, m map[string]interface{}) error {
    225 	typeValue, ok := m["type"]
    226 	if !ok {
    227 		return fmt.Errorf("cannot determine ActivityStreams type: 'type' property is missing")
    228 	}
    229 	rawContext, ok := m["@context"]
    230 	if !ok {
    231 		return fmt.Errorf("cannot determine ActivityStreams type: '@context' is missing")
    232 	}
    233 	aliasMap := toAliasMap(rawContext)
    234 	// Begin: Private lambda to handle a single string "type" value. Makes code generation easier.
    235 	handleFn := func(typeString string) error {
    236 		ActivityStreamsAlias, ok := aliasMap["https://www.w3.org/ns/activitystreams"]
    237 		if !ok {
    238 			ActivityStreamsAlias = aliasMap["http://www.w3.org/ns/activitystreams"]
    239 		}
    240 		if len(ActivityStreamsAlias) > 0 {
    241 			ActivityStreamsAlias += ":"
    242 		}
    243 		ForgeFedAlias, ok := aliasMap["https://forgefed.peers.community/ns"]
    244 		if !ok {
    245 			ForgeFedAlias = aliasMap["http://forgefed.peers.community/ns"]
    246 		}
    247 		if len(ForgeFedAlias) > 0 {
    248 			ForgeFedAlias += ":"
    249 		}
    250 		TootAlias, ok := aliasMap["https://joinmastodon.org/ns"]
    251 		if !ok {
    252 			TootAlias = aliasMap["http://joinmastodon.org/ns"]
    253 		}
    254 		if len(TootAlias) > 0 {
    255 			TootAlias += ":"
    256 		}
    257 		SchemaAlias, ok := aliasMap["https://schema.org"]
    258 		if !ok {
    259 			SchemaAlias = aliasMap["http://schema.org"]
    260 		}
    261 		if len(SchemaAlias) > 0 {
    262 			SchemaAlias += ":"
    263 		}
    264 		W3IDSecurityV1Alias, ok := aliasMap["https://w3id.org/security/v1"]
    265 		if !ok {
    266 			W3IDSecurityV1Alias = aliasMap["http://w3id.org/security/v1"]
    267 		}
    268 		if len(W3IDSecurityV1Alias) > 0 {
    269 			W3IDSecurityV1Alias += ":"
    270 		}
    271 
    272 		if typeString == ActivityStreamsAlias+"Accept" {
    273 			v, err := mgr.DeserializeAcceptActivityStreams()(m, aliasMap)
    274 			if err != nil {
    275 				return err
    276 			}
    277 			for _, i := range this.callbacks {
    278 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsAccept) error); ok {
    279 					return fn(ctx, v)
    280 				}
    281 			}
    282 			return ErrNoCallbackMatch
    283 		} else if typeString == ActivityStreamsAlias+"Activity" {
    284 			v, err := mgr.DeserializeActivityActivityStreams()(m, aliasMap)
    285 			if err != nil {
    286 				return err
    287 			}
    288 			for _, i := range this.callbacks {
    289 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsActivity) error); ok {
    290 					return fn(ctx, v)
    291 				}
    292 			}
    293 			return ErrNoCallbackMatch
    294 		} else if typeString == ActivityStreamsAlias+"Add" {
    295 			v, err := mgr.DeserializeAddActivityStreams()(m, aliasMap)
    296 			if err != nil {
    297 				return err
    298 			}
    299 			for _, i := range this.callbacks {
    300 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsAdd) error); ok {
    301 					return fn(ctx, v)
    302 				}
    303 			}
    304 			return ErrNoCallbackMatch
    305 		} else if typeString == ActivityStreamsAlias+"Announce" {
    306 			v, err := mgr.DeserializeAnnounceActivityStreams()(m, aliasMap)
    307 			if err != nil {
    308 				return err
    309 			}
    310 			for _, i := range this.callbacks {
    311 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsAnnounce) error); ok {
    312 					return fn(ctx, v)
    313 				}
    314 			}
    315 			return ErrNoCallbackMatch
    316 		} else if typeString == ActivityStreamsAlias+"Application" {
    317 			v, err := mgr.DeserializeApplicationActivityStreams()(m, aliasMap)
    318 			if err != nil {
    319 				return err
    320 			}
    321 			for _, i := range this.callbacks {
    322 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsApplication) error); ok {
    323 					return fn(ctx, v)
    324 				}
    325 			}
    326 			return ErrNoCallbackMatch
    327 		} else if typeString == ActivityStreamsAlias+"Arrive" {
    328 			v, err := mgr.DeserializeArriveActivityStreams()(m, aliasMap)
    329 			if err != nil {
    330 				return err
    331 			}
    332 			for _, i := range this.callbacks {
    333 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsArrive) error); ok {
    334 					return fn(ctx, v)
    335 				}
    336 			}
    337 			return ErrNoCallbackMatch
    338 		} else if typeString == ActivityStreamsAlias+"Article" {
    339 			v, err := mgr.DeserializeArticleActivityStreams()(m, aliasMap)
    340 			if err != nil {
    341 				return err
    342 			}
    343 			for _, i := range this.callbacks {
    344 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsArticle) error); ok {
    345 					return fn(ctx, v)
    346 				}
    347 			}
    348 			return ErrNoCallbackMatch
    349 		} else if typeString == ActivityStreamsAlias+"Audio" {
    350 			v, err := mgr.DeserializeAudioActivityStreams()(m, aliasMap)
    351 			if err != nil {
    352 				return err
    353 			}
    354 			for _, i := range this.callbacks {
    355 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsAudio) error); ok {
    356 					return fn(ctx, v)
    357 				}
    358 			}
    359 			return ErrNoCallbackMatch
    360 		} else if typeString == ActivityStreamsAlias+"Block" {
    361 			v, err := mgr.DeserializeBlockActivityStreams()(m, aliasMap)
    362 			if err != nil {
    363 				return err
    364 			}
    365 			for _, i := range this.callbacks {
    366 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsBlock) error); ok {
    367 					return fn(ctx, v)
    368 				}
    369 			}
    370 			return ErrNoCallbackMatch
    371 		} else if typeString == ForgeFedAlias+"Branch" {
    372 			v, err := mgr.DeserializeBranchForgeFed()(m, aliasMap)
    373 			if err != nil {
    374 				return err
    375 			}
    376 			for _, i := range this.callbacks {
    377 				if fn, ok := i.(func(context.Context, vocab.ForgeFedBranch) error); ok {
    378 					return fn(ctx, v)
    379 				}
    380 			}
    381 			return ErrNoCallbackMatch
    382 		} else if typeString == ActivityStreamsAlias+"Collection" {
    383 			v, err := mgr.DeserializeCollectionActivityStreams()(m, aliasMap)
    384 			if err != nil {
    385 				return err
    386 			}
    387 			for _, i := range this.callbacks {
    388 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsCollection) error); ok {
    389 					return fn(ctx, v)
    390 				}
    391 			}
    392 			return ErrNoCallbackMatch
    393 		} else if typeString == ActivityStreamsAlias+"CollectionPage" {
    394 			v, err := mgr.DeserializeCollectionPageActivityStreams()(m, aliasMap)
    395 			if err != nil {
    396 				return err
    397 			}
    398 			for _, i := range this.callbacks {
    399 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsCollectionPage) error); ok {
    400 					return fn(ctx, v)
    401 				}
    402 			}
    403 			return ErrNoCallbackMatch
    404 		} else if typeString == ForgeFedAlias+"Commit" {
    405 			v, err := mgr.DeserializeCommitForgeFed()(m, aliasMap)
    406 			if err != nil {
    407 				return err
    408 			}
    409 			for _, i := range this.callbacks {
    410 				if fn, ok := i.(func(context.Context, vocab.ForgeFedCommit) error); ok {
    411 					return fn(ctx, v)
    412 				}
    413 			}
    414 			return ErrNoCallbackMatch
    415 		} else if typeString == ActivityStreamsAlias+"Create" {
    416 			v, err := mgr.DeserializeCreateActivityStreams()(m, aliasMap)
    417 			if err != nil {
    418 				return err
    419 			}
    420 			for _, i := range this.callbacks {
    421 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsCreate) error); ok {
    422 					return fn(ctx, v)
    423 				}
    424 			}
    425 			return ErrNoCallbackMatch
    426 		} else if typeString == ActivityStreamsAlias+"Delete" {
    427 			v, err := mgr.DeserializeDeleteActivityStreams()(m, aliasMap)
    428 			if err != nil {
    429 				return err
    430 			}
    431 			for _, i := range this.callbacks {
    432 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsDelete) error); ok {
    433 					return fn(ctx, v)
    434 				}
    435 			}
    436 			return ErrNoCallbackMatch
    437 		} else if typeString == ActivityStreamsAlias+"Dislike" {
    438 			v, err := mgr.DeserializeDislikeActivityStreams()(m, aliasMap)
    439 			if err != nil {
    440 				return err
    441 			}
    442 			for _, i := range this.callbacks {
    443 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsDislike) error); ok {
    444 					return fn(ctx, v)
    445 				}
    446 			}
    447 			return ErrNoCallbackMatch
    448 		} else if typeString == ActivityStreamsAlias+"Document" {
    449 			v, err := mgr.DeserializeDocumentActivityStreams()(m, aliasMap)
    450 			if err != nil {
    451 				return err
    452 			}
    453 			for _, i := range this.callbacks {
    454 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsDocument) error); ok {
    455 					return fn(ctx, v)
    456 				}
    457 			}
    458 			return ErrNoCallbackMatch
    459 		} else if typeString == TootAlias+"Emoji" {
    460 			v, err := mgr.DeserializeEmojiToot()(m, aliasMap)
    461 			if err != nil {
    462 				return err
    463 			}
    464 			for _, i := range this.callbacks {
    465 				if fn, ok := i.(func(context.Context, vocab.TootEmoji) error); ok {
    466 					return fn(ctx, v)
    467 				}
    468 			}
    469 			return ErrNoCallbackMatch
    470 		} else if typeString == ActivityStreamsAlias+"Endpoints" {
    471 			v, err := mgr.DeserializeEndpointsActivityStreams()(m, aliasMap)
    472 			if err != nil {
    473 				return err
    474 			}
    475 			for _, i := range this.callbacks {
    476 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsEndpoints) error); ok {
    477 					return fn(ctx, v)
    478 				}
    479 			}
    480 			return ErrNoCallbackMatch
    481 		} else if typeString == ActivityStreamsAlias+"Event" {
    482 			v, err := mgr.DeserializeEventActivityStreams()(m, aliasMap)
    483 			if err != nil {
    484 				return err
    485 			}
    486 			for _, i := range this.callbacks {
    487 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsEvent) error); ok {
    488 					return fn(ctx, v)
    489 				}
    490 			}
    491 			return ErrNoCallbackMatch
    492 		} else if typeString == ActivityStreamsAlias+"Flag" {
    493 			v, err := mgr.DeserializeFlagActivityStreams()(m, aliasMap)
    494 			if err != nil {
    495 				return err
    496 			}
    497 			for _, i := range this.callbacks {
    498 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsFlag) error); ok {
    499 					return fn(ctx, v)
    500 				}
    501 			}
    502 			return ErrNoCallbackMatch
    503 		} else if typeString == ActivityStreamsAlias+"Follow" {
    504 			v, err := mgr.DeserializeFollowActivityStreams()(m, aliasMap)
    505 			if err != nil {
    506 				return err
    507 			}
    508 			for _, i := range this.callbacks {
    509 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsFollow) error); ok {
    510 					return fn(ctx, v)
    511 				}
    512 			}
    513 			return ErrNoCallbackMatch
    514 		} else if typeString == ActivityStreamsAlias+"Group" {
    515 			v, err := mgr.DeserializeGroupActivityStreams()(m, aliasMap)
    516 			if err != nil {
    517 				return err
    518 			}
    519 			for _, i := range this.callbacks {
    520 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsGroup) error); ok {
    521 					return fn(ctx, v)
    522 				}
    523 			}
    524 			return ErrNoCallbackMatch
    525 		} else if typeString == TootAlias+"IdentityProof" {
    526 			v, err := mgr.DeserializeIdentityProofToot()(m, aliasMap)
    527 			if err != nil {
    528 				return err
    529 			}
    530 			for _, i := range this.callbacks {
    531 				if fn, ok := i.(func(context.Context, vocab.TootIdentityProof) error); ok {
    532 					return fn(ctx, v)
    533 				}
    534 			}
    535 			return ErrNoCallbackMatch
    536 		} else if typeString == ActivityStreamsAlias+"Ignore" {
    537 			v, err := mgr.DeserializeIgnoreActivityStreams()(m, aliasMap)
    538 			if err != nil {
    539 				return err
    540 			}
    541 			for _, i := range this.callbacks {
    542 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsIgnore) error); ok {
    543 					return fn(ctx, v)
    544 				}
    545 			}
    546 			return ErrNoCallbackMatch
    547 		} else if typeString == ActivityStreamsAlias+"Image" {
    548 			v, err := mgr.DeserializeImageActivityStreams()(m, aliasMap)
    549 			if err != nil {
    550 				return err
    551 			}
    552 			for _, i := range this.callbacks {
    553 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsImage) error); ok {
    554 					return fn(ctx, v)
    555 				}
    556 			}
    557 			return ErrNoCallbackMatch
    558 		} else if typeString == ActivityStreamsAlias+"IntransitiveActivity" {
    559 			v, err := mgr.DeserializeIntransitiveActivityActivityStreams()(m, aliasMap)
    560 			if err != nil {
    561 				return err
    562 			}
    563 			for _, i := range this.callbacks {
    564 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsIntransitiveActivity) error); ok {
    565 					return fn(ctx, v)
    566 				}
    567 			}
    568 			return ErrNoCallbackMatch
    569 		} else if typeString == ActivityStreamsAlias+"Invite" {
    570 			v, err := mgr.DeserializeInviteActivityStreams()(m, aliasMap)
    571 			if err != nil {
    572 				return err
    573 			}
    574 			for _, i := range this.callbacks {
    575 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsInvite) error); ok {
    576 					return fn(ctx, v)
    577 				}
    578 			}
    579 			return ErrNoCallbackMatch
    580 		} else if typeString == ActivityStreamsAlias+"Join" {
    581 			v, err := mgr.DeserializeJoinActivityStreams()(m, aliasMap)
    582 			if err != nil {
    583 				return err
    584 			}
    585 			for _, i := range this.callbacks {
    586 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsJoin) error); ok {
    587 					return fn(ctx, v)
    588 				}
    589 			}
    590 			return ErrNoCallbackMatch
    591 		} else if typeString == ActivityStreamsAlias+"Leave" {
    592 			v, err := mgr.DeserializeLeaveActivityStreams()(m, aliasMap)
    593 			if err != nil {
    594 				return err
    595 			}
    596 			for _, i := range this.callbacks {
    597 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsLeave) error); ok {
    598 					return fn(ctx, v)
    599 				}
    600 			}
    601 			return ErrNoCallbackMatch
    602 		} else if typeString == ActivityStreamsAlias+"Like" {
    603 			v, err := mgr.DeserializeLikeActivityStreams()(m, aliasMap)
    604 			if err != nil {
    605 				return err
    606 			}
    607 			for _, i := range this.callbacks {
    608 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsLike) error); ok {
    609 					return fn(ctx, v)
    610 				}
    611 			}
    612 			return ErrNoCallbackMatch
    613 		} else if typeString == ActivityStreamsAlias+"Link" {
    614 			v, err := mgr.DeserializeLinkActivityStreams()(m, aliasMap)
    615 			if err != nil {
    616 				return err
    617 			}
    618 			for _, i := range this.callbacks {
    619 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsLink) error); ok {
    620 					return fn(ctx, v)
    621 				}
    622 			}
    623 			return ErrNoCallbackMatch
    624 		} else if typeString == ActivityStreamsAlias+"Listen" {
    625 			v, err := mgr.DeserializeListenActivityStreams()(m, aliasMap)
    626 			if err != nil {
    627 				return err
    628 			}
    629 			for _, i := range this.callbacks {
    630 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsListen) error); ok {
    631 					return fn(ctx, v)
    632 				}
    633 			}
    634 			return ErrNoCallbackMatch
    635 		} else if typeString == ActivityStreamsAlias+"Mention" {
    636 			v, err := mgr.DeserializeMentionActivityStreams()(m, aliasMap)
    637 			if err != nil {
    638 				return err
    639 			}
    640 			for _, i := range this.callbacks {
    641 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsMention) error); ok {
    642 					return fn(ctx, v)
    643 				}
    644 			}
    645 			return ErrNoCallbackMatch
    646 		} else if typeString == ActivityStreamsAlias+"Move" {
    647 			v, err := mgr.DeserializeMoveActivityStreams()(m, aliasMap)
    648 			if err != nil {
    649 				return err
    650 			}
    651 			for _, i := range this.callbacks {
    652 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsMove) error); ok {
    653 					return fn(ctx, v)
    654 				}
    655 			}
    656 			return ErrNoCallbackMatch
    657 		} else if typeString == ActivityStreamsAlias+"Note" {
    658 			v, err := mgr.DeserializeNoteActivityStreams()(m, aliasMap)
    659 			if err != nil {
    660 				return err
    661 			}
    662 			for _, i := range this.callbacks {
    663 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsNote) error); ok {
    664 					return fn(ctx, v)
    665 				}
    666 			}
    667 			return ErrNoCallbackMatch
    668 		} else if typeString == ActivityStreamsAlias+"Object" {
    669 			v, err := mgr.DeserializeObjectActivityStreams()(m, aliasMap)
    670 			if err != nil {
    671 				return err
    672 			}
    673 			for _, i := range this.callbacks {
    674 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsObject) error); ok {
    675 					return fn(ctx, v)
    676 				}
    677 			}
    678 			return ErrNoCallbackMatch
    679 		} else if typeString == ActivityStreamsAlias+"Offer" {
    680 			v, err := mgr.DeserializeOfferActivityStreams()(m, aliasMap)
    681 			if err != nil {
    682 				return err
    683 			}
    684 			for _, i := range this.callbacks {
    685 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsOffer) error); ok {
    686 					return fn(ctx, v)
    687 				}
    688 			}
    689 			return ErrNoCallbackMatch
    690 		} else if typeString == ActivityStreamsAlias+"OrderedCollection" {
    691 			v, err := mgr.DeserializeOrderedCollectionActivityStreams()(m, aliasMap)
    692 			if err != nil {
    693 				return err
    694 			}
    695 			for _, i := range this.callbacks {
    696 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsOrderedCollection) error); ok {
    697 					return fn(ctx, v)
    698 				}
    699 			}
    700 			return ErrNoCallbackMatch
    701 		} else if typeString == ActivityStreamsAlias+"OrderedCollectionPage" {
    702 			v, err := mgr.DeserializeOrderedCollectionPageActivityStreams()(m, aliasMap)
    703 			if err != nil {
    704 				return err
    705 			}
    706 			for _, i := range this.callbacks {
    707 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsOrderedCollectionPage) error); ok {
    708 					return fn(ctx, v)
    709 				}
    710 			}
    711 			return ErrNoCallbackMatch
    712 		} else if typeString == ActivityStreamsAlias+"Organization" {
    713 			v, err := mgr.DeserializeOrganizationActivityStreams()(m, aliasMap)
    714 			if err != nil {
    715 				return err
    716 			}
    717 			for _, i := range this.callbacks {
    718 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsOrganization) error); ok {
    719 					return fn(ctx, v)
    720 				}
    721 			}
    722 			return ErrNoCallbackMatch
    723 		} else if typeString == ActivityStreamsAlias+"Page" {
    724 			v, err := mgr.DeserializePageActivityStreams()(m, aliasMap)
    725 			if err != nil {
    726 				return err
    727 			}
    728 			for _, i := range this.callbacks {
    729 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsPage) error); ok {
    730 					return fn(ctx, v)
    731 				}
    732 			}
    733 			return ErrNoCallbackMatch
    734 		} else if typeString == ActivityStreamsAlias+"Person" {
    735 			v, err := mgr.DeserializePersonActivityStreams()(m, aliasMap)
    736 			if err != nil {
    737 				return err
    738 			}
    739 			for _, i := range this.callbacks {
    740 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsPerson) error); ok {
    741 					return fn(ctx, v)
    742 				}
    743 			}
    744 			return ErrNoCallbackMatch
    745 		} else if typeString == ActivityStreamsAlias+"Place" {
    746 			v, err := mgr.DeserializePlaceActivityStreams()(m, aliasMap)
    747 			if err != nil {
    748 				return err
    749 			}
    750 			for _, i := range this.callbacks {
    751 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsPlace) error); ok {
    752 					return fn(ctx, v)
    753 				}
    754 			}
    755 			return ErrNoCallbackMatch
    756 		} else if typeString == ActivityStreamsAlias+"Profile" {
    757 			v, err := mgr.DeserializeProfileActivityStreams()(m, aliasMap)
    758 			if err != nil {
    759 				return err
    760 			}
    761 			for _, i := range this.callbacks {
    762 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsProfile) error); ok {
    763 					return fn(ctx, v)
    764 				}
    765 			}
    766 			return ErrNoCallbackMatch
    767 		} else if typeString == SchemaAlias+"PropertyValue" {
    768 			v, err := mgr.DeserializePropertyValueSchema()(m, aliasMap)
    769 			if err != nil {
    770 				return err
    771 			}
    772 			for _, i := range this.callbacks {
    773 				if fn, ok := i.(func(context.Context, vocab.SchemaPropertyValue) error); ok {
    774 					return fn(ctx, v)
    775 				}
    776 			}
    777 			return ErrNoCallbackMatch
    778 		} else if typeString == W3IDSecurityV1Alias+"PublicKey" {
    779 			v, err := mgr.DeserializePublicKeyW3IDSecurityV1()(m, aliasMap)
    780 			if err != nil {
    781 				return err
    782 			}
    783 			for _, i := range this.callbacks {
    784 				if fn, ok := i.(func(context.Context, vocab.W3IDSecurityV1PublicKey) error); ok {
    785 					return fn(ctx, v)
    786 				}
    787 			}
    788 			return ErrNoCallbackMatch
    789 		} else if typeString == ForgeFedAlias+"Push" {
    790 			v, err := mgr.DeserializePushForgeFed()(m, aliasMap)
    791 			if err != nil {
    792 				return err
    793 			}
    794 			for _, i := range this.callbacks {
    795 				if fn, ok := i.(func(context.Context, vocab.ForgeFedPush) error); ok {
    796 					return fn(ctx, v)
    797 				}
    798 			}
    799 			return ErrNoCallbackMatch
    800 		} else if typeString == ActivityStreamsAlias+"Question" {
    801 			v, err := mgr.DeserializeQuestionActivityStreams()(m, aliasMap)
    802 			if err != nil {
    803 				return err
    804 			}
    805 			for _, i := range this.callbacks {
    806 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsQuestion) error); ok {
    807 					return fn(ctx, v)
    808 				}
    809 			}
    810 			return ErrNoCallbackMatch
    811 		} else if typeString == ActivityStreamsAlias+"Read" {
    812 			v, err := mgr.DeserializeReadActivityStreams()(m, aliasMap)
    813 			if err != nil {
    814 				return err
    815 			}
    816 			for _, i := range this.callbacks {
    817 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsRead) error); ok {
    818 					return fn(ctx, v)
    819 				}
    820 			}
    821 			return ErrNoCallbackMatch
    822 		} else if typeString == ActivityStreamsAlias+"Reject" {
    823 			v, err := mgr.DeserializeRejectActivityStreams()(m, aliasMap)
    824 			if err != nil {
    825 				return err
    826 			}
    827 			for _, i := range this.callbacks {
    828 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsReject) error); ok {
    829 					return fn(ctx, v)
    830 				}
    831 			}
    832 			return ErrNoCallbackMatch
    833 		} else if typeString == ActivityStreamsAlias+"Relationship" {
    834 			v, err := mgr.DeserializeRelationshipActivityStreams()(m, aliasMap)
    835 			if err != nil {
    836 				return err
    837 			}
    838 			for _, i := range this.callbacks {
    839 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsRelationship) error); ok {
    840 					return fn(ctx, v)
    841 				}
    842 			}
    843 			return ErrNoCallbackMatch
    844 		} else if typeString == ActivityStreamsAlias+"Remove" {
    845 			v, err := mgr.DeserializeRemoveActivityStreams()(m, aliasMap)
    846 			if err != nil {
    847 				return err
    848 			}
    849 			for _, i := range this.callbacks {
    850 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsRemove) error); ok {
    851 					return fn(ctx, v)
    852 				}
    853 			}
    854 			return ErrNoCallbackMatch
    855 		} else if typeString == ForgeFedAlias+"Repository" {
    856 			v, err := mgr.DeserializeRepositoryForgeFed()(m, aliasMap)
    857 			if err != nil {
    858 				return err
    859 			}
    860 			for _, i := range this.callbacks {
    861 				if fn, ok := i.(func(context.Context, vocab.ForgeFedRepository) error); ok {
    862 					return fn(ctx, v)
    863 				}
    864 			}
    865 			return ErrNoCallbackMatch
    866 		} else if typeString == ActivityStreamsAlias+"Service" {
    867 			v, err := mgr.DeserializeServiceActivityStreams()(m, aliasMap)
    868 			if err != nil {
    869 				return err
    870 			}
    871 			for _, i := range this.callbacks {
    872 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsService) error); ok {
    873 					return fn(ctx, v)
    874 				}
    875 			}
    876 			return ErrNoCallbackMatch
    877 		} else if typeString == ActivityStreamsAlias+"TentativeAccept" {
    878 			v, err := mgr.DeserializeTentativeAcceptActivityStreams()(m, aliasMap)
    879 			if err != nil {
    880 				return err
    881 			}
    882 			for _, i := range this.callbacks {
    883 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsTentativeAccept) error); ok {
    884 					return fn(ctx, v)
    885 				}
    886 			}
    887 			return ErrNoCallbackMatch
    888 		} else if typeString == ActivityStreamsAlias+"TentativeReject" {
    889 			v, err := mgr.DeserializeTentativeRejectActivityStreams()(m, aliasMap)
    890 			if err != nil {
    891 				return err
    892 			}
    893 			for _, i := range this.callbacks {
    894 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsTentativeReject) error); ok {
    895 					return fn(ctx, v)
    896 				}
    897 			}
    898 			return ErrNoCallbackMatch
    899 		} else if typeString == ForgeFedAlias+"Ticket" {
    900 			v, err := mgr.DeserializeTicketForgeFed()(m, aliasMap)
    901 			if err != nil {
    902 				return err
    903 			}
    904 			for _, i := range this.callbacks {
    905 				if fn, ok := i.(func(context.Context, vocab.ForgeFedTicket) error); ok {
    906 					return fn(ctx, v)
    907 				}
    908 			}
    909 			return ErrNoCallbackMatch
    910 		} else if typeString == ForgeFedAlias+"TicketDependency" {
    911 			v, err := mgr.DeserializeTicketDependencyForgeFed()(m, aliasMap)
    912 			if err != nil {
    913 				return err
    914 			}
    915 			for _, i := range this.callbacks {
    916 				if fn, ok := i.(func(context.Context, vocab.ForgeFedTicketDependency) error); ok {
    917 					return fn(ctx, v)
    918 				}
    919 			}
    920 			return ErrNoCallbackMatch
    921 		} else if typeString == ActivityStreamsAlias+"Tombstone" {
    922 			v, err := mgr.DeserializeTombstoneActivityStreams()(m, aliasMap)
    923 			if err != nil {
    924 				return err
    925 			}
    926 			for _, i := range this.callbacks {
    927 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsTombstone) error); ok {
    928 					return fn(ctx, v)
    929 				}
    930 			}
    931 			return ErrNoCallbackMatch
    932 		} else if typeString == ActivityStreamsAlias+"Travel" {
    933 			v, err := mgr.DeserializeTravelActivityStreams()(m, aliasMap)
    934 			if err != nil {
    935 				return err
    936 			}
    937 			for _, i := range this.callbacks {
    938 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsTravel) error); ok {
    939 					return fn(ctx, v)
    940 				}
    941 			}
    942 			return ErrNoCallbackMatch
    943 		} else if typeString == ActivityStreamsAlias+"Undo" {
    944 			v, err := mgr.DeserializeUndoActivityStreams()(m, aliasMap)
    945 			if err != nil {
    946 				return err
    947 			}
    948 			for _, i := range this.callbacks {
    949 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsUndo) error); ok {
    950 					return fn(ctx, v)
    951 				}
    952 			}
    953 			return ErrNoCallbackMatch
    954 		} else if typeString == ActivityStreamsAlias+"Update" {
    955 			v, err := mgr.DeserializeUpdateActivityStreams()(m, aliasMap)
    956 			if err != nil {
    957 				return err
    958 			}
    959 			for _, i := range this.callbacks {
    960 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsUpdate) error); ok {
    961 					return fn(ctx, v)
    962 				}
    963 			}
    964 			return ErrNoCallbackMatch
    965 		} else if typeString == ActivityStreamsAlias+"Video" {
    966 			v, err := mgr.DeserializeVideoActivityStreams()(m, aliasMap)
    967 			if err != nil {
    968 				return err
    969 			}
    970 			for _, i := range this.callbacks {
    971 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsVideo) error); ok {
    972 					return fn(ctx, v)
    973 				}
    974 			}
    975 			return ErrNoCallbackMatch
    976 		} else if typeString == ActivityStreamsAlias+"View" {
    977 			v, err := mgr.DeserializeViewActivityStreams()(m, aliasMap)
    978 			if err != nil {
    979 				return err
    980 			}
    981 			for _, i := range this.callbacks {
    982 				if fn, ok := i.(func(context.Context, vocab.ActivityStreamsView) error); ok {
    983 					return fn(ctx, v)
    984 				}
    985 			}
    986 			return ErrNoCallbackMatch
    987 		} else {
    988 			return ErrUnhandledType
    989 		}
    990 	}
    991 	// End: Private lambda
    992 	if typeStr, ok := typeValue.(string); ok {
    993 		return handleFn(typeStr)
    994 	} else if typeIArr, ok := typeValue.([]interface{}); ok {
    995 		for _, typeI := range typeIArr {
    996 			if typeStr, ok := typeI.(string); ok {
    997 				if err := handleFn(typeStr); err == nil {
    998 					return nil
    999 				} else if err == ErrUnhandledType {
   1000 					// Keep trying other types: only if all fail do we return this error.
   1001 					continue
   1002 				} else {
   1003 					return err
   1004 				}
   1005 			}
   1006 		}
   1007 		return ErrUnhandledType
   1008 	} else {
   1009 		return ErrUnhandledType
   1010 	}
   1011 }