threema.d.ts 22 KB

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