Commit Graph

19 Commits (2dc3877fd4c3e45f8c1ae37b2960ab49095bc07b)

Author SHA1 Message Date
Daniel Gasienica e5d90775d0 Add `MapAsync` type definition 7 years ago
Daniel Gasienica 648a7ab1bb Autoformat using Prettier 7 years ago
Daniel Gasienica e07458d886 Add basic Backbone type definitions 7 years ago
Daniel Gasienica 9d84b2f420 Index messages with attachments using a boolean
When indexing message attachment metadata using numeric indexes such as:

```javascript
{
  conversationId: '+12223334455',
  received_at: 123,
  attachments: […],
  numAttachments: 2,
},
{
  conversationId: '+12223334455',
  received_at: 456,
  attachments: [],
  numAttachments: 0,
}
{
  conversationId: '+12223334455',
  received_at: 789,
  attachments: [],
  numAttachments: 1,
}
```

It creates an index as follows:

```
[conversationId, received_at, numAttachments]
['+12223334455', 123, 2]
['+12223334455', 456, 0]
['+12223334455', 789, 1]
```

This means a query such as…

```
lowerBound: ['+12223334455', 0,                1               ]
upperBound: ['+12223334455', Number.MAX_VALUE, Number.MAX_VALUE]
```

…will return all three original entries because they span the `received_at`
from `0` through `Number.MAX_VALUE`. One workaround is to index booleans using
`1 | undefined` where `1` is included in the index and `undefined` is not, but
that way we lose the ability to query for the `false` value. Instead, we flip
adjust the index to `[conversationId, hasAttachments, received_at]` and can
then query messages with attachments using

```
[conversationId, 1 /* hasAttachments */, 0                /* received_at */]
[conversationId, 1 /* hasAttachments */, Number.MAX_VALUE /* received_at */]
```
7 years ago
Daniel Gasienica c46e1a1519 Move top-level functions to `Signal.Util` 7 years ago
Daniel Gasienica ae4c74dd5b Skip metadata initialization for `verified-change` messages 7 years ago
Daniel Gasienica 424965f876 🎨 Autoformat code 7 years ago
Daniel Gasienica fc1c3aabf5 Add scaffolding for media gallery 7 years ago
Daniel Gasienica 867bece952 Add `Message.initializeAttachmentMetadata` 7 years ago
Daniel Gasienica c5352cf26c Separate required from optional `Message` keys 7 years ago
Daniel Gasienica fc12353bb8 Add `Attachment.isVisualMedia` 7 years ago
Daniel Gasienica 6ff82adf0a Add `MIME.isImage` and `MIME.isVideo` 7 years ago
Daniel Gasienica df2e6e7864 Port `MIME` module to TypeScript 7 years ago
Daniel Gasienica 44debd123d Add basic implementation of `Conversation.updateFromLastMessage` 7 years ago
Daniel Gasienica cca5db3237 Remove unused import 7 years ago
Daniel Gasienica 1659354f51 Expand `Message` type definitions 7 years ago
Daniel Gasienica b50c55172d Add `MIME` type 7 years ago
Daniel Gasienica 65bf34d1b8 Add basic `Attachment` type definition 7 years ago
Daniel Gasienica f25a579f32 Add basic `Message` type definition 7 years ago