threema.d.ts 22 KB

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