diff --git a/api_signaling.go b/api_signaling.go index 5434e500..2edb10aa 100644 --- a/api_signaling.go +++ b/api_signaling.go @@ -1053,6 +1053,7 @@ type EventServerMessageSessionEntry struct { UserId string `json:"userid"` User json.RawMessage `json:"user,omitempty"` RoomSessionId string `json:"roomsessionid,omitempty"` + Federated bool `json:"federated,omitempty"` } func (e *EventServerMessageSessionEntry) Clone() *EventServerMessageSessionEntry { @@ -1061,6 +1062,7 @@ func (e *EventServerMessageSessionEntry) Clone() *EventServerMessageSessionEntry UserId: e.UserId, User: e.User, RoomSessionId: e.RoomSessionId, + Federated: e.Federated, } } diff --git a/docs/standalone-signaling-api-v1.md b/docs/standalone-signaling-api-v1.md index 2fe9b49d..6646bdc6 100644 --- a/docs/standalone-signaling-api-v1.md +++ b/docs/standalone-signaling-api-v1.md @@ -650,6 +650,10 @@ Room event session object: } } +If a session is federated, an additional entry `"federated": true` will be +available. + + Message format (Server -> Client, user(s) left): { diff --git a/federation_test.go b/federation_test.go index ba00fdac..c615e3b5 100644 --- a/federation_test.go +++ b/federation_test.go @@ -137,6 +137,7 @@ func Test_Federation(t *testing.T) { remoteSessionId = evt.SessionId assert.NotEqual(hello2.Hello.SessionId, remoteSessionId) assert.Equal(testDefaultUserId+"2", evt.UserId) + assert.True(evt.Federated) } // The client2 will see its own session id, not the one from the remote server. @@ -183,6 +184,7 @@ func Test_Federation(t *testing.T) { remoteSessionId = evt.SessionId assert.NotEqual(hello2.Hello.SessionId, remoteSessionId) assert.Equal(testDefaultUserId+"2", evt.UserId) + assert.True(evt.Federated) } assert.NoError(client2.RunUntilJoined(ctx, hello1.Hello, hello2.Hello)) @@ -347,6 +349,7 @@ func Test_Federation(t *testing.T) { remoteSessionId4 = evt.SessionId assert.NotEqual(hello4.Hello.SessionId, remoteSessionId) assert.Equal(testDefaultUserId+"4", evt.UserId) + assert.True(evt.Federated) } assert.NoError(client2.RunUntilJoined(ctx, &HelloServerMessage{ @@ -449,6 +452,7 @@ func Test_FederationMedia(t *testing.T) { remoteSessionId = evt.SessionId assert.NotEqual(hello2.Hello.SessionId, remoteSessionId) assert.Equal(testDefaultUserId+"2", evt.UserId) + assert.True(evt.Federated) } // The client2 will see its own session id, not the one from the remote server. @@ -540,6 +544,7 @@ func Test_FederationResume(t *testing.T) { remoteSessionId = evt.SessionId assert.NotEqual(hello2.Hello.SessionId, remoteSessionId) assert.Equal(testDefaultUserId+"2", evt.UserId) + assert.True(evt.Federated) } // The client2 will see its own session id, not the one from the remote server. @@ -667,6 +672,7 @@ func Test_FederationResumeNewSession(t *testing.T) { remoteSessionId = evt.SessionId assert.NotEqual(hello2.Hello.SessionId, remoteSessionId) assert.Equal(hello2.Hello.UserId, evt.UserId) + assert.True(evt.Federated) } // The client2 will see its own session id, not the one from the remote server. @@ -708,6 +714,7 @@ func Test_FederationResumeNewSession(t *testing.T) { remoteSessionId = evt.SessionId assert.NotEqual(hello2.Hello.SessionId, remoteSessionId) assert.Equal(hello2.Hello.UserId, evt.UserId) + assert.True(evt.Federated) } // client2 will join the room again after the reconnect with the new diff --git a/room.go b/room.go index 39ce6bdc..2ef1f890 100644 --- a/room.go +++ b/room.go @@ -367,6 +367,7 @@ func (r *Room) notifySessionJoined(sessionId string) { } if s, ok := s.(*ClientSession); ok { entry.RoomSessionId = s.RoomSessionId() + entry.Federated = s.ClientType() == HelloClientTypeFederation } events = append(events, entry) } @@ -535,6 +536,7 @@ func (r *Room) PublishSessionJoined(session Session, sessionData *RoomSessionDat } if session, ok := session.(*ClientSession); ok { message.Event.Join[0].RoomSessionId = session.RoomSessionId() + message.Event.Join[0].Federated = session.ClientType() == HelloClientTypeFederation } if err := r.publish(message); err != nil { log.Printf("Could not publish session joined message in room %s: %s", r.Id(), err)