Refactor sender key sends to allow distribution lists
This commit is contained in:
parent
61a6f1b4cf
commit
161b0e5379
10 changed files with 210 additions and 110 deletions
|
@ -280,6 +280,7 @@ const dataInterface: ServerInterface = {
|
|||
_deleteAllStoryDistributions,
|
||||
createNewStoryDistribution,
|
||||
getAllStoryDistributionsWithMembers,
|
||||
modifyStoryDistribution,
|
||||
modifyStoryDistributionMembers,
|
||||
deleteStoryDistribution,
|
||||
|
||||
|
@ -3848,12 +3849,12 @@ async function _deleteAllStoryDistributions(): Promise<void> {
|
|||
db.prepare<EmptyQuery>('DELETE FROM storyDistributions;').run();
|
||||
}
|
||||
async function createNewStoryDistribution(
|
||||
story: StoryDistributionWithMembersType
|
||||
distribution: StoryDistributionWithMembersType
|
||||
): Promise<void> {
|
||||
const db = getInstance();
|
||||
|
||||
db.transaction(() => {
|
||||
const payload = freezeStoryDistribution(story);
|
||||
const payload = freezeStoryDistribution(distribution);
|
||||
|
||||
prepare(
|
||||
db,
|
||||
|
@ -3874,7 +3875,7 @@ async function createNewStoryDistribution(
|
|||
`
|
||||
).run(payload);
|
||||
|
||||
const { id: listId, members } = story;
|
||||
const { id: listId, members } = distribution;
|
||||
|
||||
const memberInsertStatement = prepare(
|
||||
db,
|
||||
|
@ -3910,6 +3911,24 @@ async function getAllStoryDistributionsWithMembers(): Promise<
|
|||
members: (byListId[list.id] || []).map(member => member.uuid),
|
||||
}));
|
||||
}
|
||||
async function modifyStoryDistribution(
|
||||
distribution: StoryDistributionType
|
||||
): Promise<void> {
|
||||
const payload = freezeStoryDistribution(distribution);
|
||||
const db = getInstance();
|
||||
prepare(
|
||||
db,
|
||||
`
|
||||
UPDATE storyDistributions
|
||||
SET
|
||||
name = $name,
|
||||
avatarUrlPath = $avatarUrlPath,
|
||||
avatarKey = $avatarKey,
|
||||
senderKeyInfoJson = $senderKeyInfoJson
|
||||
WHERE id = $id
|
||||
`
|
||||
).run(payload);
|
||||
}
|
||||
async function modifyStoryDistributionMembers(
|
||||
listId: string,
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue