forked from jmug/stoatchat
Channels: Include last message id on text channels.
API: Return members when fetching messages. Misc: Remove defunct DISABLE_REGISTRATION variable.
This commit is contained in:
@@ -90,7 +90,7 @@ impl Message {
|
||||
"last_message": {
|
||||
"_id": self.id.clone(),
|
||||
"author": self.author.clone(),
|
||||
"short": text.chars().take(24).collect::<String>()
|
||||
"short": text.chars().take(128).collect::<String>()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -133,6 +133,25 @@ impl Message {
|
||||
})?;
|
||||
}
|
||||
}
|
||||
Channel::TextChannel { id, .. } => {
|
||||
if let Content::Text(_) = &self.content {
|
||||
channels
|
||||
.update_one(
|
||||
doc! { "_id": id },
|
||||
doc! {
|
||||
"$set": {
|
||||
"last_message": &self.id
|
||||
}
|
||||
},
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.map_err(|_| Error::DatabaseError {
|
||||
operation: "update_one",
|
||||
with: "channel",
|
||||
})?;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user