diff --git a/backend/canisters/community/api/src/main.rs b/backend/canisters/community/api/src/main.rs index 27ca94e6c4..9cd83a8532 100644 --- a/backend/canisters/community/api/src/main.rs +++ b/backend/canisters/community/api/src/main.rs @@ -121,7 +121,7 @@ fn main() { generate_ts_method!(community, pin_message); generate_ts_method!(community, register_poll_vote); generate_ts_method!(community, register_proposal_vote); - // generate_ts_method!(community, register_proposal_vote_v2); + generate_ts_method!(community, register_proposal_vote_v2); generate_ts_method!(community, remove_member_from_channel); generate_ts_method!(community, remove_member); generate_ts_method!(community, remove_reaction); diff --git a/backend/canisters/community/api/src/updates/register_proposal_vote_v2.rs b/backend/canisters/community/api/src/updates/register_proposal_vote_v2.rs index 4df1bb612e..60f2c29ac6 100644 --- a/backend/canisters/community/api/src/updates/register_proposal_vote_v2.rs +++ b/backend/canisters/community/api/src/updates/register_proposal_vote_v2.rs @@ -1,7 +1,9 @@ use candid::CandidType; use serde::{Deserialize, Serialize}; +use ts_export::ts_export; use types::{ChannelId, MessageIndex}; +#[ts_export(community, register_proposal_vote_v2)] #[derive(CandidType, Serialize, Deserialize, Debug)] pub struct Args { pub channel_id: ChannelId, @@ -9,6 +11,7 @@ pub struct Args { pub adopt: bool, } +#[ts_export(community, register_proposal_vote_v2)] #[derive(CandidType, Serialize, Deserialize, Debug)] pub enum Response { Success, diff --git a/backend/canisters/community/impl/src/updates/mod.rs b/backend/canisters/community/impl/src/updates/mod.rs index 056ea64da5..3a938abf5f 100644 --- a/backend/canisters/community/impl/src/updates/mod.rs +++ b/backend/canisters/community/impl/src/updates/mod.rs @@ -36,7 +36,7 @@ pub mod leave_channel; pub mod pin_message; pub mod register_poll_vote; pub mod register_proposal_vote; -// pub mod register_proposal_vote_v2; +pub mod register_proposal_vote_v2; pub mod remove_member; pub mod remove_member_from_channel; pub mod remove_reaction; diff --git a/backend/canisters/group/CHANGELOG.md b/backend/canisters/group/CHANGELOG.md index 345c25d76d..4376673c03 100644 --- a/backend/canisters/group/CHANGELOG.md +++ b/backend/canisters/group/CHANGELOG.md @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed - Mark prize messages as having ledger error if transfers fail ([#6500](https://github.com/open-chat-labs/open-chat/pull/6500)) +- Add missing MessagePack endpoints ([#6547](https://github.com/open-chat-labs/open-chat/pull/6547)) ## [[2.0.1366](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1366-group)] - 2024-10-02 diff --git a/backend/canisters/group/impl/src/queries/events.rs b/backend/canisters/group/impl/src/queries/events.rs index 19bacb2d30..9a6dc4c9ac 100644 --- a/backend/canisters/group/impl/src/queries/events.rs +++ b/backend/canisters/group/impl/src/queries/events.rs @@ -7,7 +7,7 @@ use group_canister::c2c_events::Args as C2CArgs; use group_canister::events::{Response::*, *}; use group_chat_core::EventsResult; -#[query(candid = true)] +#[query(candid = true, msgpack = true)] fn events(args: Args) -> Response { read_state(|state| events_impl(args, None, state)) } diff --git a/backend/canisters/group/impl/src/queries/events_by_index.rs b/backend/canisters/group/impl/src/queries/events_by_index.rs index 123284b5cc..24400ddf7f 100644 --- a/backend/canisters/group/impl/src/queries/events_by_index.rs +++ b/backend/canisters/group/impl/src/queries/events_by_index.rs @@ -7,7 +7,7 @@ use group_canister::c2c_events_by_index::Args as C2CArgs; use group_canister::events_by_index::{Response::*, *}; use group_chat_core::EventsResult; -#[query(candid = true)] +#[query(candid = true, msgpack = true)] fn events_by_index(args: Args) -> Response { read_state(|state| events_by_index_impl(args, None, state)) } diff --git a/backend/canisters/group/impl/src/queries/events_window.rs b/backend/canisters/group/impl/src/queries/events_window.rs index c0b55234a5..419a3c8f71 100644 --- a/backend/canisters/group/impl/src/queries/events_window.rs +++ b/backend/canisters/group/impl/src/queries/events_window.rs @@ -7,7 +7,7 @@ use group_canister::c2c_events_window::Args as C2CArgs; use group_canister::events_window::{Response::*, *}; use group_chat_core::EventsResult; -#[query(candid = true)] +#[query(candid = true, msgpack = true)] fn events_window(args: Args) -> Response { read_state(|state| events_window_impl(args, None, state)) } diff --git a/backend/canisters/group/impl/src/queries/summary.rs b/backend/canisters/group/impl/src/queries/summary.rs index 3e68a422c0..74102b83d9 100644 --- a/backend/canisters/group/impl/src/queries/summary.rs +++ b/backend/canisters/group/impl/src/queries/summary.rs @@ -5,7 +5,7 @@ use canister_api_macros::query; use group_canister::c2c_summary::{Args as C2CArgs, Response as C2CResponse}; use group_canister::summary::{Response::*, *}; -#[query(candid = true)] +#[query(candid = true, msgpack = true)] fn summary(_: Args) -> Response { read_state(|state| summary_impl(None, state)) } diff --git a/backend/canisters/group/impl/src/queries/summary_updates.rs b/backend/canisters/group/impl/src/queries/summary_updates.rs index 0de6503e10..3647a88515 100644 --- a/backend/canisters/group/impl/src/queries/summary_updates.rs +++ b/backend/canisters/group/impl/src/queries/summary_updates.rs @@ -7,7 +7,7 @@ use types::{ GroupCanisterGroupChatSummaryUpdates, GroupMembershipUpdates, OptionUpdate, TimestampMillis, MAX_THREADS_IN_SUMMARY, }; -#[query(candid = true)] +#[query(candid = true, msgpack = true)] fn summary_updates(args: Args) -> Response { read_state(|state| summary_updates_impl(args.updates_since, None, state)) } diff --git a/frontend/openchat-agent/src/typebox.ts b/frontend/openchat-agent/src/typebox.ts index 5750a4a7d7..a6ce8a8585 100644 --- a/frontend/openchat-agent/src/typebox.ts +++ b/frontend/openchat-agent/src/typebox.ts @@ -306,6 +306,13 @@ export const UserManageFavouriteChatsResponse = Type.Union([ Type.Literal("UserSuspended"), ]); +export type UserMessageActivitySummary = Static; +export const UserMessageActivitySummary = Type.Object({ + read_up_to: Type.BigInt(), + latest_event: Type.BigInt(), + unread_count: Type.Number(), +}); + export type UserMarkAchievementsSeenArgs = Static; export const UserMarkAchievementsSeenArgs = Type.Object({ last_seen: Type.BigInt(), @@ -2614,6 +2621,29 @@ export const CommunityMessagesByMessageIndexArgs = Type.Object({ latest_known_update: Type.Optional(Type.BigInt()), }); +export type CommunityRegisterProposalVoteV2Args = Static< + typeof CommunityRegisterProposalVoteV2Args +>; +export const CommunityRegisterProposalVoteV2Args = Type.Object({ + channel_id: Type.BigInt(), + message_index: MessageIndex, + adopt: Type.Boolean(), +}); + +export type CommunityRegisterProposalVoteV2Response = Static< + typeof CommunityRegisterProposalVoteV2Response +>; +export const CommunityRegisterProposalVoteV2Response = Type.Union([ + Type.Literal("Success"), + Type.Literal("CommunityFrozen"), + Type.Literal("UserNotInCommunity"), + Type.Literal("UserSuspended"), + Type.Literal("ChannelNotFound"), + Type.Literal("UserNotInChannel"), + Type.Literal("ProposalMessageNotFound"), + Type.Literal("UserLapsed"), +]); + export type CommunityDeleteUserGroupsResponse = Static; export const CommunityDeleteUserGroupsResponse = Type.Union([ Type.Literal("Success"), @@ -2784,7 +2814,7 @@ export const CommunitySendMessageSuccessResult = Type.Object({ event_index: EventIndex, message_index: MessageIndex, timestamp: Type.BigInt(), - expires_at: Type.Optional(Type.BigInt()), + expires_at: Type.Optional(Type.Union([Type.BigInt(), Type.Null()])), }); export type CommunitySendMessageResponse = Static; @@ -3397,7 +3427,7 @@ export const GroupSendMessageSuccessResult = Type.Object({ event_index: EventIndex, message_index: MessageIndex, timestamp: Type.BigInt(), - expires_at: Type.Optional(Type.BigInt()), + expires_at: Type.Optional(Type.Union([Type.BigInt(), Type.Null()])), }); export type GroupSendMessageResponse = Static; @@ -8692,6 +8722,7 @@ export const UserInitialStateSuccessResult = Type.Object({ is_unique_person: Type.Boolean(), wallet_config: UserWalletConfig, referrals: Type.Array(UserReferral), + message_activity_summary: UserMessageActivitySummary, }); export type UserInitialStateResponse = Static; @@ -8722,6 +8753,7 @@ export const UserUpdatesSuccessResult = Type.Object({ is_unique_person: Type.Optional(Type.Boolean()), wallet_config: Type.Optional(UserWalletConfig), referrals: Type.Array(UserReferral), + message_activity_summary: Type.Optional(UserMessageActivitySummary), }); export type UserUpdatesResponse = Static; diff --git a/tsBindings/community/registerProposalVoteV2/CommunityRegisterProposalVoteV2Args.ts b/tsBindings/community/registerProposalVoteV2/CommunityRegisterProposalVoteV2Args.ts new file mode 100644 index 0000000000..fce305dfce --- /dev/null +++ b/tsBindings/community/registerProposalVoteV2/CommunityRegisterProposalVoteV2Args.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { MessageIndex } from "../../shared/MessageIndex"; + +export type CommunityRegisterProposalVoteV2Args = { channel_id: bigint, message_index: MessageIndex, adopt: boolean, }; diff --git a/tsBindings/community/registerProposalVoteV2/CommunityRegisterProposalVoteV2Response.ts b/tsBindings/community/registerProposalVoteV2/CommunityRegisterProposalVoteV2Response.ts new file mode 100644 index 0000000000..ef82f89ca4 --- /dev/null +++ b/tsBindings/community/registerProposalVoteV2/CommunityRegisterProposalVoteV2Response.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type CommunityRegisterProposalVoteV2Response = "Success" | "CommunityFrozen" | "UserNotInCommunity" | "UserSuspended" | "ChannelNotFound" | "UserNotInChannel" | "ProposalMessageNotFound" | "UserLapsed"; diff --git a/tsBindings/types.d.ts b/tsBindings/types.d.ts index cd23294e82..54ebf2469d 100644 --- a/tsBindings/types.d.ts +++ b/tsBindings/types.d.ts @@ -31,6 +31,7 @@ export type GroupReportMessageResponse = "Success" | "UserSuspended" | "UserLaps export type GroupEditMessageResponse = "Success" | "MessageNotFound" | "CallerNotInGroup" | "UserSuspended" | "UserLapsed" | "ChatFrozen"; export type GroupFollowThreadResponse = "Success" | "AlreadyFollowing" | "ThreadNotFound" | "UserNotInGroup" | "UserSuspended" | "UserLapsed" | "GroupFrozen"; export type UserManageFavouriteChatsResponse = "Success" | "UserSuspended"; +export type UserMessageActivitySummary = { read_up_to: bigint, latest_event: bigint, unread_count: number, }; export type UserMarkAchievementsSeenArgs = { last_seen: bigint, }; export type UserMarkAchievementsSeenResponse = "Success"; export type UserBioResponse = { "Success": string }; @@ -265,6 +266,8 @@ export type CommunityChangeChannelRoleResponse = "Success" | "CommunityFrozen" | export type CommunityDeclineInvitationArgs = { channel_id?: bigint, }; export type CommunityDeclineInvitationResponse = "Success" | "NotInvited" | "ChannelNotFound" | "UserNotInCommunity"; export type CommunityMessagesByMessageIndexArgs = { channel_id: bigint, thread_root_message_index?: MessageIndex, messages: Array, latest_known_update?: bigint, }; +export type CommunityRegisterProposalVoteV2Args = { channel_id: bigint, message_index: MessageIndex, adopt: boolean, }; +export type CommunityRegisterProposalVoteV2Response = "Success" | "CommunityFrozen" | "UserNotInCommunity" | "UserSuspended" | "ChannelNotFound" | "UserNotInChannel" | "ProposalMessageNotFound" | "UserLapsed"; export type CommunityDeleteUserGroupsResponse = "Success" | "NotAuthorized" | "CommunityFrozen" | "UserSuspended" | "UserLapsed"; export type CommunityDeleteUserGroupsArgs = { user_group_ids: Array, }; export type CommunityUpdateCommunitySuccessResult = { rules_version?: Version, }; @@ -808,7 +811,7 @@ export type CommunitySummaryResponse = { "Success": CommunityCanisterCommunitySu export type GroupThreadPreviewsResponse = { "Success": GroupThreadPreviewsSuccessResult } | "CallerNotInGroup" | { "ReplicaNotUpToDate": bigint }; export type GroupEventsResponse = { "Success": EventsResponse } | "CallerNotInGroup" | "ThreadMessageNotFound" | "UserSuspended" | "UserLapsed" | { "ReplicaNotUpToDateV2": bigint }; export type UserEventsResponse = { "Success": EventsResponse } | "ChatNotFound" | "ThreadMessageNotFound" | { "ReplicaNotUpToDateV2": bigint }; -export type UserInitialStateSuccessResult = { timestamp: bigint, direct_chats: UserInitialStateDirectChatsInitial, group_chats: UserInitialStateGroupChatsInitial, favourite_chats: UserInitialStateFavouriteChatsInitial, communities: UserInitialStateCommunitiesInitial, avatar_id?: bigint, blocked_users: Array, suspended: boolean, pin_number_settings?: PinNumberSettings, local_user_index_canister_id: TSBytes, achievements: Array, achievements_last_seen: bigint, total_chit_earned: number, chit_balance: number, streak: number, streak_ends: bigint, next_daily_claim: bigint, is_unique_person: boolean, wallet_config: UserWalletConfig, referrals: Array, }; +export type UserInitialStateSuccessResult = { timestamp: bigint, direct_chats: UserInitialStateDirectChatsInitial, group_chats: UserInitialStateGroupChatsInitial, favourite_chats: UserInitialStateFavouriteChatsInitial, communities: UserInitialStateCommunitiesInitial, avatar_id?: bigint, blocked_users: Array, suspended: boolean, pin_number_settings?: PinNumberSettings, local_user_index_canister_id: TSBytes, achievements: Array, achievements_last_seen: bigint, total_chit_earned: number, chit_balance: number, streak: number, streak_ends: bigint, next_daily_claim: bigint, is_unique_person: boolean, wallet_config: UserWalletConfig, referrals: Array, message_activity_summary: UserMessageActivitySummary, }; export type UserInitialStateResponse = { "Success": UserInitialStateSuccessResult }; -export type UserUpdatesSuccessResult = { timestamp: bigint, username?: string, display_name: OptionUpdateString, direct_chats: UserUpdatesDirectChatsUpdates, group_chats: UserUpdatesGroupChatsUpdates, favourite_chats: UserUpdatesFavouriteChatsUpdates, communities: UserUpdatesCommunitiesUpdates, avatar_id: OptionUpdateU128, blocked_users?: Array, suspended?: boolean, pin_number_settings: OptionUpdatePinNumberSettings, achievements: Array, achievements_last_seen?: bigint, total_chit_earned: number, chit_balance: number, streak: number, streak_ends: bigint, next_daily_claim: bigint, is_unique_person?: boolean, wallet_config?: UserWalletConfig, referrals: Array, }; +export type UserUpdatesSuccessResult = { timestamp: bigint, username?: string, display_name: OptionUpdateString, direct_chats: UserUpdatesDirectChatsUpdates, group_chats: UserUpdatesGroupChatsUpdates, favourite_chats: UserUpdatesFavouriteChatsUpdates, communities: UserUpdatesCommunitiesUpdates, avatar_id: OptionUpdateU128, blocked_users?: Array, suspended?: boolean, pin_number_settings: OptionUpdatePinNumberSettings, achievements: Array, achievements_last_seen?: bigint, total_chit_earned: number, chit_balance: number, streak: number, streak_ends: bigint, next_daily_claim: bigint, is_unique_person?: boolean, wallet_config?: UserWalletConfig, referrals: Array, message_activity_summary?: UserMessageActivitySummary, }; export type UserUpdatesResponse = { "Success": UserUpdatesSuccessResult } | "SuccessNoUpdates";