threema.d.ts 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  1. /**
  2. * This file is part of Threema Web.
  3. *
  4. * Threema Web is free software: you can redistribute it and/or modify it
  5. * under the terms of the GNU Affero General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or (at
  7. * your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Affero General Public License
  15. * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. declare const angular: ng.IAngularStatic;
  18. declare namespace threema {
  19. interface Avatar {
  20. // Low resolution avatar URI
  21. low?: ArrayBuffer;
  22. // High resolution avatar URI
  23. high?: ArrayBuffer;
  24. }
  25. interface WireMessageAcknowledgement {
  26. id: string,
  27. success: boolean,
  28. error?: string,
  29. }
  30. /**
  31. * Messages that are sent through the secure data channel as encrypted msgpack bytes.
  32. */
  33. interface WireMessage {
  34. type: string;
  35. subType: string;
  36. id?: string;
  37. ack?: WireMessageAcknowledgement;
  38. args?: any;
  39. data?: any;
  40. }
  41. type MessageType = 'text' | 'image' | 'video' | 'audio' | 'location' | 'contact' |
  42. 'status' | 'ballot' | 'file' | 'voipStatus' | 'unknown';
  43. type MessageState = 'delivered' | 'read' | 'send-failed' | 'sent' | 'user-ack' |
  44. 'user-dec' | 'pending' | 'timeout' | 'sending';
  45. const enum InitializationStep {
  46. ClientInfo = 'client info',
  47. Conversations = 'conversations',
  48. Receivers = 'receivers',
  49. Profile = 'profile',
  50. }
  51. interface InitializationStepRoutine {
  52. requiredSteps: InitializationStep[];
  53. callback: any;
  54. }
  55. interface Thumbnail {
  56. img?: string;
  57. preview: ArrayBuffer;
  58. width: number;
  59. height: number;
  60. }
  61. const enum EventType {
  62. Created = 'created',
  63. Sent = 'sent',
  64. Delivered = 'delivered',
  65. Read = 'read',
  66. Acked = 'acked',
  67. Modified = 'modified',
  68. }
  69. /**
  70. * A message event, e.g. when it was delivered, read or modified.
  71. */
  72. interface MessageEvent {
  73. // The event type
  74. type: EventType;
  75. // Unix timestamp in seconds
  76. date: number;
  77. }
  78. /**
  79. * A Threema chat message.
  80. */
  81. interface Message {
  82. type: MessageType;
  83. id: string;
  84. body: string;
  85. thumbnail?: Thumbnail;
  86. date?: number;
  87. events?: MessageEvent[];
  88. sortKey: number;
  89. partnerId: string;
  90. isOutbox: boolean;
  91. isStatus: boolean;
  92. caption?: string;
  93. statusType?: 'text' | 'firstUnreadMessage';
  94. unread?: boolean;
  95. state?: MessageState;
  96. quote?: Quote;
  97. file?: FileInfo;
  98. video?: VideoInfo;
  99. audio?: AudioInfo;
  100. voip?: VoipStatusInfo;
  101. location?: LocationInfo;
  102. // only for temporary Messages
  103. temporaryId?: string;
  104. errorMessage?: string;
  105. }
  106. interface FileInfo {
  107. description: string;
  108. name: string;
  109. size: number;
  110. type: string;
  111. inApp: boolean;
  112. }
  113. interface VideoInfo {
  114. duration: number;
  115. size?: number;
  116. }
  117. interface AudioInfo {
  118. duration: number;
  119. }
  120. const enum VoipStatus {
  121. Missed = 1,
  122. Finished = 2,
  123. Rejected = 3,
  124. Aborted = 4,
  125. }
  126. const enum VoipRejectReason {
  127. Unknown = 0,
  128. Busy = 1,
  129. Timeout = 2,
  130. Rejected = 3,
  131. }
  132. interface VoipStatusInfo {
  133. status: VoipStatus;
  134. duration?: number;
  135. reason?: VoipRejectReason;
  136. }
  137. interface LocationInfo {
  138. lat: number;
  139. lon: number;
  140. accuracy: number;
  141. description: string;
  142. address?: string;
  143. }
  144. interface BlobInfo {
  145. buffer: ArrayBuffer;
  146. mimetype: string;
  147. filename: string;
  148. }
  149. /**
  150. * All possible receiver types.
  151. */
  152. type ReceiverType = 'me' | 'contact' | 'group' | 'distributionList';
  153. /**
  154. * Access Object for receivers
  155. */
  156. interface ReceiverAccess {
  157. canDelete?: boolean;
  158. }
  159. interface ContactReceiverAccess extends ReceiverAccess {
  160. canChangeAvatar: boolean;
  161. canChangeFirstName: boolean;
  162. canChangeLastName: boolean;
  163. }
  164. interface GroupReceiverAccess extends ReceiverAccess {
  165. canChangeAvatar: boolean;
  166. canChangeName: boolean;
  167. canChangeMembers?: boolean;
  168. canLeave?: boolean;
  169. canSync?: boolean;
  170. }
  171. interface DistributionListReceiverAccess extends ReceiverAccess {
  172. canChangeMembers?: boolean;
  173. }
  174. const enum IdentityType {
  175. Regular = 0,
  176. Work = 1,
  177. }
  178. /**
  179. * The base class for a receiver. Only type and id.
  180. */
  181. interface BaseReceiver {
  182. id: string;
  183. type: ReceiverType;
  184. }
  185. /**
  186. * A generic receiver.
  187. *
  188. * Note that the id is not unique for all receivers, only for all receivers
  189. * of a certain type. The primary key for a receiver is the tuple (type, id).
  190. */
  191. interface Receiver extends BaseReceiver {
  192. // The display name
  193. displayName: string;
  194. // The color used for the avatar
  195. color: string;
  196. // The avatar, may be set if already fetched
  197. avatar?: Avatar;
  198. // Permissions towards this receiver
  199. access: ReceiverAccess;
  200. // Whether the chat with this receiver is locked. Used for private chats.
  201. locked: boolean;
  202. // Whether the chat with this receiver is visible. Used for private chats.
  203. visible: boolean;
  204. }
  205. /**
  206. * A contact.
  207. */
  208. interface ContactReceiver extends Receiver {
  209. // Flag indicating whether this is the own profile or another contact
  210. type: 'contact' | 'me';
  211. // Public nickname, if set
  212. publicNickname?: string;
  213. // First name, if set
  214. firstName?: string;
  215. // Last name, if set
  216. lastName?: string;
  217. // Verification level integer (1-3)
  218. verificationLevel?: number;
  219. // Feature mask
  220. featureMask: number | null;
  221. // The identity state
  222. state: 'ACTIVE' | 'INACTIVE';
  223. // Contact hidden?
  224. hidden: boolean;
  225. // The Threema public key
  226. publicKey: ArrayBuffer;
  227. // System confact information
  228. systemContact?: SystemContact;
  229. // Permissions towards this contact
  230. access: ContactReceiverAccess;
  231. // Whether this is a contact from the same Threema Work package.
  232. // Only relevant for Threema Work users.
  233. isWork?: boolean;
  234. // Whether this contact is blocked
  235. isBlocked?: boolean;
  236. // The identity type.
  237. // 0 - Regular Threema user.
  238. // 1 - Threema Work user.
  239. identityType?: IdentityType;
  240. }
  241. /**
  242. * Own contact.
  243. */
  244. interface MeReceiver extends ContactReceiver {
  245. type: 'me';
  246. }
  247. /**
  248. * A group.
  249. */
  250. interface GroupReceiver extends Receiver {
  251. type: 'group';
  252. disabled: boolean;
  253. members: string[];
  254. administrator: string;
  255. access: GroupReceiverAccess;
  256. createdAt: number;
  257. }
  258. /**
  259. * A distribution list.
  260. */
  261. interface DistributionListReceiver extends Receiver {
  262. type: 'distributionList';
  263. members: string[];
  264. access: DistributionListReceiverAccess;
  265. }
  266. interface SystemContact {
  267. emails?: SystemContactEmail[];
  268. phoneNumbers?: SystemContactPhone[];
  269. }
  270. interface SystemContactEmail {
  271. label: string;
  272. address: string;
  273. }
  274. interface SystemContactPhone {
  275. label: string;
  276. number: string;
  277. }
  278. /**
  279. * A conversation.
  280. */
  281. interface Conversation {
  282. type: ReceiverType;
  283. id: string;
  284. position?: number;
  285. messageCount: number;
  286. unreadCount: number;
  287. latestMessage: Message | null;
  288. receiver?: Receiver;
  289. avatar?: ArrayBuffer;
  290. notifications?: NotificationSettings;
  291. isStarred?: boolean;
  292. }
  293. /**
  294. * A conversation with a position field, used for updating a conversation.
  295. */
  296. interface ConversationWithPosition extends Conversation {
  297. position: number;
  298. }
  299. interface NotificationSettings {
  300. sound: NotificationSound;
  301. dnd: NotificationDnd;
  302. }
  303. interface NotificationSound {
  304. mode: NotificationSoundMode;
  305. }
  306. const enum NotificationSoundMode {
  307. Default = 'default',
  308. Muted = 'muted',
  309. }
  310. interface NotificationDnd {
  311. mode: NotificationDndMode;
  312. mentionOnly?: boolean;
  313. until?: number;
  314. }
  315. const enum NotificationDndMode {
  316. Off = 'off',
  317. On = 'on',
  318. Until = 'until',
  319. }
  320. /**
  321. * A form of the notification settings where things like the "until" mode
  322. * have been processed already.
  323. */
  324. interface SimplifiedNotificationSettings {
  325. sound: {
  326. muted: boolean,
  327. };
  328. dnd: {
  329. enabled: boolean,
  330. mentionOnly: boolean,
  331. };
  332. }
  333. /**
  334. * Connection state in the welcome dialog.
  335. *
  336. * States:
  337. *
  338. * - new: Initial state
  339. * - connecting: Connecting to signaling server
  340. * - push: When trying to reconnect, waiting for push notification to arrive
  341. * - manual_start: When trying to reconnect, waiting for manual session start
  342. * - already_connected: When the user is already connected in another tab or window
  343. * - waiting: Waiting for new-responder message from signaling server
  344. * - peer_handshake: Doing SaltyRTC handshake with the peer
  345. * - loading: Loading initial data
  346. * - done: Initial loading is finished
  347. * - closed: Connection is closed
  348. * - reconnect_failed: Reconnecting failed after several attempts
  349. *
  350. */
  351. type ConnectionBuildupState = 'new' | 'connecting' | 'push' | 'manual_start' | 'already_connected'
  352. | 'waiting' | 'peer_handshake' | 'loading' | 'done' | 'closed' | 'reconnect_failed';
  353. interface ConnectionBuildupStateChange {
  354. state: ConnectionBuildupState;
  355. prevState: ConnectionBuildupState;
  356. }
  357. /**
  358. * Connection state of the task peer connection.
  359. */
  360. const enum TaskConnectionState {
  361. New = 'new',
  362. Connecting = 'connecting',
  363. Connected = 'connected',
  364. Reconnecting = 'reconnecting',
  365. Disconnected = 'disconnected',
  366. }
  367. /**
  368. * Connection state of the WebRTC peer connection.
  369. */
  370. const enum GlobalConnectionState {
  371. Ok = 'ok',
  372. Warning = 'warning',
  373. Error = 'error',
  374. }
  375. interface GlobalConnectionStateChange {
  376. state: GlobalConnectionState;
  377. prevState: GlobalConnectionState;
  378. }
  379. /**
  380. * Type of message to be sent to a receiver.
  381. */
  382. type MessageContentType = 'text' | 'file';
  383. interface MessageData {
  384. // optional quote object
  385. quote?: Quote;
  386. }
  387. /**
  388. * Payload for a file message.
  389. */
  390. interface FileMessageData extends MessageData {
  391. // File name
  392. name: string;
  393. // File MIME type
  394. fileType: string;
  395. // Size in bytes
  396. size: number;
  397. // File bytes
  398. data: ArrayBuffer;
  399. // Caption string
  400. caption?: string;
  401. // Send as file message
  402. sendAsFile?: boolean;
  403. }
  404. /**
  405. * Payload for a text message.
  406. */
  407. interface TextMessageData extends MessageData {
  408. // Text to be sent
  409. text: string;
  410. }
  411. interface Quote {
  412. identity: string;
  413. text: string;
  414. }
  415. const enum PushTokenType {
  416. Gcm = 'gcm',
  417. Apns = 'apns',
  418. }
  419. const enum PushTokenPrefix {
  420. Gcm = 'g',
  421. Apns = 'a',
  422. }
  423. interface TrustedKeyStoreData {
  424. ownPublicKey: Uint8Array;
  425. ownSecretKey: Uint8Array;
  426. peerPublicKey: Uint8Array;
  427. pushToken: string | null;
  428. pushTokenType: PushTokenType | null;
  429. }
  430. const enum BrowserName {
  431. Chrome = 'chrome',
  432. ChromeIos = 'chromeIos',
  433. Firefox = 'firefox',
  434. FirefoxIos = 'firefoxIos',
  435. InternetExplorer = 'ie',
  436. Edge = 'edge',
  437. Opera = 'opera',
  438. Safari = 'safari',
  439. }
  440. interface PromiseRequestResult<T> {
  441. success: boolean;
  442. error?: string;
  443. data?: T;
  444. }
  445. type OnRemovedCallback = (identity: string) => void;
  446. const enum ControllerModelMode {
  447. NEW = 'new',
  448. VIEW = 'view',
  449. EDIT = 'edit',
  450. CHAT = 'chat',
  451. }
  452. const enum ContactReceiverFeature {
  453. AUDIO = 0x01,
  454. GROUP_CHAT = 0x02,
  455. BALLOT = 0x04,
  456. FILE = 0x08,
  457. VOIP = 0x10,
  458. }
  459. interface ControllerModel<T extends BaseReceiver> {
  460. /**
  461. * The title shown in the header.
  462. */
  463. subject: string;
  464. /**
  465. * Loading state.
  466. */
  467. isLoading: boolean;
  468. /**
  469. * Save the changes, return a promise with the receiver.
  470. */
  471. save(): Promise<T>;
  472. /**
  473. * Delete all messages in this conversation.
  474. */
  475. clean(ev: any): any;
  476. /**
  477. * Validate this receiver.
  478. */
  479. isValid(): boolean;
  480. /*
  481. * Return whether this receiver can be chatted with.
  482. */
  483. canChat(): boolean;
  484. /**
  485. * Can this receiver be edited?
  486. */
  487. canEdit(): boolean;
  488. /**
  489. * Can this receiver be cleaned?
  490. */
  491. canClean(): boolean;
  492. /*
  493. * Return whether this receiver can show a QR code of the public key.
  494. */
  495. canShowQr(): boolean;
  496. /**
  497. * The editing mode, e.g. view or edit this receiver.
  498. */
  499. getMode(): ControllerModelMode;
  500. /**
  501. * Set the on removed callback.
  502. */
  503. setOnRemoved(callback: OnRemovedCallback): void;
  504. /**
  505. * Callback called when the members change.
  506. */
  507. onChangeMembers(identities: string[]): void;
  508. /**
  509. * Return the members of this receiver.
  510. */
  511. getMembers(): string[];
  512. }
  513. interface Alert {
  514. source: string;
  515. type: string;
  516. message: string;
  517. }
  518. interface ReceiverListener {
  519. onConversationRemoved(receiver: Receiver);
  520. }
  521. interface Config {
  522. SELF_HOSTED: boolean;
  523. PREV_PROTOCOL_LAST_VERSION: string | null;
  524. VERSION_MOUNTAIN: string;
  525. VERSION_MOUNTAIN_URL: string;
  526. VERSION_MOUNTAIN_IMAGE_URL: string;
  527. VERSION_MOUNTAIN_IMAGE_COPYRIGHT: string;
  528. VERSION_MOUNTAIN_HEIGHT: number;
  529. GIT_BRANCH: string;
  530. SALTYRTC_PORT: number;
  531. SALTYRTC_SERVER_KEY: string | null;
  532. SALTYRTC_HOST: string | null;
  533. SALTYRTC_HOST_PREFIX: string | null;
  534. SALTYRTC_HOST_SUFFIX: string | null;
  535. SALTYRTC_LOG_LEVEL: saltyrtc.LogLevel;
  536. ICE_SERVERS: RTCIceServer[];
  537. PUSH_URL: string;
  538. DEBUG: boolean;
  539. MSG_DEBUGGING: boolean;
  540. MSGPACK_DEBUGGING: boolean;
  541. ICE_DEBUGGING: boolean;
  542. }
  543. interface InitialConversationData {
  544. draft: string;
  545. initialText: string;
  546. }
  547. interface BrowserMinVersions {
  548. FF: number;
  549. CHROME: number;
  550. OPERA: number;
  551. SAFARI: number;
  552. }
  553. interface BatteryStatus {
  554. percent: number | null;
  555. isCharging: boolean;
  556. }
  557. const enum OperatingSystem {
  558. Android = 'android',
  559. Ios = 'ios',
  560. }
  561. interface ClientInfo {
  562. device: string;
  563. os: OperatingSystem;
  564. osVersion: string;
  565. isWork: boolean;
  566. pushToken?: string;
  567. configuration: AppConfig;
  568. capabilities: AppCapabilities;
  569. }
  570. interface AppConfig {
  571. voipEnabled: boolean;
  572. voipForceTurn: boolean;
  573. largeSingleEmoji: boolean;
  574. showInactiveIDs: boolean;
  575. }
  576. interface AppCapabilities {
  577. maxGroupSize: number;
  578. maxFileSize: number;
  579. distributionLists: boolean;
  580. imageFormat: ImageFormat;
  581. mdm?: MdmRestrictions;
  582. }
  583. /**
  584. * MIME types for the images exchanged between app and browser.
  585. */
  586. interface ImageFormat {
  587. avatar: string;
  588. thumbnail: string;
  589. }
  590. interface MdmRestrictions {
  591. disableAddContact?: boolean;
  592. disableCreateGroup?: boolean;
  593. disableSaveToGallery?: boolean;
  594. disableExport?: boolean;
  595. disableMessagePreview?: boolean;
  596. disableCalls?: boolean;
  597. readonlyProfile?: boolean;
  598. }
  599. interface ProfileUpdate {
  600. publicNickname?: string;
  601. avatar?: ArrayBuffer;
  602. }
  603. interface Profile extends ProfileUpdate {
  604. identity: string;
  605. publicKey: ArrayBuffer;
  606. }
  607. interface Mention {
  608. identity: string;
  609. query: string;
  610. isAll: boolean;
  611. }
  612. interface WordResult {
  613. // The trimmed word
  614. word: string;
  615. // The length of the untrimmed word
  616. realLength: number;
  617. }
  618. interface WebClientServiceStopArguments {
  619. reason: DisconnectReason,
  620. send: boolean,
  621. close: boolean | string,
  622. connectionBuildupState?: ConnectionBuildupState,
  623. }
  624. const enum ChosenTask {
  625. None = 'none',
  626. WebRTC = 'webrtc',
  627. RelayedData = 'relayed-data',
  628. }
  629. const enum DisconnectReason {
  630. SessionStopped = 'stop',
  631. SessionDeleted = 'delete',
  632. WebclientDisabled = 'disable',
  633. SessionReplaced = 'replace',
  634. SessionError = 'error',
  635. }
  636. namespace Container {
  637. interface ReceiverData {
  638. contacts: ContactReceiver[];
  639. groups: GroupReceiver[];
  640. distributionLists: DistributionListReceiver[];
  641. }
  642. interface Converter {
  643. unicodeToEmoji(message);
  644. addReceiverToConversation(receivers: Receivers);
  645. }
  646. interface Filters {
  647. hasData(receivers);
  648. hasContact(contacts);
  649. isValidMessage(contacts);
  650. }
  651. interface Receivers {
  652. me: MeReceiver;
  653. contacts: Map<string, ContactReceiver>;
  654. groups: Map<string, GroupReceiver>;
  655. distributionLists: Map<string, DistributionListReceiver>;
  656. get(receiverType: ReceiverType): Receiver | Map<string, Receiver>;
  657. getData(receiver: BaseReceiver): Receiver | null;
  658. set(data: ReceiverData): void;
  659. setMe(data: MeReceiver): void;
  660. setContacts(data: ContactReceiver[]): void;
  661. setGroups(data: GroupReceiver[]): void;
  662. setDistributionLists(data: DistributionListReceiver[]): void;
  663. extend(receiverType: ReceiverType, data: Receiver): Receiver;
  664. extendDistributionList(data: DistributionListReceiver): DistributionListReceiver;
  665. extendGroup(data: GroupReceiver): GroupReceiver;
  666. extendMe(data: MeReceiver): MeReceiver;
  667. extendContact(data: ContactReceiver): ContactReceiver;
  668. }
  669. interface Conversations {
  670. get(): Conversation[];
  671. set(data: Conversation[]): void;
  672. find(pattern: Conversation | Receiver): Conversation | null;
  673. add(conversation: Conversation): void;
  674. updateOrAdd(conversation: Conversation, returnOld?: boolean): Conversation | null;
  675. remove(conversation: Conversation): void;
  676. setFilter(filter: (data: Conversation[]) => Conversation[]): void;
  677. setConverter(converter: (data: Conversation) => Conversation): void;
  678. }
  679. interface Messages {
  680. converter: (data: Message) => Message;
  681. getList(receiver: BaseReceiver): Message[];
  682. clear($scope: ng.IScope): void;
  683. clearReceiverMessages(receiver: BaseReceiver): number;
  684. contains(receiver: BaseReceiver): boolean;
  685. hasMore(receiver: BaseReceiver): boolean;
  686. setMore(receiver: BaseReceiver, more: boolean): void;
  687. getReferenceMsgId(receiver: BaseReceiver): string;
  688. isRequested(receiver: BaseReceiver): boolean;
  689. setRequested(receiver: BaseReceiver): void;
  690. clearRequested(receiver: BaseReceiver): void;
  691. addNewer(receiver: BaseReceiver, messages: Message[]): void;
  692. addOlder(receiver: BaseReceiver, messages: Message[]): void;
  693. update(receiver: BaseReceiver, message: Message): boolean;
  694. setThumbnail(receiver: BaseReceiver, messageId: string, thumbnailImage: string): boolean;
  695. remove(receiver: BaseReceiver, messageId: string): boolean;
  696. removeTemporary(receiver: BaseReceiver, temporaryMessageId: string): boolean;
  697. bindTemporaryToMessageId(receiver: BaseReceiver, temporaryId: string, messageId: string): boolean;
  698. notify(receiver: BaseReceiver, $scope: ng.IScope): void;
  699. register(receiver: BaseReceiver, $scope: ng.IScope, callback: any): Message[];
  700. updateFirstUnreadMessage(receiver: BaseReceiver);
  701. }
  702. interface Typing {
  703. setTyping(receiver: BaseReceiver): void;
  704. unsetTyping(receiver: BaseReceiver): void;
  705. clearAll(): void;
  706. isTyping(receiver: BaseReceiver): boolean;
  707. }
  708. interface Drafts {
  709. setQuote(receiver: Receiver, quote: Quote): void;
  710. removeQuote(receiver: Receiver): void;
  711. getQuote(receiver: Receiver): Quote;
  712. setText(receiver: Receiver, draftMessage: string): void;
  713. removeText(receiver: Receiver): void;
  714. getText(receiver: Receiver): string;
  715. }
  716. interface Factory {
  717. Converter: Container.Converter;
  718. Filters: Container.Filters;
  719. createReceivers: () => Receivers;
  720. createConversations: () => Conversations;
  721. createMessages: () => Messages;
  722. createTyping: () => Typing;
  723. createDrafts: () => Drafts;
  724. }
  725. }
  726. }