Skip to content

Commit

Permalink
When purging while banning a user, also remove their emoji reactions.
Browse files Browse the repository at this point in the history
This expands on oxen-io#2653 and ensures that when a user is banned from a room
or an entire server, and **Delete All** has been selected, not just his
messages but also his emoji reactions will be removed.

This pull-request depends on oxen-io/session-pysogs#169.

Verified working on `sog.caliban.org`.
  • Loading branch information
ianmacd committed Jun 28, 2023
1 parent 6853f15 commit b8babeb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ts/session/apis/open_group_api/sogsv3/sogsV3BanUnban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export const sogsV3BanUser = async (
type: 'deleteAllPosts',
deleteAllPosts: { sessionId: userToBan.key, roomId: roomInfos.roomId },
});
sequence.push({
type: 'deleteAllReactions',
deleteAllReactions: { sessionId: userToBan.key, roomId: roomInfos.roomId },
});
}

const batchSendResponse = await sogsBatchSend(
Expand Down Expand Up @@ -83,6 +87,10 @@ export const sogsV3ServerBanUser = async (
type: 'deleteAllUserPosts',
deleteAllUserPosts: { sessionId: userToBan.key },
});
sequence.push({
type: 'deleteAllUserReactions',
deleteAllUserReactions: { sessionId: userToBan.key },
});
}

const batchSendResponse = await sogsBatchSend(
Expand Down
29 changes: 28 additions & 1 deletion ts/session/apis/open_group_api/sogsv3/sogsV3BatchPoll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,21 @@ export type SubRequestDeleteAllUserServerPostsType = {
};
};

export type SubRequestDeleteAllUserReactionsType = {
type: 'deleteAllReactions';
deleteAllReactions: {
sessionId: string; // can be blinded id or not
roomId: string;
};
};

export type SubRequestDeleteAllUserServerReactionsType = {
type: 'deleteAllUserReactions';
deleteAllUserReactions: {
sessionId: string; // can be blinded id or not
};
};

export type SubRequestUpdateRoomType = {
type: 'updateRoom';
updateRoom: {
Expand Down Expand Up @@ -226,7 +241,9 @@ export type OpenGroupBatchRow =
| SubRequestAddRemoveModeratorType
| SubRequestBanUnbanUserType
| SubRequestDeleteAllUserPostsType
| SubRequestDeleteAllUserReactionsType
| SubRequestDeleteAllUserServerPostsType
| SubRequestDeleteAllUserServerReactionsType
| SubRequestUpdateRoomType
| SubRequestDeleteReactionType;

Expand Down Expand Up @@ -342,7 +359,17 @@ const makeBatchRequestPayload = (
method: 'DELETE',
path: `/rooms/all/${options.deleteAllUserPosts.sessionId}`,
};
case 'updateRoom':
case 'deleteAllReactions':
return {
method: 'DELETE',
path: `/room/${options.deleteAllReactions.roomId}/all/reactions/${options.deleteAllReactions.sessionId}`,
};
case 'deleteAllUserReactions':
return {
method: 'DELETE',
path: `/rooms/all/reactions/${options.deleteAllUserReactions.sessionId}`,
};
case 'updateRoom':
return {
method: 'PUT',
path: `/room/${options.updateRoom.roomId}`,
Expand Down

0 comments on commit b8babeb

Please sign in to comment.