add: live browser notifications
This commit is contained in:
parent
58d206eb81
commit
98d6f21e6e
18 changed files with 291 additions and 15 deletions
|
@ -146,7 +146,7 @@ pub async fn stream_request(
|
|||
Query(props): Query<PaginatedQuery>,
|
||||
) -> impl IntoResponse {
|
||||
let data = data.read().await;
|
||||
let user = match get_user_from_token!(jar, data.0) {
|
||||
let mut user = match get_user_from_token!(jar, data.0) {
|
||||
Some(ua) => ua,
|
||||
None => {
|
||||
return Err(Html(
|
||||
|
@ -168,6 +168,21 @@ pub async fn stream_request(
|
|||
Err(e) => return Err(Html(render_error(e, &jar, &data, &Some(user)).await)),
|
||||
};
|
||||
|
||||
if props.page == 0 {
|
||||
if let Some(ref last_message) = messages.get(messages.len() - 1) {
|
||||
user.subscriptions.insert(channel, last_message.0.id);
|
||||
|
||||
// maybe make update_user_subscriptions take a reference to avoid cloning
|
||||
if let Err(e) = data
|
||||
.0
|
||||
.update_user_subscriptions(user.id, user.subscriptions.clone())
|
||||
.await
|
||||
{
|
||||
return Err(Html(render_error(e, &jar, &data, &Some(user)).await));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let membership = match data
|
||||
.0
|
||||
.get_membership_by_owner_community(user.id, community)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue