Skip to content

Commit

Permalink
Add missing MessagePack endpoints (#6547)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Oct 10, 2024
1 parent 1536f53 commit 6dd0553
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 11 deletions.
2 changes: 1 addition & 1 deletion backend/canisters/community/api/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
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,
pub message_index: MessageIndex,
pub adopt: bool,
}

#[ts_export(community, register_proposal_vote_v2)]
#[derive(CandidType, Serialize, Deserialize, Debug)]
pub enum Response {
Success,
Expand Down
2 changes: 1 addition & 1 deletion backend/canisters/community/impl/src/updates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions backend/canisters/group/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion backend/canisters/group/impl/src/queries/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
2 changes: 1 addition & 1 deletion backend/canisters/group/impl/src/queries/events_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
2 changes: 1 addition & 1 deletion backend/canisters/group/impl/src/queries/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
36 changes: 34 additions & 2 deletions frontend/openchat-agent/src/typebox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,13 @@ export const UserManageFavouriteChatsResponse = Type.Union([
Type.Literal("UserSuspended"),
]);

export type UserMessageActivitySummary = Static<typeof UserMessageActivitySummary>;
export const UserMessageActivitySummary = Type.Object({
read_up_to: Type.BigInt(),
latest_event: Type.BigInt(),
unread_count: Type.Number(),
});

export type UserMarkAchievementsSeenArgs = Static<typeof UserMarkAchievementsSeenArgs>;
export const UserMarkAchievementsSeenArgs = Type.Object({
last_seen: Type.BigInt(),
Expand Down Expand Up @@ -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<typeof CommunityDeleteUserGroupsResponse>;
export const CommunityDeleteUserGroupsResponse = Type.Union([
Type.Literal("Success"),
Expand Down Expand Up @@ -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<typeof CommunitySendMessageResponse>;
Expand Down Expand Up @@ -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<typeof GroupSendMessageResponse>;
Expand Down Expand Up @@ -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<typeof UserInitialStateResponse>;
Expand Down Expand Up @@ -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<typeof UserUpdatesResponse>;
Expand Down
Original file line number Diff line number Diff line change
@@ -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, };
Original file line number Diff line number Diff line change
@@ -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";
7 changes: 5 additions & 2 deletions tsBindings/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -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<MessageIndex>, 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<number>, };
export type CommunityUpdateCommunitySuccessResult = { rules_version?: Version, };
Expand Down Expand Up @@ -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<UserId>, suspended: boolean, pin_number_settings?: PinNumberSettings, local_user_index_canister_id: TSBytes, achievements: Array<ChitEarned>, 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<UserReferral>, };
export type UserInitialStateSuccessResult = { timestamp: bigint, direct_chats: UserInitialStateDirectChatsInitial, group_chats: UserInitialStateGroupChatsInitial, favourite_chats: UserInitialStateFavouriteChatsInitial, communities: UserInitialStateCommunitiesInitial, avatar_id?: bigint, blocked_users: Array<UserId>, suspended: boolean, pin_number_settings?: PinNumberSettings, local_user_index_canister_id: TSBytes, achievements: Array<ChitEarned>, 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<UserReferral>, 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<UserId>, suspended?: boolean, pin_number_settings: OptionUpdatePinNumberSettings, achievements: Array<ChitEarned>, 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<UserReferral>, };
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<UserId>, suspended?: boolean, pin_number_settings: OptionUpdatePinNumberSettings, achievements: Array<ChitEarned>, 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<UserReferral>, message_activity_summary?: UserMessageActivitySummary, };
export type UserUpdatesResponse = { "Success": UserUpdatesSuccessResult } | "SuccessNoUpdates";

0 comments on commit 6dd0553

Please sign in to comment.