bootdesk/chat-sdk

WebAdapterConfig
in package

Configuration class for WebAdapter.

Extend this class and override only the methods you need. All methods return safe defaults so minimal configuration is required.

Tags
example
class MyAppWebConfig extends WebAdapterConfig
{
    public function getUser(ServerRequestInterface $request): ?array
    {
        $session = $request->getAttribute('session');
        return $session ? ['id' => $session->get('user_id'), 'name' => $session->get('user_name')] : null;
    }

    public function verifySignature(ServerRequestInterface $request): bool|string
    {
        $signature = $request->getHeaderLine('X-Chat-Signature');
        return hash_equals($this->expectedSignature, $signature) ? true : 'Invalid signature';
    }
}

Table of Contents

Methods

fetchChannelInfo()  : ChannelInfo|null
Fetch channel info.
fetchMessages()  : FetchResult
Fetch messages for a conversation.
fetchThread()  : ThreadInfo
Fetch thread info for a conversation.
getAuthorInfo()  : Author
Resolve author info (locale, language, timezone) for a user.
getUser()  : array{id: string, name?: string}|null
Resolve the current user from the request.
threadIdFor()  : string
Build a thread ID from user and conversation identifiers.
verifySignature()  : true|string
Verify the request signature/authenticity.

Methods

fetchChannelInfo()

Fetch channel info.

public fetchChannelInfo(string $channelId) : ChannelInfo|null

Override to provide custom channel details. The channel ID should use the canonical format "web:{userId}:{conversationId}".

Parameters
$channelId : string

Channel ID (format: "web:{userId}:{conversationId}").

Return values
ChannelInfo|null

fetchMessages()

Fetch messages for a conversation.

public fetchMessages(string $threadId[, FetchOptions|null $options = null ]) : FetchResult

Override to provide custom message history.

Parameters
$threadId : string

Canonical thread ID (format: "web:{userId}:{conversationId}").

$options : FetchOptions|null = null

Fetch options for pagination.

Return values
FetchResult

fetchThread()

Fetch thread info for a conversation.

public fetchThread(string $threadId) : ThreadInfo

Override to provide custom thread details. Both the id and channelId in the returned ThreadInfo should use the canonical format "web:{userId}:{conversationId}".

Parameters
$threadId : string

Canonical thread ID (format: "web:{userId}:{conversationId}").

Return values
ThreadInfo

getAuthorInfo()

Resolve author info (locale, language, timezone) for a user.

public getAuthorInfo(Author $author) : Author

Override to return an enriched Author with localization data from your database, session, or API.

Parameters
$author : Author
Return values
Author

getUser()

Resolve the current user from the request.

public getUser(ServerRequestInterface $request) : array{id: string, name?: string}|null
Parameters
$request : ServerRequestInterface
Return values
array{id: string, name?: string}|null

User data or null if unauthenticated

threadIdFor()

Build a thread ID from user and conversation identifiers.

public threadIdFor(string $userId, string $conversationId) : string
Parameters
$userId : string

The resolved user ID

$conversationId : string

The conversation ID from the request

Return values
string

verifySignature()

Verify the request signature/authenticity.

public verifySignature(ServerRequestInterface $request) : true|string
Parameters
$request : ServerRequestInterface
Return values
true|string

True if valid, or an error message string if invalid

On this page

Search results