Skip to content

Commit

Permalink
Merge branch 'master' into dfx
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Dec 5, 2023
2 parents f2927d9 + d53c274 commit 1f8a6d2
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 8 deletions.
4 changes: 4 additions & 0 deletions backend/canisters/community/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

### Fixed

- Fix bug which allowed anyone to mention @everyone ([#4930](https://github.com/open-chat-labs/open-chat/pull/4930))

## [[2.0.958](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.958-community)] - 2023-12-05

### Added
Expand Down
4 changes: 4 additions & 0 deletions backend/canisters/group/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

### Fixed

- Fix bug which allowed anyone to mention @everyone ([#4930](https://github.com/open-chat-labs/open-chat/pull/4930))

## [[2.0.957](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.957-group)] - 2023-12-05

### Added
Expand Down
4 changes: 4 additions & 0 deletions backend/canisters/user/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

### Changed

- When swapping tokens take fee out of amount passed in ([#4934](https://github.com/open-chat-labs/open-chat/pull/4934))

## [[2.0.961](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.961-user)] - 2023-12-05

### Added
Expand Down
8 changes: 4 additions & 4 deletions backend/canisters/user/impl/src/updates/swap_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub(crate) async fn process_token_swap(mut token_swap: TokenSwap, attempt: u32)
fee: Some(args.input_token.fee.into()),
created_at_time: Some(now * NANOS_PER_MILLISECOND),
memo: Some(MEMO_SWAP.to_vec().into()),
amount: args.input_amount.into(),
amount: args.input_amount.saturating_sub(args.input_token.fee).into(),
},
)
.await
Expand All @@ -85,7 +85,7 @@ pub(crate) async fn process_token_swap(mut token_swap: TokenSwap, attempt: u32)
Err(msg) => {
mutate_state(|state| {
let now = state.env.now();
token_swap.notified_dex_at = Some(Timestamped::new(Err(msg.clone()), now));
token_swap.transfer = Some(Timestamped::new(Err(msg.clone()), now));
token_swap.success = Some(Timestamped::new(false, now));
state.data.token_swaps.upsert(token_swap);
});
Expand All @@ -99,7 +99,7 @@ pub(crate) async fn process_token_swap(mut token_swap: TokenSwap, attempt: u32)
let msg = format!("{error:?}");
mutate_state(|state| {
let now = state.env.now();
token_swap.transfer = Some(Timestamped::new(Err(msg.clone()), now));
token_swap.notified_dex_at = Some(Timestamped::new(Err(msg.clone()), now));
state.data.token_swaps.upsert(token_swap.clone());
enqueue_token_swap(token_swap, attempt, now, &mut state.data);
});
Expand Down Expand Up @@ -144,7 +144,7 @@ pub(crate) async fn process_token_swap(mut token_swap: TokenSwap, attempt: u32)
let (successful_swap, amount_out) = if let Ok(amount_swapped) = swap_result {
(true, amount_swapped.saturating_sub(args.output_token.fee))
} else {
(false, args.input_amount.saturating_sub(args.input_token.fee))
(false, args.input_amount.saturating_sub(2 * args.input_token.fee))
};

if extract_result(&token_swap.withdrawn_from_dex_at).is_none() {
Expand Down
4 changes: 4 additions & 0 deletions backend/canisters/user_index/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

### Added

- Expose number of lifetime Diamond members in metrics ([#4929](https://github.com/open-chat-labs/open-chat/pull/4929))

## [[2.0.955](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.955-user_index)] - 2023-12-05

### Added
Expand Down
1 change: 1 addition & 0 deletions backend/canisters/user_index/impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ pub struct DiamondMembershipMetrics {
#[derive(Serialize, Debug, Default)]
pub struct DiamondMembershipUserMetrics {
pub total: u64,
pub lifetime: u64,
pub recurring: u64,
}

Expand Down
3 changes: 3 additions & 0 deletions backend/canisters/user_index/impl/src/model/user_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ impl UserMap {
let mut metrics = DiamondMembershipUserMetrics::default();
for user in self.users.values().filter(|u| u.diamond_membership_details.is_active(now)) {
metrics.total += 1;
if user.diamond_membership_details.is_lifetime_diamond_member() {
metrics.lifetime += 1;
}
if user.diamond_membership_details.is_recurring() {
metrics.recurring += 1;
}
Expand Down
4 changes: 2 additions & 2 deletions backend/canisters/user_index/impl/src/queries/http_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn http_request(request: HttpRequest) -> HttpResponse {
.users
.iter()
.filter(|u| u.is_bot)
.map(|u| u.user_id.to_string())
.map(|u| (u.user_id.to_string(), u.username.clone()))
.collect();

build_json_response(&bots)
Expand All @@ -34,7 +34,7 @@ fn http_request(request: HttpRequest) -> HttpResponse {
let mut grouped: BTreeMap<String, u32> = BTreeMap::new();
for user in state.data.users.iter().filter(|u| u.date_created > 0) {
let date = time::OffsetDateTime::from_unix_timestamp((user.date_created / 1000) as i64).unwrap();
let date_string = format!("{}-{}-{}", date.year(), u8::from(date.month()), date.day());
let date_string = format!("{}-{:02}-{:02}", date.year(), u8::from(date.month()), date.day());
*grouped.entry(date_string).or_default() += 1;
}
build_json_response(&grouped)
Expand Down
2 changes: 1 addition & 1 deletion backend/libraries/group_chat_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ impl GroupChatCore {
Success(PrepareSendMessageSuccess {
min_visible_event_index: member.min_visible_event_index(),
mentions_disabled: false,
everyone_mentioned: is_everyone_mentioned(content),
everyone_mentioned: member.role.can_mention_everyone(permissions) && is_everyone_mentioned(content),
})
}

Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/components/Panel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
padding: 0px;
border-left: var(--bw) solid var(--bd);
background: var(--panel-right-bg);
position: relative;
&.modal.right {
background: var(--panel-right-modal);
Expand Down
4 changes: 4 additions & 0 deletions frontend/app/src/components/home/EmojiPicker.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,9 @@
@include size-below(xxs) {
--num-columns: 7 !important;
}
&.thread {
--num-columns: 10 !important;
}
}
</style>
12 changes: 11 additions & 1 deletion frontend/app/src/components/home/Footer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
</script>

{#if messageAction === "emoji"}
<div class="emoji-overlay">
<div class={`emoji-overlay ${mode}`}>
<ModalContent hideFooter hideHeader fill>
<span slot="body">
<div class="emoji-header">
Expand Down Expand Up @@ -173,6 +173,11 @@
border: var(--bw) solid var(--bd);
}
:global(.emoji-overlay.thread .modal-content) {
width: 100%;
border-radius: var(--modal-rd) var(--modal-rd) 0 0;
}
.footer {
position: relative;
flex: 0 0 toRem(60);
Expand Down Expand Up @@ -212,6 +217,11 @@
flex: 0 0 20px;
}
}
&.thread {
bottom: toRem(60);
left: 0;
}
}
.draft-container {
Expand Down

0 comments on commit 1f8a6d2

Please sign in to comment.