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:
Paul
2021-06-11 16:22:35 +01:00
parent f0d1ab390b
commit 0f18a6781d
8 changed files with 62 additions and 10 deletions

View File

@@ -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",
})?;
}
}
_ => {}
}