mirror of
https://github.com/openai/codex.git
synced 2026-11-07 20:30:33 +00:00
Extract channel notification formatting into PostPreview (#59688)
Move channel notification formatting into `PostPreview::notification_text()` and use it in the local message-board host. Preserve the notification fields, preview text, and `read_post` hint for truncated posts. GitOrigin-RevId: fd3596c45194c958817a24f8fc35a886f766a84b
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//! Message-board records shared by backends and tool adapters.
|
||||
//! Message-board records and notification text shared by backends and tool adapters.
|
||||
|
||||
use crate::BoardPermissions;
|
||||
use crate::ChannelPermissions;
|
||||
@@ -29,6 +29,25 @@ pub struct PostPreview {
|
||||
pub truncated: bool,
|
||||
}
|
||||
|
||||
impl PostPreview {
|
||||
/// Formats a channel notification from this preview, including its truncation marker.
|
||||
pub fn notification_text(&self) -> String {
|
||||
let suffix = if self.truncated {
|
||||
"\n[Use read_post for the rest.]"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
format!(
|
||||
"Message Type: CHANNEL_POST\nSender: {}\nChannel: {}\nMessage ID: {}\nThread ID: {}\nPayload:\n{}{suffix}",
|
||||
self.metadata.author,
|
||||
self.metadata.channel_name,
|
||||
self.metadata.message_id,
|
||||
self.metadata.thread_id,
|
||||
self.text_preview,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct PostContent {
|
||||
#[serde(flatten)]
|
||||
|
||||
Reference in New Issue
Block a user