-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add name to various objects return from Room
Members, Occupants and Messages
- Loading branch information
Showing
34 changed files
with
887 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// prose-core-client/prose-sdk-js | ||
// | ||
// Copyright: 2023, Marc Bauer <mb@nesium.com> | ||
// License: Mozilla Public License v2.0 (MPL v2.0) | ||
|
||
use wasm_bindgen::prelude::wasm_bindgen; | ||
|
||
use prose_core_client::dtos::{ | ||
UserBasicInfo as SdkUserBasicInfo, UserPresenceInfo as SdkUserPresenceInfo, | ||
}; | ||
|
||
use crate::types::{Availability, BareJid}; | ||
|
||
#[wasm_bindgen] | ||
pub struct UserBasicInfo { | ||
jid: BareJid, | ||
name: String, | ||
} | ||
|
||
#[wasm_bindgen] | ||
impl UserBasicInfo { | ||
#[wasm_bindgen(getter)] | ||
pub fn name(&self) -> String { | ||
self.name.clone() | ||
} | ||
|
||
#[wasm_bindgen(getter)] | ||
pub fn jid(&self) -> BareJid { | ||
self.jid.clone().into() | ||
} | ||
} | ||
|
||
impl From<SdkUserBasicInfo> for UserBasicInfo { | ||
fn from(value: SdkUserBasicInfo) -> Self { | ||
Self { | ||
jid: value.jid.into(), | ||
name: value.name, | ||
} | ||
} | ||
} | ||
|
||
#[wasm_bindgen] | ||
pub struct UserPresenceInfo { | ||
jid: BareJid, | ||
name: String, | ||
availability: Availability, | ||
} | ||
|
||
#[wasm_bindgen] | ||
impl UserPresenceInfo { | ||
#[wasm_bindgen(getter)] | ||
pub fn name(&self) -> String { | ||
self.name.clone() | ||
} | ||
|
||
#[wasm_bindgen(getter)] | ||
pub fn jid(&self) -> BareJid { | ||
self.jid.clone().into() | ||
} | ||
|
||
#[wasm_bindgen(getter)] | ||
pub fn availability(&self) -> Availability { | ||
self.availability.clone() | ||
} | ||
} | ||
|
||
impl From<SdkUserPresenceInfo> for UserPresenceInfo { | ||
fn from(value: SdkUserPresenceInfo) -> Self { | ||
Self { | ||
jid: value.jid.into(), | ||
name: value.name, | ||
availability: value.availability.into(), | ||
} | ||
} | ||
} | ||
|
||
#[wasm_bindgen] | ||
extern "C" { | ||
#[wasm_bindgen(typescript_type = "UserBasicInfo[]")] | ||
pub type UserBasicInfoArray; | ||
|
||
#[wasm_bindgen(typescript_type = "UserPresenceInfo[]")] | ||
pub type UserPresenceInfoArray; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// prose-core-client/prose-core-client | ||
// | ||
// Copyright: 2023, Marc Bauer <mb@nesium.com> | ||
// License: Mozilla Public License v2.0 (MPL v2.0) | ||
|
||
use chrono::{DateTime, Utc}; | ||
use jid::Jid; | ||
|
||
use crate::dtos::{MessageId, Reaction, StanzaId}; | ||
|
||
#[derive(Debug, Clone, PartialEq)] | ||
pub struct Message { | ||
pub id: Option<MessageId>, | ||
pub stanza_id: Option<StanzaId>, | ||
pub from: MessageSender, | ||
pub body: String, | ||
pub timestamp: DateTime<Utc>, | ||
pub is_read: bool, | ||
pub is_edited: bool, | ||
pub is_delivered: bool, | ||
pub reactions: Vec<Reaction>, | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq)] | ||
pub struct MessageSender { | ||
pub jid: Jid, | ||
pub name: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.