|
|
|
@ -64,6 +64,7 @@ import { |
|
|
|
PREFIX_V3, |
|
|
|
PREFIX_V3, |
|
|
|
retryNetworkOperation, |
|
|
|
retryNetworkOperation, |
|
|
|
UploadContentResponseType, |
|
|
|
UploadContentResponseType, |
|
|
|
|
|
|
|
PREFIX_WATCHA_NEXTCLOUD, // watcha+
|
|
|
|
} from "./http-api"; |
|
|
|
} from "./http-api"; |
|
|
|
import { |
|
|
|
import { |
|
|
|
Crypto, |
|
|
|
Crypto, |
|
|
|
@ -202,6 +203,7 @@ const SCROLLBACK_DELAY_MS = 3000; |
|
|
|
export const CRYPTO_ENABLED: boolean = isCryptoAvailable(); |
|
|
|
export const CRYPTO_ENABLED: boolean = isCryptoAvailable(); |
|
|
|
const CAPABILITIES_CACHE_MS = 21600000; // 6 hours - an arbitrary value
|
|
|
|
const CAPABILITIES_CACHE_MS = 21600000; // 6 hours - an arbitrary value
|
|
|
|
const TURN_CHECK_INTERVAL = 10 * 60 * 1000; // poll for turn credentials every 10 minutes
|
|
|
|
const TURN_CHECK_INTERVAL = 10 * 60 * 1000; // poll for turn credentials every 10 minutes
|
|
|
|
|
|
|
|
const CALENDAR_EVENT_TYPE = "watcha.room.nextcloud_calendar"; // watcha+
|
|
|
|
|
|
|
|
|
|
|
|
interface IExportedDevice { |
|
|
|
interface IExportedDevice { |
|
|
|
olmDevice: IOlmDevice; |
|
|
|
olmDevice: IOlmDevice; |
|
|
|
@ -763,6 +765,26 @@ interface ITimestampToEventResponse { |
|
|
|
event_id: string; |
|
|
|
event_id: string; |
|
|
|
origin_server_ts: string; |
|
|
|
origin_server_ts: string; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// watcha+
|
|
|
|
|
|
|
|
export interface IOwnCalendars { |
|
|
|
|
|
|
|
VEVENT_VTODO: IOwnCalendar[]; |
|
|
|
|
|
|
|
VEVENT: IOwnCalendar[]; |
|
|
|
|
|
|
|
VTODO: IOwnCalendar[]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export interface IOwnCalendar { |
|
|
|
|
|
|
|
id: number; |
|
|
|
|
|
|
|
displayname: string; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export interface ICalendar { |
|
|
|
|
|
|
|
id: number; |
|
|
|
|
|
|
|
displayname: string; |
|
|
|
|
|
|
|
components: string[]; |
|
|
|
|
|
|
|
is_personal: boolean; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// +watcha
|
|
|
|
/* eslint-enable camelcase */ |
|
|
|
/* eslint-enable camelcase */ |
|
|
|
|
|
|
|
|
|
|
|
// We're using this constant for methods overloading and inspect whether a variable
|
|
|
|
// We're using this constant for methods overloading and inspect whether a variable
|
|
|
|
@ -897,6 +919,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa |
|
|
|
protected canSupportVoip = false; |
|
|
|
protected canSupportVoip = false; |
|
|
|
protected peekSync: SyncApi = null; |
|
|
|
protected peekSync: SyncApi = null; |
|
|
|
protected isGuestAccount = false; |
|
|
|
protected isGuestAccount = false; |
|
|
|
|
|
|
|
protected isPartnerAccount = false; // watcha+
|
|
|
|
protected ongoingScrollbacks: {[roomId: string]: {promise?: Promise<Room>, errorTs?: number}} = {}; |
|
|
|
protected ongoingScrollbacks: {[roomId: string]: {promise?: Promise<Room>, errorTs?: number}} = {}; |
|
|
|
protected notifTimelineSet: EventTimelineSet = null; |
|
|
|
protected notifTimelineSet: EventTimelineSet = null; |
|
|
|
protected cryptoStore: CryptoStore; |
|
|
|
protected cryptoStore: CryptoStore; |
|
|
|
@ -1539,6 +1562,24 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa |
|
|
|
this.isGuestAccount = guest; |
|
|
|
this.isGuestAccount = guest; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// watcha+
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Return whether the client is configured for a partner account. |
|
|
|
|
|
|
|
* @return {boolean} True if this is a partner account. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public isPartner(): boolean { |
|
|
|
|
|
|
|
return this.isPartnerAccount; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Set whether this client is a partner account. |
|
|
|
|
|
|
|
* @param {boolean} partner True if this is a partner account. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public setPartner(partner: boolean) { |
|
|
|
|
|
|
|
this.isPartnerAccount = partner; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// +watcha
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return the provided scheduler, if any. |
|
|
|
* Return the provided scheduler, if any. |
|
|
|
* @return {?module:scheduler~MatrixScheduler} The scheduler or null |
|
|
|
* @return {?module:scheduler~MatrixScheduler} The scheduler or null |
|
|
|
@ -4795,7 +4836,10 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa |
|
|
|
{ $roomId: roomId }, |
|
|
|
{ $roomId: roomId }, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* watcha! |
|
|
|
const identityServerUrl = this.getIdentityServerUrl(true); |
|
|
|
const identityServerUrl = this.getIdentityServerUrl(true); |
|
|
|
|
|
|
|
!watcha */ |
|
|
|
|
|
|
|
const identityServerUrl = "fake-is.watcha.fr"; // watcha+ until we have an IS
|
|
|
|
if (!identityServerUrl) { |
|
|
|
if (!identityServerUrl) { |
|
|
|
return Promise.reject(new MatrixError({ |
|
|
|
return Promise.reject(new MatrixError({ |
|
|
|
error: "No supplied identity server URL", |
|
|
|
error: "No supplied identity server URL", |
|
|
|
@ -6402,7 +6446,10 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa |
|
|
|
private async fetchClientWellKnown(): Promise<void> { |
|
|
|
private async fetchClientWellKnown(): Promise<void> { |
|
|
|
// `getRawClientConfig` does not throw or reject on network errors, instead
|
|
|
|
// `getRawClientConfig` does not throw or reject on network errors, instead
|
|
|
|
// it absorbs errors and returns `{}`.
|
|
|
|
// it absorbs errors and returns `{}`.
|
|
|
|
|
|
|
|
/* watcha! |
|
|
|
this.clientWellKnownPromise = AutoDiscovery.getRawClientConfig(this.getDomain()); |
|
|
|
this.clientWellKnownPromise = AutoDiscovery.getRawClientConfig(this.getDomain()); |
|
|
|
|
|
|
|
!watcha */ |
|
|
|
|
|
|
|
this.clientWellKnownPromise = AutoDiscovery.getRawClientConfig(window.location.hostname); // watcha+
|
|
|
|
this.clientWellKnown = await this.clientWellKnownPromise; |
|
|
|
this.clientWellKnown = await this.clientWellKnownPromise; |
|
|
|
this.emit(ClientEvent.ClientWellKnown, this.clientWellKnown); |
|
|
|
this.emit(ClientEvent.ClientWellKnown, this.clientWellKnown); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -7744,7 +7791,11 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa |
|
|
|
info?: string, |
|
|
|
info?: string, |
|
|
|
callback?: Callback, |
|
|
|
callback?: Callback, |
|
|
|
// eslint-disable-next-line camelcase
|
|
|
|
// eslint-disable-next-line camelcase
|
|
|
|
|
|
|
|
/* watcha! |
|
|
|
): Promise<{ avatar_url?: string, displayname?: string }> { |
|
|
|
): Promise<{ avatar_url?: string, displayname?: string }> { |
|
|
|
|
|
|
|
!watcha */ |
|
|
|
|
|
|
|
/* eslint-disable-next-line camelcase */// watcha+
|
|
|
|
|
|
|
|
): Promise<{ avatar_url?: string, displayname?: string, email: string }> { // watcha+ until we have an IS
|
|
|
|
if (utils.isFunction(info)) { |
|
|
|
if (utils.isFunction(info)) { |
|
|
|
callback = info as any as Callback; // legacy
|
|
|
|
callback = info as any as Callback; // legacy
|
|
|
|
info = undefined; |
|
|
|
info = undefined; |
|
|
|
@ -8908,6 +8959,74 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa |
|
|
|
return new MSC3089TreeSpace(this, roomId); |
|
|
|
return new MSC3089TreeSpace(this, roomId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// watcha+
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @return {Promise<IOwnCalendars>} |
|
|
|
|
|
|
|
* @return {module:http-api.MatrixError} Rejects: with an error response. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public getOwnCalendars(): Promise<IOwnCalendars> { |
|
|
|
|
|
|
|
return this.http.authedRequest(undefined, Method.Get, "/calendars", undefined, undefined, { |
|
|
|
|
|
|
|
prefix: PREFIX_WATCHA_NEXTCLOUD, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @param {number} calendarId |
|
|
|
|
|
|
|
* @return {Promise<ICalendar>} |
|
|
|
|
|
|
|
* @return {module:http-api.MatrixError} Rejects: with an error response. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public getCalendar(calendarId: number): Promise<ICalendar> { |
|
|
|
|
|
|
|
const path = utils.encodeUri("/calendars/$calendarId", { |
|
|
|
|
|
|
|
$calendarId: calendarId.toString(), |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return this.http.authedRequest(undefined, Method.Get, path, undefined, undefined, { |
|
|
|
|
|
|
|
prefix: PREFIX_WATCHA_NEXTCLOUD, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @param {number} calendarId |
|
|
|
|
|
|
|
* @return {Promise<{}>} |
|
|
|
|
|
|
|
* @return {module:http-api.MatrixError} Rejects: with an error response. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public reorderCalendars(calendarId: string): Promise<{}> { |
|
|
|
|
|
|
|
const path = utils.encodeUri("/calendars/$calendarId/top", { |
|
|
|
|
|
|
|
$calendarId: calendarId.toString(), |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return this.http.authedRequest(undefined, Method.Put, path, undefined, undefined, { |
|
|
|
|
|
|
|
prefix: PREFIX_WATCHA_NEXTCLOUD, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @param {string} roomId |
|
|
|
|
|
|
|
* @param {number} calendarId Optional. |
|
|
|
|
|
|
|
* @return {Promise<ISendEventResponse>} |
|
|
|
|
|
|
|
* @return {module:http-api.MatrixError} Rejects: with an error response. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public async setRoomCalendar( |
|
|
|
|
|
|
|
roomId: string, |
|
|
|
|
|
|
|
calendarId: number = null, |
|
|
|
|
|
|
|
): Promise<ISendEventResponse> { |
|
|
|
|
|
|
|
return this.sendStateEvent(roomId, CALENDAR_EVENT_TYPE, { |
|
|
|
|
|
|
|
id: calendarId, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @param {string} roomId |
|
|
|
|
|
|
|
* @param {string} stateKey |
|
|
|
|
|
|
|
* @return {Promise<ISendEventResponse>} |
|
|
|
|
|
|
|
* @return {module:http-api.MatrixError} Rejects: with an error response. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public async unsetRoomCalendar( |
|
|
|
|
|
|
|
roomId: string, |
|
|
|
|
|
|
|
stateKey: string, |
|
|
|
|
|
|
|
): Promise<ISendEventResponse> { |
|
|
|
|
|
|
|
return this.sendStateEvent(roomId, CALENDAR_EVENT_TYPE, {}, stateKey); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// +watcha
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @experimental |
|
|
|
* @experimental |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|