func NewInbox(cfg *Config, s store.Store, outbox service.Outbox,
	activityPubClient activityPubClient, opts ...service.HandlerOpt) *Inbox {
	options := defaultOptions()
	for _, opt := range opts {
		opt(options)
	}
	followersIRI, err := url.Parse(cfg.ServiceIRI.String() + resthandler.FollowersPath)
	if err != nil {
		panic(fmt.Errorf("followers IRI: %w", err))
	}
	h := &Inbox{
		outbox:       outbox,
		Handlers:     options,
		followersIRI: followersIRI,
	}
	h.handler = newHandler(cfg, s, activityPubClient,
		func(activity *vocab.ActivityType) error {
			return h.undoAddReference(activity, store.Follower, func() *url.URL {
				return activity.Object().IRI()
			})
		},
		func(activity *vocab.ActivityType) error {
			return h.undoAddReference(activity, store.Witnessing, func() *url.URL {
				return activity.Target().IRI()
			})
		},
		h.inboxUndoLike,
	)
	return h
}
NewInbox returns a new ActivityPub inbox activity handler.
package activityhandler
import (
	"encoding/json"
	"errors"
	"fmt"
	"net/url"
	"time"
	"github.com/trustbloc/orb/pkg/activitypub/resthandler"
	service "github.com/trustbloc/orb/pkg/activitypub/service/spi"
	store "github.com/trustbloc/orb/pkg/activitypub/store/spi"
	"github.com/trustbloc/orb/pkg/activitypub/store/storeutil"
	"github.com/trustbloc/orb/pkg/activitypub/vocab"
	orberrors "github.com/trustbloc/orb/pkg/errors"
	"github.com/trustbloc/orb/pkg/hashlink"
)
var errDuplicateAnchorEvent = errors.New("anchor event already handled")
type Inbox struct {
	*handler
	*service.Handlers
	outbox       service.Outbox
	followersIRI *url.URL
}