Skip to content

Commit

Permalink
Merge branch 'master' into event_store
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Apr 22, 2024
2 parents 3213776 + 1e40cc1 commit 28b76b3
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 2 deletions.
2 changes: 2 additions & 0 deletions backend/canisters/community/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Store presence kind of each video call participant ([#5682](https://github.com/open-chat-labs/open-chat/pull/5682))
- Add `block_level_markdown` to edit message args ([#5697](https://github.com/open-chat-labs/open-chat/pull/5697))
- Allow non-Diamond members to start video calls ([#5706](https://github.com/open-chat-labs/open-chat/pull/5706))
- Allow members to make video calls in existing private chats ([#5714](https://github.com/open-chat-labs/open-chat/pull/5714))
- Update `event_store` packages to v0.1.0 ([#5715](https://github.com/open-chat-labs/open-chat/pull/5715))

### Fixed

- Fix payments which are failing due to being too old ([#5681](https://github.com/open-chat-labs/open-chat/pull/5681))
- One time job to mark video calls ended if message deleted ([#5714](https://github.com/open-chat-labs/open-chat/pull/5714))

## [[2.0.1139](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1139-community)] - 2024-04-10

Expand Down
22 changes: 21 additions & 1 deletion backend/canisters/community/impl/src/lifecycle/post_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use ic_cdk_macros::post_upgrade;
use instruction_counts_log::InstructionCountFunctionId;
use stable_memory::get_reader;
use tracing::info;
use types::PendingCryptoTransaction;
use types::{GroupPermissionRole, PendingCryptoTransaction};
use utils::time::{DAY_IN_MS, NANOS_PER_MILLISECOND};

#[post_upgrade]
Expand Down Expand Up @@ -42,8 +42,10 @@ fn post_upgrade(args: Args) {
});

mutate_state(|state| {
let now = state.env.now();
for channel in state.data.channels.iter_mut() {
channel.chat.events.set_block_level_markdown(1710152259000);
channel.chat.events.mark_video_call_ended_if_message_deleted(now);
}

for (_, job) in state.data.timer_jobs.iter() {
Expand All @@ -57,5 +59,23 @@ fn post_upgrade(args: Args) {
}
}
}

// TODO: One time only - remove after release
let now = state.env.now();
for channel in state.data.channels.iter_mut() {
if !channel.chat.is_public.value {
channel.chat.permissions.update(
|ps| {
if matches!(ps.start_video_call, GroupPermissionRole::Admins) {
ps.start_video_call = GroupPermissionRole::Members;
true
} else {
false
}
},
now,
);
}
}
});
}
2 changes: 2 additions & 0 deletions backend/canisters/group/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Store presence kind of each video call participant ([#5682](https://github.com/open-chat-labs/open-chat/pull/5682))
- Add `block_level_markdown` to edit message args ([#5697](https://github.com/open-chat-labs/open-chat/pull/5697))
- Allow non-Diamond members to start video calls ([#5706](https://github.com/open-chat-labs/open-chat/pull/5706))
- Allow members to make video calls in existing private chats ([#5714](https://github.com/open-chat-labs/open-chat/pull/5714))
- Update `event_store` packages to v0.1.0 ([#5715](https://github.com/open-chat-labs/open-chat/pull/5715))

### Fixed

- Fix payments which are failing due to being too old ([#5681](https://github.com/open-chat-labs/open-chat/pull/5681))
- One time job to mark video calls ended if message deleted ([#5714](https://github.com/open-chat-labs/open-chat/pull/5714))

## [[2.0.1140](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1140-group)] - 2024-04-10

Expand Down
23 changes: 22 additions & 1 deletion backend/canisters/group/impl/src/lifecycle/post_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use ic_cdk_macros::post_upgrade;
use instruction_counts_log::InstructionCountFunctionId;
use stable_memory::get_reader;
use tracing::info;
use types::PendingCryptoTransaction;
use types::{GroupPermissionRole, PendingCryptoTransaction};
use utils::time::{DAY_IN_MS, NANOS_PER_MILLISECOND};

#[post_upgrade]
Expand All @@ -36,6 +36,11 @@ fn post_upgrade(args: Args) {

mutate_state(|state| {
state.data.chat.events.set_block_level_markdown(1710152259000);
state
.data
.chat
.events
.mark_video_call_ended_if_message_deleted(state.env.now());

for (_, job) in state.data.timer_jobs.iter() {
if let Some(TimerJob::MakeTransfer(j)) = job.borrow_mut().as_mut() {
Expand All @@ -48,5 +53,21 @@ fn post_upgrade(args: Args) {
}
}
}

// TODO: One time only - remove after release
let now = state.env.now();
if !state.data.chat.is_public.value {
state.data.chat.permissions.update(
|ps| {
if matches!(ps.start_video_call, GroupPermissionRole::Admins) {
ps.start_video_call = GroupPermissionRole::Members;
true
} else {
false
}
},
now,
);
}
});
}
4 changes: 4 additions & 0 deletions backend/canisters/user/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Allow non-Diamond members to start video calls ([#5706](https://github.com/open-chat-labs/open-chat/pull/5706))
- Update `event_store` packages to v0.1.0 ([#5715](https://github.com/open-chat-labs/open-chat/pull/5715))

### Fixed

- One time job to mark video calls ended if message deleted ([#5714](https://github.com/open-chat-labs/open-chat/pull/5714))

## [[2.0.1141](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1141-user)] - 2024-04-11

### Added
Expand Down
5 changes: 5 additions & 0 deletions backend/canisters/user/impl/src/lifecycle/post_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ fn post_upgrade(args: Args) {
{
ic_cdk_timers::set_timer(Duration::ZERO, mark_user_canister_empty);
}

let now = state.env.now();
for chat in state.data.direct_chats.iter_mut() {
chat.events.mark_video_call_ended_if_message_deleted(now);
}
});
}

Expand Down
13 changes: 13 additions & 0 deletions backend/libraries/chat_events/src/chat_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ pub struct ChatEvents {
}

impl ChatEvents {
pub fn mark_video_call_ended_if_message_deleted(&mut self, now: TimestampMillis) {
if let Some(message_index) = self.video_call_in_progress.value.as_ref().map(|v| v.message_index) {
let is_deleted = self
.main_events_reader()
.message_internal(message_index.into())
.map_or(true, |m| m.deleted_by.is_some());

if is_deleted {
self.video_call_in_progress = Timestamped::new(None, now);
}
}
}

pub fn set_block_level_markdown(&mut self, cutoff: TimestampMillis) {
self.main.set_block_level_markdown(cutoff);
for thread in self.threads.values_mut() {
Expand Down

0 comments on commit 28b76b3

Please sign in to comment.