Add last_message to channels, mark DMs as active.

This commit is contained in:
Paul Makles
2021-01-24 10:24:44 +00:00
parent cb882ce1b2
commit 11f7092fcd
8 changed files with 69 additions and 13 deletions

View File

@@ -101,7 +101,7 @@ pub async fn req(user: User, target: Ref) -> Result<()> {
id.clone(),
format!("<@{}> left the group.", user.id),
)
.publish()
.publish(&target)
.await
.ok();

View File

@@ -17,7 +17,7 @@ pub async fn req(user: User, target: Ref, member: Ref) -> Result<()> {
Err(Error::LabelMe)?
}
if let Channel::Group { id, recipients, .. } = channel {
if let Channel::Group { id, recipients, .. } = &channel {
if recipients.len() >= *MAX_GROUP_SIZE {
Err(Error::GroupTooLarge {
max: *MAX_GROUP_SIZE,
@@ -56,10 +56,10 @@ pub async fn req(user: User, target: Ref, member: Ref) -> Result<()> {
Message::create(
"00000000000000000000000000".to_string(),
id,
id.clone(),
format!("<@{}> added <@{}> to the group.", user.id, member.id),
)
.publish()
.publish(&channel)
.await
.ok();

View File

@@ -70,6 +70,7 @@ pub async fn req(user: User, info: Json<Data>) -> Result<JsonValue> {
.unwrap_or_else(|| "A group.".to_string()),
owner: user.id,
recipients: set.into_iter().collect::<Vec<String>>(),
last_message: None
};
channel.clone().publish().await?;

View File

@@ -16,9 +16,9 @@ pub async fn req(user: User, target: Ref, member: Ref) -> Result<()> {
owner,
recipients,
..
} = channel
} = &channel
{
if &user.id != &owner {
if &user.id != owner {
// figure out if we want to use perm system here
Err(Error::LabelMe)?
}
@@ -55,10 +55,10 @@ pub async fn req(user: User, target: Ref, member: Ref) -> Result<()> {
Message::create(
"00000000000000000000000000".to_string(),
id,
id.clone(),
format!("<@{}> removed <@{}> from the group.", user.id, member.id),
)
.publish()
.publish(&channel)
.await
.ok();

View File

@@ -56,7 +56,7 @@ pub async fn req(user: User, target: Ref, message: Json<Data>) -> Result<JsonVal
edited: None,
};
msg.clone().publish().await?;
msg.clone().publish(&target).await?;
Ok(json!(msg))
}

View File

@@ -40,6 +40,7 @@ pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
id,
active: false,
recipients: vec![user.id, target.id],
last_message: None
}
};