feat(bridge): expose poke strength to Flutter
This commit is contained in:
@@ -1695,6 +1695,8 @@ pub enum BridgeEvent {
|
|||||||
message: String,
|
message: String,
|
||||||
/// Target scope (server/channel/private/poke).
|
/// Target scope (server/channel/private/poke).
|
||||||
target: BridgeMessageTarget,
|
target: BridgeMessageTarget,
|
||||||
|
/// Poke notification strength, present only for poke messages.
|
||||||
|
poke_strength: Option<BridgePokeStrength>,
|
||||||
},
|
},
|
||||||
/// Human-readable server activity surfaced from protocol bookkeeping events.
|
/// Human-readable server activity surfaced from protocol bookkeeping events.
|
||||||
ServerActivity {
|
ServerActivity {
|
||||||
@@ -1812,6 +1814,27 @@ impl From<chanora_core::MessageTarget> for BridgeMessageTarget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Bridge poke notification strength.
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
pub enum BridgePokeStrength {
|
||||||
|
/// Poke should be surfaced at full strength.
|
||||||
|
Strong,
|
||||||
|
/// Poke is rate-limited but below overflow severity.
|
||||||
|
Suppressed,
|
||||||
|
/// Poke remains suppressed after repeated suppressed pokes.
|
||||||
|
SuppressedOverflow,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<chanora_core::PokeStrength> for BridgePokeStrength {
|
||||||
|
fn from(strength: chanora_core::PokeStrength) -> Self {
|
||||||
|
match strength {
|
||||||
|
chanora_core::PokeStrength::Strong => Self::Strong,
|
||||||
|
chanora_core::PokeStrength::Suppressed => Self::Suppressed,
|
||||||
|
chanora_core::PokeStrength::SuppressedOverflow => Self::SuppressedOverflow,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Bridge mirror of core join projection sync state.
|
/// Bridge mirror of core join projection sync state.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum BridgeVoiceJoinSyncState {
|
pub enum BridgeVoiceJoinSyncState {
|
||||||
@@ -1958,11 +1981,13 @@ impl From<chanora_core::SessionEvent> for BridgeEvent {
|
|||||||
sender_name,
|
sender_name,
|
||||||
message,
|
message,
|
||||||
target,
|
target,
|
||||||
|
poke_strength,
|
||||||
} => BridgeEvent::ChatMessage {
|
} => BridgeEvent::ChatMessage {
|
||||||
sender_id,
|
sender_id,
|
||||||
sender_name,
|
sender_name,
|
||||||
message,
|
message,
|
||||||
target: target.into(),
|
target: target.into(),
|
||||||
|
poke_strength: poke_strength.map(Into::into),
|
||||||
},
|
},
|
||||||
chanora_core::SessionEvent::ServerActivity { message } => {
|
chanora_core::SessionEvent::ServerActivity { message } => {
|
||||||
BridgeEvent::ServerActivity { message }
|
BridgeEvent::ServerActivity { message }
|
||||||
|
|||||||
@@ -2292,11 +2292,14 @@ impl SseDecode for crate::api::BridgeEvent {
|
|||||||
let mut var_senderName = <String>::sse_decode(deserializer);
|
let mut var_senderName = <String>::sse_decode(deserializer);
|
||||||
let mut var_message = <String>::sse_decode(deserializer);
|
let mut var_message = <String>::sse_decode(deserializer);
|
||||||
let mut var_target = <crate::api::BridgeMessageTarget>::sse_decode(deserializer);
|
let mut var_target = <crate::api::BridgeMessageTarget>::sse_decode(deserializer);
|
||||||
|
let mut var_pokeStrength =
|
||||||
|
<Option<crate::api::BridgePokeStrength>>::sse_decode(deserializer);
|
||||||
return crate::api::BridgeEvent::ChatMessage {
|
return crate::api::BridgeEvent::ChatMessage {
|
||||||
sender_id: var_senderId,
|
sender_id: var_senderId,
|
||||||
sender_name: var_senderName,
|
sender_name: var_senderName,
|
||||||
message: var_message,
|
message: var_message,
|
||||||
target: var_target,
|
target: var_target,
|
||||||
|
poke_strength: var_pokeStrength,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
11 => {
|
11 => {
|
||||||
@@ -2454,6 +2457,19 @@ impl SseDecode for crate::api::BridgeNetworkState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SseDecode for crate::api::BridgePokeStrength {
|
||||||
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
|
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||||
|
let mut inner = <i32>::sse_decode(deserializer);
|
||||||
|
return match inner {
|
||||||
|
0 => crate::api::BridgePokeStrength::Strong,
|
||||||
|
1 => crate::api::BridgePokeStrength::Suppressed,
|
||||||
|
2 => crate::api::BridgePokeStrength::SuppressedOverflow,
|
||||||
|
_ => unreachable!("Invalid variant for BridgePokeStrength: {}", inner),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl SseDecode for crate::api::BridgePttBinding {
|
impl SseDecode for crate::api::BridgePttBinding {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||||
@@ -2680,6 +2696,17 @@ impl SseDecode for Option<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SseDecode for Option<crate::api::BridgePokeStrength> {
|
||||||
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
|
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||||
|
if (<bool>::sse_decode(deserializer)) {
|
||||||
|
return Some(<crate::api::BridgePokeStrength>::sse_decode(deserializer));
|
||||||
|
} else {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl SseDecode for Option<crate::api::BridgeVoiceJoinErrorCode> {
|
impl SseDecode for Option<crate::api::BridgeVoiceJoinErrorCode> {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||||
@@ -3299,12 +3326,14 @@ impl flutter_rust_bridge::IntoDart for crate::api::BridgeEvent {
|
|||||||
sender_name,
|
sender_name,
|
||||||
message,
|
message,
|
||||||
target,
|
target,
|
||||||
|
poke_strength,
|
||||||
} => [
|
} => [
|
||||||
10.into_dart(),
|
10.into_dart(),
|
||||||
sender_id.into_into_dart().into_dart(),
|
sender_id.into_into_dart().into_dart(),
|
||||||
sender_name.into_into_dart().into_dart(),
|
sender_name.into_into_dart().into_dart(),
|
||||||
message.into_into_dart().into_dart(),
|
message.into_into_dart().into_dart(),
|
||||||
target.into_into_dart().into_dart(),
|
target.into_into_dart().into_dart(),
|
||||||
|
poke_strength.into_into_dart().into_dart(),
|
||||||
]
|
]
|
||||||
.into_dart(),
|
.into_dart(),
|
||||||
crate::api::BridgeEvent::ServerActivity { message } => {
|
crate::api::BridgeEvent::ServerActivity { message } => {
|
||||||
@@ -3484,6 +3513,28 @@ impl flutter_rust_bridge::IntoIntoDart<crate::api::BridgeNetworkState>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||||
|
impl flutter_rust_bridge::IntoDart for crate::api::BridgePokeStrength {
|
||||||
|
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
|
||||||
|
match self {
|
||||||
|
Self::Strong => 0.into_dart(),
|
||||||
|
Self::Suppressed => 1.into_dart(),
|
||||||
|
Self::SuppressedOverflow => 2.into_dart(),
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive
|
||||||
|
for crate::api::BridgePokeStrength
|
||||||
|
{
|
||||||
|
}
|
||||||
|
impl flutter_rust_bridge::IntoIntoDart<crate::api::BridgePokeStrength>
|
||||||
|
for crate::api::BridgePokeStrength
|
||||||
|
{
|
||||||
|
fn into_into_dart(self) -> crate::api::BridgePokeStrength {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||||
impl flutter_rust_bridge::IntoDart for crate::api::BridgePttBinding {
|
impl flutter_rust_bridge::IntoDart for crate::api::BridgePttBinding {
|
||||||
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
|
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
|
||||||
[
|
[
|
||||||
@@ -4053,12 +4104,14 @@ impl SseEncode for crate::api::BridgeEvent {
|
|||||||
sender_name,
|
sender_name,
|
||||||
message,
|
message,
|
||||||
target,
|
target,
|
||||||
|
poke_strength,
|
||||||
} => {
|
} => {
|
||||||
<i32>::sse_encode(10, serializer);
|
<i32>::sse_encode(10, serializer);
|
||||||
<u64>::sse_encode(sender_id, serializer);
|
<u64>::sse_encode(sender_id, serializer);
|
||||||
<String>::sse_encode(sender_name, serializer);
|
<String>::sse_encode(sender_name, serializer);
|
||||||
<String>::sse_encode(message, serializer);
|
<String>::sse_encode(message, serializer);
|
||||||
<crate::api::BridgeMessageTarget>::sse_encode(target, serializer);
|
<crate::api::BridgeMessageTarget>::sse_encode(target, serializer);
|
||||||
|
<Option<crate::api::BridgePokeStrength>>::sse_encode(poke_strength, serializer);
|
||||||
}
|
}
|
||||||
crate::api::BridgeEvent::ServerActivity { message } => {
|
crate::api::BridgeEvent::ServerActivity { message } => {
|
||||||
<i32>::sse_encode(11, serializer);
|
<i32>::sse_encode(11, serializer);
|
||||||
@@ -4214,6 +4267,23 @@ impl SseEncode for crate::api::BridgeNetworkState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SseEncode for crate::api::BridgePokeStrength {
|
||||||
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
|
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||||
|
<i32>::sse_encode(
|
||||||
|
match self {
|
||||||
|
crate::api::BridgePokeStrength::Strong => 0,
|
||||||
|
crate::api::BridgePokeStrength::Suppressed => 1,
|
||||||
|
crate::api::BridgePokeStrength::SuppressedOverflow => 2,
|
||||||
|
_ => {
|
||||||
|
unimplemented!("");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
serializer,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl SseEncode for crate::api::BridgePttBinding {
|
impl SseEncode for crate::api::BridgePttBinding {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||||
@@ -4429,6 +4499,16 @@ impl SseEncode for Option<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SseEncode for Option<crate::api::BridgePokeStrength> {
|
||||||
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
|
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||||
|
<bool>::sse_encode(self.is_some(), serializer);
|
||||||
|
if let Some(value) = self {
|
||||||
|
<crate::api::BridgePokeStrength>::sse_encode(value, serializer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl SseEncode for Option<crate::api::BridgeVoiceJoinErrorCode> {
|
impl SseEncode for Option<crate::api::BridgeVoiceJoinErrorCode> {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||||
|
|||||||
Reference in New Issue
Block a user