Skip to main content

Invite strategies

An Invite Strategy determines what happens when a user is invited to a document who is not a member of your database.

An invite strategy can be set with the unknownInviteStrategy setting. See below for the different options.

import CollabServer from '@pdftron/collab-server'
const server = new CollabServer({
unknownInviteStrategy: CollabServer.UnknownInviteStrategies.CREATE
})

Create user#

CollabServer.UnknownInviteStrategies.CREATE

The CREATE invite strategy will add unknown invited users to your Users table as an anonymous user.

Ignore#

CollabServer.UnknownInviteStrategies.IGNORE

The IGNORE invite strategy will ignore any invites to users that are no in your database.

Custom invite strategy#

You can pass a function to the unknownInviteStrategy to handle the unknown invite on your own.

The function will be passed the invited users email.

customUnknownInviteStrategy(email: string): Promise<string | null>

If you return null from your custom function, no further action will be taken (an invite will not be sent to the user by the server). If you return a userID, then an invite will be sent to that user as normal.

Examples

Sending your own custom invite email.

import CollabServer from '@pdftron/collab-server'
const server = new CollabServer({
unknownInviteStrategy: async (email) => {
await sendInviteEmail(email)
// Returning null makes the server do no further actions
return null;
}
})

Creating a user and sending an invite

import CollabServer from '@pdftron/collab-server'
const server = new CollabServer({
unknownInviteStrategy: async (email) => {
const user = await createNewUserFromEmail(email);
// Returning a userId will make the collab server send an invite as usual
return user.id;
}
})