QueryServerJoinedToRoom implements api.RoomserverInternalAPI
( ctx context.Context, request *api.QueryServerJoinedToRoomRequest, response *api.QueryServerJoinedToRoomResponse, )
| 294 | |
| 295 | // QueryServerJoinedToRoom implements api.RoomserverInternalAPI |
| 296 | func (r *Queryer) QueryServerJoinedToRoom( |
| 297 | ctx context.Context, |
| 298 | request *api.QueryServerJoinedToRoomRequest, |
| 299 | response *api.QueryServerJoinedToRoomResponse, |
| 300 | ) error { |
| 301 | info, err := r.DB.RoomInfo(ctx, request.RoomID) |
| 302 | if err != nil { |
| 303 | return fmt.Errorf("r.DB.RoomInfo: %w", err) |
| 304 | } |
| 305 | if info == nil || info.IsStub() { |
| 306 | return nil |
| 307 | } |
| 308 | response.RoomExists = true |
| 309 | |
| 310 | if request.ServerName == r.ServerName || request.ServerName == "" { |
| 311 | response.IsInRoom, err = r.DB.GetLocalServerInRoom(ctx, info.RoomNID) |
| 312 | if err != nil { |
| 313 | return fmt.Errorf("r.DB.GetLocalServerInRoom: %w", err) |
| 314 | } |
| 315 | } else { |
| 316 | response.IsInRoom, err = r.DB.GetServerInRoom(ctx, info.RoomNID, request.ServerName) |
| 317 | if err != nil { |
| 318 | return fmt.Errorf("r.DB.GetServerInRoom: %w", err) |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | return nil |
| 323 | } |
| 324 | |
| 325 | // QueryServerAllowedToSeeEvent implements api.RoomserverInternalAPI |
| 326 | func (r *Queryer) QueryServerAllowedToSeeEvent( |
no test coverage detected