项目文件夹

文件
wehub-resource-sync 4ce4204b6c
CI / Lint (push) Failing after 2s
CI / Build (push) Has been skipped
SDK CI / PHP SDK (push) Failing after 1s
Split PHP SDK / PHP SDK tests (push) Failing after 1s
CI / Test (push) Failing after 1s
CI / Dashboard (push) Failing after 0s
SDK CI / JavaScript SDK (push) Failing after 0s
SDK CI / Python SDK (push) Failing after 2s
SDK CI / Java SDK (push) Failing after 1s
Split PHP SDK / Mirror sdk/php -> rmyndharis/openwa-php (push) Has been skipped
CI / Test (PostgreSQL migrations) (push) Failing after 7m47s
CI / Docker Build (push) Has been skipped
chore: import upstream snapshot with attribution
2026-07-13 12:24:08 +08:00

32 行
1.0 KiB
JavaScript

// Sandbox fixture: registers a search provider whose handler returns canned SearchResults derived from
// the query, so the integration test can assert the full search RPC round-trip
// (host dispatch -> worker handler -> search-result). The handler echoes the query term into the hit.
module.exports = class SearchPlugin {
async onEnable(ctx) {
ctx.registerSearchProvider(async (query) => {
const term = String(query.q || '');
return {
hits: term
? [
{
messageId: 'm1',
waMessageId: 'wamid1',
sessionId: 's1',
chatId: 'c1@c.us',
body: `match for ${term}`,
snippet: `<mark>${term}</mark>`,
timestamp: 1700000000,
type: 'text',
direction: 'outgoing',
from: 'a@c.us',
},
]
: [],
total: term ? 1 : 0,
tookMs: 2,
provider: 'plugin:search-fixture',
};
});
}
};