Support additional sticker states

Co-authored-by: scott@signal.org
Co-authored-by: ken@signal.org
This commit is contained in:
Ken Powers
2019-05-23 18:27:42 -07:00
committed by Scott Nonnenberg
parent 41880cfe66
commit be5d0837f8
35 changed files with 925 additions and 249 deletions

View File

@@ -1193,14 +1193,14 @@ async function updateConversation(data) {
await db.run(
`UPDATE conversations SET
json = $json,
json = $json,
active_at = $active_at,
type = $type,
members = $members,
name = $name,
profileName = $profileName
WHERE id = $id;`,
active_at = $active_at,
type = $type,
members = $members,
name = $name,
profileName = $profileName
WHERE id = $id;`,
{
$id: id,
$json: objectToJSON(data),
@@ -1879,8 +1879,46 @@ async function createOrUpdateStickerPack(pack) {
);
}
const rows = await db.all('SELECT id FROM sticker_packs WHERE id = $id;', {
$id: id,
});
const payload = {
$attemptedStatus: attemptedStatus,
$author: author,
$coverStickerId: coverStickerId,
$createdAt: createdAt || Date.now(),
$downloadAttempts: downloadAttempts || 1,
$id: id,
$installedAt: installedAt,
$key: key,
$lastUsed: lastUsed || null,
$status: status,
$stickerCount: stickerCount,
$title: title,
};
if (rows && rows.length) {
await db.run(
`UPDATE sticker_packs SET
attemptedStatus = $attemptedStatus,
author = $author,
coverStickerId = $coverStickerId,
createdAt = $createdAt,
downloadAttempts = $downloadAttempts,
installedAt = $installedAt,
key = $key,
lastUsed = $lastUsed,
status = $status,
stickerCount = $stickerCount,
title = $title
WHERE id = $id;`,
payload
);
return;
}
await db.run(
`INSERT OR REPLACE INTO sticker_packs (
`INSERT INTO sticker_packs (
attemptedStatus,
author,
coverStickerId,
@@ -1907,20 +1945,7 @@ async function createOrUpdateStickerPack(pack) {
$stickerCount,
$title
)`,
{
$attemptedStatus: attemptedStatus,
$author: author,
$coverStickerId: coverStickerId,
$createdAt: createdAt || Date.now(),
$downloadAttempts: downloadAttempts || 1,
$id: id,
$installedAt: installedAt,
$key: key,
$lastUsed: lastUsed || null,
$status: status,
$stickerCount: stickerCount,
$title: title,
}
payload
);
}
async function updateStickerPackStatus(id, status, options) {