Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
changed room update notification
Browse files Browse the repository at this point in the history
  • Loading branch information
khodzha committed Apr 14, 2020
1 parent 2e4cb13 commit cfa2bc7
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 10 deletions.
10 changes: 10 additions & 0 deletions docs/src/api.room.create.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,13 @@ backend | String | none | The room backend. Available values: janus,
## Unicast response

If successful, the response payload contains a **Room** object.

## Broadcast event

A notification is being sent to the _audience_ topic.

**URI:** `audiences/:audience/events`

**Label:** `room.create`.

**Payload:** created [room](../room.md#room) object.
10 changes: 10 additions & 0 deletions docs/src/api.room.delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,13 @@ id | Uuid | _required_ | The room identifier. The room must not be expired.
## Unicast response

If successful, the response payload contains a deleted **Room** object.

## Broadcast event

A notification is being sent to the _audience_ topic.

**URI:** `audiences/:audience/events`

**Label:** `room.delete`.

**Payload:** deleted [room](../room.md#room) object.
10 changes: 10 additions & 0 deletions docs/src/api.room.md
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
# Room

## Properties

Name | Type | Default | Description
---------------| ---------- | ---------- | ----------------------------------------------------
id | uuid | _required_ | The room identifier.
audience | string | _required_ | The audience of the room.
time | [int, int] | _required_ | Opening and closing timestamps in seconds.
created_at | int | _required_ | Room creation timestamp in seconds.
backend | string | _required_ | Room backend, either `janus` or `none`.
10 changes: 10 additions & 0 deletions docs/src/api.room.update.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,13 @@ backend | String | _optional_ | The room backend. Available values: janus,
## Unicast response

If successful, the response payload contains an updated **Room** object.

## Broadcast event

A notification is being sent to the _audience_ topic.

**URI:** `audiences/:audience/events`

**Label:** `room.update`.

**Payload:** [room](../room.md#room) object.
27 changes: 18 additions & 9 deletions src/app/endpoint/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ impl State {
shared::respond(
&inreq,
object,
Some(("room.create", "rooms")),
Some((
"room.create",
&format!("audiences/{}/events", inreq.payload().audience),
)),
start_timestamp,
authz_time,
)
Expand Down Expand Up @@ -198,10 +201,11 @@ impl State {
inreq.payload().execute(&conn)?
};

let audience = object.audience().to_owned();
shared::respond(
&inreq,
object,
Some(("room.update", &format!("rooms/{}/events", room_id))),
Some(("room.update", &format!("audiences/{}/events", audience))),
start_timestamp,
authz_time,
)
Expand Down Expand Up @@ -245,10 +249,11 @@ impl State {
room::DeleteQuery::new(inreq.payload().id).execute(&conn)?
};

let audience = object.audience().to_owned();
shared::respond(
&inreq,
object,
Some(("room.delete", "rooms")),
Some(("room.delete", &format!("audiences/{}/events", &audience))),
start_timestamp,
authz_time,
)
Expand Down Expand Up @@ -439,7 +444,10 @@ mod test {

assert_eq!(
evt.topic(),
format!("apps/conference.{}/api/{}/rooms", AUDIENCE, API_VERSION),
format!(
"apps/conference.{}/api/{}/audiences/{}/events",
AUDIENCE, API_VERSION, AUDIENCE
),
);

assert_eq!(evt.properties().kind(), "event");
Expand Down Expand Up @@ -639,10 +647,8 @@ mod test {
assert_eq!(
evt.topic(),
format!(
"apps/conference.{}/api/{}/rooms/{}/events",
AUDIENCE,
API_VERSION,
room.id()
"apps/conference.{}/api/{}/audiences/{}/events",
AUDIENCE, API_VERSION, "dev.svc.example.net"
),
);

Expand Down Expand Up @@ -757,7 +763,10 @@ mod test {

assert_eq!(
evt.topic(),
format!("apps/conference.{}/api/{}/rooms", AUDIENCE, API_VERSION),
format!(
"apps/conference.{}/api/{}/audiences/{}/events",
AUDIENCE, API_VERSION, AUDIENCE
),
);

assert_eq!(evt.properties().kind(), "event");
Expand Down
2 changes: 1 addition & 1 deletion src/test_helpers/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::db::{create_pool, ConnectionPool};
use diesel::Connection;
use std::env::var;

const TIMEOUT: u64 = 60000;
const TIMEOUT: u64 = 10;

pub(crate) struct TestDb {
connection_pool: ConnectionPool,
Expand Down

0 comments on commit cfa2bc7

Please sign in to comment.