threema.d.ts 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867
  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. interface PushSessionConfig {
  417. retryTimeoutInitMs: number;
  418. retryTimeoutMaxMs: number;
  419. triesMax: number;
  420. timeToLiveRange: number[];
  421. }
  422. const enum PushTokenType {
  423. Gcm = 'gcm',
  424. Apns = 'apns',
  425. }
  426. const enum PushTokenPrefix {
  427. Gcm = 'g',
  428. Apns = 'a',
  429. }
  430. interface TrustedKeyStoreData {
  431. ownPublicKey: Uint8Array;
  432. ownSecretKey: Uint8Array;
  433. peerPublicKey: Uint8Array;
  434. pushToken: string | null;
  435. pushTokenType: PushTokenType | null;
  436. }
  437. const enum BrowserName {
  438. Chrome = 'chrome',
  439. ChromeIos = 'chromeIos',
  440. Firefox = 'firefox',
  441. FirefoxIos = 'firefoxIos',
  442. InternetExplorer = 'ie',
  443. Edge = 'edge',
  444. Opera = 'opera',
  445. Safari = 'safari',
  446. }
  447. interface PromiseRequestResult<T> {
  448. success: boolean;
  449. error?: string;
  450. data?: T;
  451. }
  452. type OnRemovedCallback = (identity: string) => void;
  453. const enum ControllerModelMode {
  454. NEW = 'new',
  455. VIEW = 'view',
  456. EDIT = 'edit',
  457. CHAT = 'chat',
  458. }
  459. const enum ContactReceiverFeature {
  460. AUDIO = 0x01,
  461. GROUP_CHAT = 0x02,
  462. BALLOT = 0x04,
  463. FILE = 0x08,
  464. VOIP = 0x10,
  465. }
  466. interface ControllerModel<T extends BaseReceiver> {
  467. /**
  468. * The title shown in the header.
  469. */
  470. subject: string;
  471. /**
  472. * Loading state.
  473. */
  474. isLoading: boolean;
  475. /**
  476. * Save the changes, return a promise with the receiver.
  477. */
  478. save(): Promise<T>;
  479. /**
  480. * Delete all messages in this conversation.
  481. */
  482. clean(ev: any): any;
  483. /**
  484. * Validate this receiver.
  485. */
  486. isValid(): boolean;
  487. /*
  488. * Return whether this receiver can be chatted with.
  489. */
  490. canChat(): boolean;
  491. /**
  492. * Can this receiver be edited?
  493. */
  494. canEdit(): boolean;
  495. /**
  496. * Can this receiver be cleaned?
  497. */
  498. canClean(): boolean;
  499. /*
  500. * Return whether this receiver can show a QR code of the public key.
  501. */
  502. canShowQr(): boolean;
  503. /**
  504. * The editing mode, e.g. view or edit this receiver.
  505. */
  506. getMode(): ControllerModelMode;
  507. /**
  508. * Set the on removed callback.
  509. */
  510. setOnRemoved(callback: OnRemovedCallback): void;
  511. /**
  512. * Callback called when the members change.
  513. */
  514. onChangeMembers(identities: string[]): void;
  515. /**
  516. * Return the members of this receiver.
  517. */
  518. getMembers(): string[];
  519. }
  520. interface Alert {
  521. source: string;
  522. type: string;
  523. message: string;
  524. }
  525. interface ReceiverListener {
  526. onConversationRemoved(receiver: Receiver);
  527. }
  528. interface Config {
  529. SELF_HOSTED: boolean;
  530. PREV_PROTOCOL_LAST_VERSION: string | null;
  531. VERSION_MOUNTAIN: string;
  532. VERSION_MOUNTAIN_URL: string;
  533. VERSION_MOUNTAIN_IMAGE_URL: string;
  534. VERSION_MOUNTAIN_IMAGE_COPYRIGHT: string;
  535. VERSION_MOUNTAIN_HEIGHT: number;
  536. GIT_BRANCH: string;
  537. SALTYRTC_PORT: number;
  538. SALTYRTC_SERVER_KEY: string | null;
  539. SALTYRTC_HOST: string | null;
  540. SALTYRTC_HOST_PREFIX: string | null;
  541. SALTYRTC_HOST_SUFFIX: string | null;
  542. SALTYRTC_LOG_LEVEL: saltyrtc.LogLevel;
  543. ICE_SERVERS: RTCIceServer[];
  544. PUSH_URL: string;
  545. DEBUG: boolean;
  546. MSG_DEBUGGING: boolean;
  547. MSGPACK_DEBUGGING: boolean;
  548. ICE_DEBUGGING: boolean;
  549. }
  550. interface InitialConversationData {
  551. draft: string;
  552. initialText: string;
  553. }
  554. interface BrowserMinVersions {
  555. FF: number;
  556. CHROME: number;
  557. OPERA: number;
  558. SAFARI: number;
  559. }
  560. interface BatteryStatus {
  561. percent: number | null;
  562. isCharging: boolean;
  563. }
  564. const enum OperatingSystem {
  565. Android = 'android',
  566. Ios = 'ios',
  567. }
  568. interface ClientInfo {
  569. // The device name
  570. device: string;
  571. // The operating system
  572. os: OperatingSystem;
  573. // The operating system version (e.g. "5.1")
  574. osVersion: string;
  575. // Whether the app is the *work* variant of Threema
  576. isWork: boolean;
  577. // The GCM / APNS push token
  578. pushToken?: string;
  579. // The device configuration
  580. configuration: AppConfig;
  581. // The device capabilities
  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. interface WebClientServiceStopArguments {
  633. reason: DisconnectReason,
  634. send: boolean,
  635. close: boolean | string,
  636. connectionBuildupState?: ConnectionBuildupState,
  637. }
  638. const enum ChosenTask {
  639. None = 'none',
  640. WebRTC = 'webrtc',
  641. RelayedData = 'relayed-data',
  642. }
  643. const enum DisconnectReason {
  644. SessionStopped = 'stop',
  645. SessionDeleted = 'delete',
  646. WebclientDisabled = 'disable',
  647. SessionReplaced = 'replace',
  648. SessionError = 'error',
  649. }
  650. namespace Container {
  651. interface ReceiverData {
  652. contacts: ContactReceiver[];
  653. groups: GroupReceiver[];
  654. distributionLists: DistributionListReceiver[];
  655. }
  656. interface Converter {
  657. addReceiverToConversation(receivers: Receivers);
  658. }
  659. interface Filters {
  660. hasData(receivers);
  661. hasContact(contacts);
  662. isValidMessage(contacts);
  663. }
  664. interface Receivers {
  665. me: MeReceiver;
  666. contacts: Map<string, ContactReceiver>;
  667. groups: Map<string, GroupReceiver>;
  668. distributionLists: Map<string, DistributionListReceiver>;
  669. get(receiverType: ReceiverType): Receiver | Map<string, Receiver>;
  670. getData(receiver: BaseReceiver): Receiver | null;
  671. set(data: ReceiverData): void;
  672. setMe(data: MeReceiver): void;
  673. setContacts(data: ContactReceiver[]): void;
  674. setGroups(data: GroupReceiver[]): void;
  675. setDistributionLists(data: DistributionListReceiver[]): void;
  676. extend(receiverType: ReceiverType, data: Receiver): Receiver;
  677. extendDistributionList(data: DistributionListReceiver): DistributionListReceiver;
  678. extendGroup(data: GroupReceiver): GroupReceiver;
  679. extendMe(data: MeReceiver): MeReceiver;
  680. extendContact(data: ContactReceiver): ContactReceiver;
  681. }
  682. interface Conversations {
  683. get(): Conversation[];
  684. set(data: Conversation[]): void;
  685. find(pattern: Conversation | Receiver): Conversation | null;
  686. add(conversation: Conversation): void;
  687. updateOrAdd(conversation: Conversation, returnOld?: boolean): Conversation | null;
  688. remove(conversation: Conversation): void;
  689. setFilter(filter: (data: Conversation[]) => Conversation[]): void;
  690. setConverter(converter: (data: Conversation) => Conversation): void;
  691. }
  692. interface Messages {
  693. converter: (data: Message) => Message;
  694. getList(receiver: BaseReceiver): Message[];
  695. clear($scope: ng.IScope): void;
  696. clearReceiverMessages(receiver: BaseReceiver): number;
  697. contains(receiver: BaseReceiver): boolean;
  698. hasMore(receiver: BaseReceiver): boolean;
  699. setMore(receiver: BaseReceiver, more: boolean): void;
  700. getReferenceMsgId(receiver: BaseReceiver): string;
  701. isRequested(receiver: BaseReceiver): boolean;
  702. setRequested(receiver: BaseReceiver): void;
  703. clearRequested(receiver: BaseReceiver): void;
  704. addNewer(receiver: BaseReceiver, messages: Message[]): void;
  705. addOlder(receiver: BaseReceiver, messages: Message[]): void;
  706. addStatusMessage(receiver: BaseReceiver, text: string): void;
  707. update(receiver: BaseReceiver, message: Message): boolean;
  708. setThumbnail(receiver: BaseReceiver, messageId: string, thumbnailImage: string): boolean;
  709. remove(receiver: BaseReceiver, messageId: string): boolean;
  710. removeTemporary(receiver: BaseReceiver, temporaryMessageId: string): boolean;
  711. bindTemporaryToMessageId(receiver: BaseReceiver, temporaryId: string, messageId: string): boolean;
  712. notify(receiver: BaseReceiver, $scope: ng.IScope): void;
  713. register(receiver: BaseReceiver, $scope: ng.IScope, callback: any): Message[];
  714. updateFirstUnreadMessage(receiver: BaseReceiver);
  715. }
  716. interface Typing {
  717. setTyping(receiver: BaseReceiver): void;
  718. unsetTyping(receiver: BaseReceiver): void;
  719. clearAll(): void;
  720. isTyping(receiver: BaseReceiver): boolean;
  721. }
  722. interface Drafts {
  723. setQuote(receiver: Receiver, quote: Quote): void;
  724. removeQuote(receiver: Receiver): void;
  725. getQuote(receiver: Receiver): Quote;
  726. setText(receiver: Receiver, draftMessage: string): void;
  727. removeText(receiver: Receiver): void;
  728. getText(receiver: Receiver): string;
  729. }
  730. interface Factory {
  731. Converter: Container.Converter;
  732. Filters: Container.Filters;
  733. createReceivers: () => Receivers;
  734. createConversations: () => Conversations;
  735. createMessages: () => Messages;
  736. createTyping: () => Typing;
  737. createDrafts: () => Drafts;
  738. }
  739. }
  740. }