Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 2s
241 lines
4.8 KiB
TypeScript
241 lines
4.8 KiB
TypeScript
import { CallHistory, MediaCalls } from '@rocket.chat/models';
|
|
|
|
export async function addCallHistoryTestData(uid: string, extraUid: string): Promise<void> {
|
|
const callId1 = 'rocketchat.internal.call.test';
|
|
const callId2 = 'rocketchat.internal.call.test.2';
|
|
const callId3 = 'rocketchat.external.call.test.outbound';
|
|
const callId4 = 'rocketchat.external.call.test.inbound';
|
|
|
|
const extraCallId1 = 'rocketchat.extra.call.test.1';
|
|
const extraCallId2 = 'rocketchat.extra.call.test.2';
|
|
|
|
await CallHistory.deleteMany({ uid });
|
|
await MediaCalls.deleteMany({ _id: { $in: [callId1, callId2, callId3, callId4] } });
|
|
|
|
await CallHistory.insertMany([
|
|
{
|
|
_id: 'rocketchat.internal.history.test.outbound',
|
|
ts: new Date(),
|
|
callId: callId1,
|
|
state: 'ended',
|
|
type: 'media-call',
|
|
duration: 10,
|
|
endedAt: new Date(),
|
|
external: false,
|
|
uid,
|
|
contactId: extraUid,
|
|
direction: 'outbound',
|
|
contactName: 'Pineapple', // random words used for searching
|
|
contactUsername: 'fruit-001',
|
|
},
|
|
{
|
|
_id: 'rocketchat.internal.history.test.inbound',
|
|
ts: new Date(),
|
|
callId: callId2,
|
|
state: 'not-answered',
|
|
type: 'media-call',
|
|
duration: 10,
|
|
endedAt: new Date(),
|
|
external: false,
|
|
uid,
|
|
contactId: extraUid,
|
|
direction: 'inbound',
|
|
contactName: 'Apple',
|
|
contactUsername: 'fruit-002',
|
|
},
|
|
{
|
|
_id: 'rocketchat.internal.history.test.outbound.2',
|
|
ts: new Date(),
|
|
callId: extraCallId1,
|
|
state: 'transferred',
|
|
type: 'media-call',
|
|
duration: 10,
|
|
endedAt: new Date(),
|
|
external: false,
|
|
uid,
|
|
contactId: extraUid,
|
|
direction: 'outbound',
|
|
contactName: 'Grapefruit 002',
|
|
contactUsername: 'username-001',
|
|
},
|
|
{
|
|
_id: 'rocketchat.internal.history.test.inbound.2',
|
|
ts: new Date(),
|
|
callId: extraCallId2,
|
|
state: 'transferred',
|
|
type: 'media-call',
|
|
duration: 10,
|
|
endedAt: new Date(),
|
|
external: false,
|
|
uid,
|
|
contactId: extraUid,
|
|
direction: 'inbound',
|
|
contactName: 'Pasta 1',
|
|
contactUsername: 'meal',
|
|
},
|
|
{
|
|
_id: 'rocketchat.external.history.test.outbound',
|
|
ts: new Date(),
|
|
callId: callId3,
|
|
state: 'failed',
|
|
type: 'media-call',
|
|
duration: 10,
|
|
endedAt: new Date(),
|
|
external: true,
|
|
uid,
|
|
direction: 'outbound',
|
|
contactExtension: '1001',
|
|
},
|
|
{
|
|
_id: 'rocketchat.external.history.test.inbound',
|
|
ts: new Date(),
|
|
callId: callId4,
|
|
state: 'ended',
|
|
type: 'media-call',
|
|
duration: 10,
|
|
endedAt: new Date(),
|
|
external: true,
|
|
uid,
|
|
direction: 'inbound',
|
|
contactExtension: '1002',
|
|
},
|
|
]);
|
|
|
|
await MediaCalls.insertMany([
|
|
{
|
|
_id: callId1,
|
|
service: 'webrtc',
|
|
kind: 'direct',
|
|
state: 'hangup',
|
|
createdBy: {
|
|
type: 'user',
|
|
id: uid,
|
|
},
|
|
createdAt: new Date(),
|
|
caller: {
|
|
type: 'user',
|
|
id: uid,
|
|
contractId: 'contract1',
|
|
},
|
|
callee: {
|
|
type: 'user',
|
|
id: extraUid,
|
|
contractId: 'contract2',
|
|
},
|
|
ended: true,
|
|
endedBy: {
|
|
type: 'user',
|
|
id: uid,
|
|
},
|
|
endedAt: new Date(),
|
|
hangupReason: 'normal',
|
|
expiresAt: new Date(),
|
|
acceptedAt: new Date(),
|
|
activatedAt: new Date(),
|
|
uids: [uid, extraUid],
|
|
features: ['audio'],
|
|
},
|
|
{
|
|
_id: callId2,
|
|
service: 'webrtc',
|
|
kind: 'direct',
|
|
state: 'hangup',
|
|
createdBy: {
|
|
type: 'user',
|
|
id: extraUid,
|
|
},
|
|
createdAt: new Date(),
|
|
caller: {
|
|
type: 'user',
|
|
id: extraUid,
|
|
contractId: 'contract1',
|
|
},
|
|
callee: {
|
|
type: 'user',
|
|
id: uid,
|
|
contractId: 'contract2',
|
|
},
|
|
ended: true,
|
|
endedBy: {
|
|
type: 'user',
|
|
id: uid,
|
|
},
|
|
endedAt: new Date(),
|
|
hangupReason: 'normal',
|
|
expiresAt: new Date(),
|
|
acceptedAt: new Date(),
|
|
activatedAt: new Date(),
|
|
uids: [uid, extraUid],
|
|
features: ['audio'],
|
|
},
|
|
{
|
|
_id: callId3,
|
|
service: 'webrtc',
|
|
kind: 'direct',
|
|
state: 'hangup',
|
|
createdBy: {
|
|
type: 'user',
|
|
id: uid,
|
|
},
|
|
createdAt: new Date(),
|
|
caller: {
|
|
type: 'user',
|
|
id: uid,
|
|
contractId: 'contract1',
|
|
},
|
|
callee: {
|
|
type: 'sip',
|
|
id: '1001',
|
|
contractId: 'contract2',
|
|
},
|
|
ended: true,
|
|
endedBy: {
|
|
type: 'user',
|
|
id: uid,
|
|
},
|
|
endedAt: new Date(),
|
|
hangupReason: 'normal',
|
|
expiresAt: new Date(),
|
|
acceptedAt: new Date(),
|
|
activatedAt: new Date(),
|
|
uids: [uid],
|
|
features: ['audio'],
|
|
sipCallId: 'sipCallId3',
|
|
},
|
|
{
|
|
_id: callId4,
|
|
service: 'webrtc',
|
|
kind: 'direct',
|
|
state: 'hangup',
|
|
createdBy: {
|
|
type: 'sip',
|
|
id: '1001',
|
|
},
|
|
createdAt: new Date(),
|
|
caller: {
|
|
type: 'sip',
|
|
id: '1001',
|
|
contractId: 'contract1',
|
|
},
|
|
callee: {
|
|
type: 'user',
|
|
id: uid,
|
|
contractId: 'contract2',
|
|
},
|
|
ended: true,
|
|
endedBy: {
|
|
type: 'user',
|
|
id: uid,
|
|
},
|
|
endedAt: new Date(),
|
|
hangupReason: 'normal',
|
|
expiresAt: new Date(),
|
|
acceptedAt: new Date(),
|
|
activatedAt: new Date(),
|
|
uids: [uid],
|
|
features: ['audio'],
|
|
sipCallId: 'sipCallId4',
|
|
},
|
|
]);
|
|
}
|