Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:wireapp/wire-webapp into in-call-han…
Browse files Browse the repository at this point in the history
…d-raise
  • Loading branch information
thisisamir98 committed Dec 4, 2024
2 parents 3566c23 + ce47d8f commit 180cfd5
Show file tree
Hide file tree
Showing 13 changed files with 329 additions and 105 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"@lexical/history": "0.20.2",
"@lexical/react": "0.20.2",
"@mediapipe/tasks-vision": "0.10.18",
"@wireapp/avs": "9.10.16",
"@wireapp/avs": "10.0.4",
"@wireapp/avs-debugger": "0.0.5",
"@wireapp/commons": "5.4.0",
"@wireapp/core": "46.11.4",
"@wireapp/react-ui-kit": "9.28.0",
Expand Down
174 changes: 99 additions & 75 deletions src/script/backup/CrossPlatformBackup/CPB.export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,103 +63,127 @@ export const exportCPBHistoryFromDatabase = async ({
}

// Taking care of conversations
const conversationsData = ConversationTableSchema.parse(
const {
success: conversationsSuccess,
data: conversationsData,
error: conversationsError,
} = ConversationTableSchema.safeParse(
await exportTable<ConversationRecord>({
backupService,
table: conversationTable,
preprocessor: streamProgress(preprocessConversations),
}),
);
conversationsData.forEach(conversationData =>
backupExporter.addConversation(
new BackUpConversation(
new BackupQualifiedId(conversationData.id, conversationData.domain),
conversationData.name ?? '',
if (conversationsSuccess) {
conversationsData.forEach(conversationData =>
backupExporter.addConversation(
new BackUpConversation(
new BackupQualifiedId(conversationData.id, conversationData.domain),
conversationData.name ?? '',
),
),
),
);
);
} else {
CPBLogger.log('Conversation data schema validation failed', conversationsError);
}

// Taking care of users
const usersData = UserTableSchema.parse(
const {
success: usersSuccess,
data: usersData,
error: usersError,
} = UserTableSchema.safeParse(
await exportTable<UserRecord>({backupService, table: usersTable, preprocessor: streamProgress(preprocessUsers)}),
);
usersData.forEach(userData =>
backupExporter.addUser(
new BackupUser(
new BackupQualifiedId(userData?.qualified_id?.id ?? userData.id, userData?.qualified_id?.domain ?? ''),
userData.name,
userData.handle ?? '',
if (usersSuccess) {
usersData.forEach(userData =>
backupExporter.addUser(
new BackupUser(
new BackupQualifiedId(userData?.qualified_id?.id ?? userData.id, userData?.qualified_id?.domain ?? ''),
userData.name,
userData.handle ?? '',
),
),
),
);
);
} else {
CPBLogger.log('User data schema validation failed', usersError);
}

// Taking care of events
const eventsData = EventTableSchema.parse(
const {
success: eventsSuccess,
data: eventsData,
error: eventsError,
} = EventTableSchema.safeParse(
await exportTable<EventRecord>({backupService, table: eventsTable, preprocessor: streamProgress(preprocessEvents)}),
);
eventsData.forEach(eventData => {
const {type} = eventData;
// ToDo: Add support for other types of messages and different types of content. Also figure out which fields are required.
if (!isSupportedEventType(type)) {
// eslint-disable-next-line no-console
CPBLogger.log('Unsupported message type', type);
return;
}
if (!eventData.id) {
// eslint-disable-next-line no-console
CPBLogger.log('Event without id', eventData);
return;
}

const id = eventData.id;
const conversationId = new BackupQualifiedId(
eventData.qualified_conversation.id,
eventData.qualified_conversation.domain ?? '',
);
const senderUserId = new BackupQualifiedId(
eventData.qualified_from?.id ?? eventData.from ?? '',
eventData.qualified_from?.domain ?? '',
);
const senderClientId = eventData.from_client_id ?? '';
const creationDate = new BackupDateTime(new Date(eventData.time));
// for debugging purposes
const webPrimaryKey = eventData.primary_key;

if (isAssetAddEvent(type)) {
const {success, error, data} = AssetContentSchema.safeParse(eventData.data);
if (!success) {
CPBLogger.log('Asset data schema validation failed', error);
if (eventsSuccess) {
eventsData.forEach(eventData => {
const {type} = eventData;
// ToDo: Add support for other types of messages and different types of content. Also figure out which fields are required.
if (!isSupportedEventType(type)) {
// eslint-disable-next-line no-console
CPBLogger.log('Unsupported message type', type);
return;
}
if (!eventData.id) {
// eslint-disable-next-line no-console
CPBLogger.log('Event without id', eventData);
return;
}

const metaData = buildMetaData(data.content_type, data.info);

CPBLogger.log('metaData', metaData, data.content_type);

const asset = new BackupMessageContent.Asset(
data.content_type,
data.content_length,
data.info.name,
transformObjectToArray(data.otr_key),
transformObjectToArray(data.sha256),
data.key,
data.token,
data.domain,
null,
metaData,
const id = eventData.id;
const conversationId = new BackupQualifiedId(
eventData.qualified_conversation.id,
eventData.qualified_conversation.domain ?? '',
);
backupExporter.addMessage(
new BackupMessage(id, conversationId, senderUserId, senderClientId, creationDate, asset, webPrimaryKey),
const senderUserId = new BackupQualifiedId(
eventData.qualified_from?.id ?? eventData.from ?? '',
eventData.qualified_from?.domain ?? '',
);
}
const senderClientId = eventData.from_client_id ?? '';
const creationDate = new BackupDateTime(new Date(eventData.time));
// for debugging purposes
const webPrimaryKey = eventData.primary_key;

if (isAssetAddEvent(type)) {
const {success, error, data} = AssetContentSchema.safeParse(eventData.data);
if (!success) {
CPBLogger.log('Asset data schema validation failed', error);
return;
}

const metaData = buildMetaData(data.content_type, data.info);

CPBLogger.log('metaData', metaData, data.content_type);

const asset = new BackupMessageContent.Asset(
data.content_type,
data.content_length,
data.info.name,
transformObjectToArray(data.otr_key),
transformObjectToArray(data.sha256),
data.key,
data.token,
data.domain,
null,
metaData,
);
backupExporter.addMessage(
new BackupMessage(id, conversationId, senderUserId, senderClientId, creationDate, asset, webPrimaryKey),
);
}

if (isMessageAddEvent(type) && eventData.data?.content) {
const text = new BackupMessageContent.Text(eventData.data.content);
backupExporter.addMessage(
new BackupMessage(id, conversationId, senderUserId, senderClientId, creationDate, text, webPrimaryKey),
);
}
});
if (isMessageAddEvent(type) && eventData.data?.content) {
const text = new BackupMessageContent.Text(eventData.data.content);
backupExporter.addMessage(
new BackupMessage(id, conversationId, senderUserId, senderClientId, creationDate, text, webPrimaryKey),
);
}
});
} else {
CPBLogger.log('Event data schema validation failed', eventsError);
}

return backupExporter.serialize();
};
2 changes: 1 addition & 1 deletion src/script/backup/CrossPlatformBackup/data.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const ConversationSchema = zod.object({
accessRoleV2: zod.string().optional(),
archived_state: zod.boolean(),
archived_timestamp: zod.number(),
cipher_suite: zod.string().optional(),
cipher_suite: zod.number().optional(),
creator: zod.string(),
domain: zod.string(),
group_id: zod.string().optional(),
Expand Down
2 changes: 1 addition & 1 deletion src/script/calling/Call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class Call {
public blockMessages: boolean = false;
public currentPage: ko.Observable<number> = ko.observable(0);
public pages: ko.ObservableArray<Participant[]> = ko.observableArray();
readonly maximizedParticipant: ko.Observable<Participant | null>;
public readonly maximizedParticipant: ko.Observable<Participant | null>;
public readonly isActive: ko.PureComputed<boolean>;

private readonly audios: Record<string, {audioElement: HTMLAudioElement; stream: MediaStream}> = {};
Expand Down
13 changes: 11 additions & 2 deletions src/script/calling/CallState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ export class CallState {
public readonly activeCalls: ko.PureComputed<Call[]>;
public readonly joinedCall: ko.PureComputed<Call | undefined>;
public readonly activeCallViewTab = ko.observable(CallViewTab.ALL);
readonly hasAvailableScreensToShare: ko.PureComputed<boolean>;
readonly isSpeakersViewActive: ko.PureComputed<boolean>;
public readonly hasAvailableScreensToShare: ko.PureComputed<boolean>;
public readonly isSpeakersViewActive: ko.PureComputed<boolean>;
public readonly isMaximisedViewActive: ko.PureComputed<boolean>;
public readonly viewMode = ko.observable<CallingViewMode>(CallingViewMode.MINIMIZED);
public readonly detachedWindow = ko.observable<Window | null>(null);
public readonly isScreenSharingSourceFromDetachedWindow = ko.observable<boolean>(false);
Expand All @@ -96,6 +97,14 @@ export class CallState {
});
this.isSpeakersViewActive = ko.pureComputed(() => this.activeCallViewTab() === CallViewTab.SPEAKERS);

this.isMaximisedViewActive = ko.pureComputed(() => {
const call = this.joinedCall();
if (!call) {
return false;
}
return call.maximizedParticipant() !== null;
});

this.hasAvailableScreensToShare = ko.pureComputed(
() => this.selectableScreens().length > 0 || this.selectableWindows().length > 0,
);
Expand Down
Loading

0 comments on commit 180cfd5

Please sign in to comment.