Skip to content

Commit 4dd3dc9

Browse files
committed
fix: update participant and room metadata structures to use non-pointer types
1 parent 7644ea4 commit 4dd3dc9

4 files changed

Lines changed: 80 additions & 80 deletions

File tree

router/v3/qall.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (h *Handlers) PlaySoundboardItem(c echo.Context) error {
9393
// 2-2) ルームに参加しているか確認
9494
isParticipant := false
9595
for _, participant := range roomState.Participants {
96-
if *participant.Name == userID.String() {
96+
if participant.Name == userID.String() {
9797
isParticipant = true
9898
break
9999
}
@@ -189,7 +189,7 @@ func (h *Handlers) PatchRoomMetadata(c echo.Context) error {
189189
// Verify user is a participant
190190
isParticipant := false
191191
for _, participant := range targetRoom.Participants {
192-
if *participant.Name == userID.String() {
192+
if participant.Name == userID.String() {
193193
isParticipant = true
194194
break
195195
}
@@ -202,7 +202,7 @@ func (h *Handlers) PatchRoomMetadata(c echo.Context) error {
202202
// Update metadata
203203
metadata := qall.Metadata{
204204
Status: req.Metadata,
205-
IsWebinar: *targetRoom.IsWebinar,
205+
IsWebinar: targetRoom.IsWebinar,
206206
}
207207

208208
_, err = livekitClient.UpdateRoomMetadata(c.Request().Context(), &livekit.UpdateRoomMetadataRequest{
@@ -250,8 +250,8 @@ func (h *Handlers) PatchRoomParticipants(c echo.Context) error {
250250
// userがcanPublishかどうかを確認
251251
canPublish := false
252252
for _, participant := range roomState.Participants {
253-
if *participant.Name == userID.String() {
254-
canPublish = *participant.CanPublish
253+
if participant.Name == userID.String() {
254+
canPublish = participant.CanPublish
255255
break
256256
}
257257
}
@@ -263,10 +263,10 @@ func (h *Handlers) PatchRoomParticipants(c echo.Context) error {
263263
livekitClient := lksdk.NewRoomServiceClient(h.Config.LiveKitHost, h.Config.LiveKitAPIKey, h.Config.LiveKitAPISecret)
264264
for _, participant := range req.Users {
265265
for _, roomParticipant := range roomState.Participants {
266-
if *roomParticipant.Name == participant.UserID {
266+
if roomParticipant.Name == participant.UserID {
267267
_, err := livekitClient.UpdateParticipant(c.Request().Context(), &livekit.UpdateParticipantRequest{
268268
Room: roomID.String(),
269-
Identity: *roomParticipant.Identity,
269+
Identity: roomParticipant.Identity,
270270
Permission: &livekit.ParticipantPermission{
271271
CanPublish: participant.CanPublish,
272272
},
@@ -275,7 +275,7 @@ func (h *Handlers) PatchRoomParticipants(c echo.Context) error {
275275
failedUsers[participant.UserID] = err.Error()
276276
} else {
277277
succeedUsers = append(succeedUsers, participant.UserID)
278-
h.QallRepo.UpdateParticipantCanPublish(roomID.String(), *roomParticipant.Identity, participant.CanPublish)
278+
h.QallRepo.UpdateParticipantCanPublish(roomID.String(), roomParticipant.Identity, participant.CanPublish)
279279
}
280280
}
281281
}
@@ -330,7 +330,7 @@ func (h *Handlers) GetLiveKitToken(c echo.Context) error {
330330

331331
// ルームが存在して、webinar=true の場合はCanPublish=false
332332
isExistingRoom := roomState != nil
333-
if isExistingRoom && *roomState.IsWebinar {
333+
if isExistingRoom && roomState.IsWebinar {
334334
isWebinar = true
335335
}
336336

@@ -341,8 +341,8 @@ func (h *Handlers) GetLiveKitToken(c echo.Context) error {
341341
isAlreadyCanPublish := false
342342
if roomState != nil {
343343
for _, participant := range roomState.Participants {
344-
if *participant.Name == userID.String() {
345-
isAlreadyCanPublish = *participant.CanPublish
344+
if participant.Name == userID.String() {
345+
isAlreadyCanPublish = participant.CanPublish
346346
break
347347
}
348348
}
@@ -391,7 +391,7 @@ func (h *Handlers) GetLiveKitToken(c echo.Context) error {
391391
// ルームが存在しない場合は新規作成
392392
emptyMetadata := ""
393393
roomWithParticipants := qall.RoomWithParticipants{
394-
IsWebinar: &isWebinar,
394+
IsWebinar: isWebinar,
395395
Metadata: &emptyMetadata,
396396
RoomID: roomID,
397397
Participants: []qall.Participant{},

service/qall/roomstate.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ type Participant struct {
2323
Attributes *map[string]string `json:"attributes,omitempty"`
2424

2525
// CanPublish 発言権限
26-
CanPublish *bool `json:"canPublish,omitempty"`
26+
CanPublish bool `json:"canPublish"`
2727

2828
// Identity ユーザーID_RandomUUID
29-
Identity *string `json:"identity,omitempty"`
29+
Identity string `json:"identity"`
3030

3131
// JoinedAt 参加した時刻
32-
JoinedAt *time.Time `json:"joinedAt,omitempty"`
32+
JoinedAt time.Time `json:"joinedAt"`
3333

3434
// Name 表示名
35-
Name *string `json:"name,omitempty"`
35+
Name string `json:"name"`
3636
}
3737

3838
// RoomWithParticipants defines model for RoomWithParticipants.
3939
type RoomWithParticipants struct {
4040
// IsWebinar ウェビナールームかどうか
41-
IsWebinar *bool `json:"isWebinar,omitempty"`
41+
IsWebinar bool `json:"isWebinar"`
4242

4343
// Metadata ルームに関連付けられたカスタム属性
4444
Metadata *string `json:"metadata,omitempty"`

service/qall/roomstate_impl.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ func (r *Repository) AddParticipantToRoomState(room *livekit.Room, participant *
4040
if roomState.RoomID.String() == room.Name {
4141
t := time.Unix(participant.JoinedAt, 0).In(time.FixedZone("Asia/Tokyo", 9*60*60))
4242
r.RoomState[i].Participants = append(r.RoomState[i].Participants, Participant{
43-
Identity: &participant.Identity,
44-
JoinedAt: &t,
45-
Name: &participant.Name,
43+
Identity: participant.Identity,
44+
JoinedAt: t,
45+
Name: participant.Name,
4646
Attributes: &participant.Attributes,
47-
CanPublish: &participant.Permission.CanPublish,
47+
CanPublish: participant.Permission.CanPublish,
4848
})
4949

5050
if r.Hub != nil {
@@ -66,8 +66,8 @@ func (r *Repository) UpdateParticipantCanPublish(roomID string, participantID st
6666
for i, roomState := range r.RoomState {
6767
if roomState.RoomID.String() == roomID {
6868
for j, participant := range roomState.Participants {
69-
if *participant.Identity == participantID {
70-
r.RoomState[i].Participants[j].CanPublish = &canPublish
69+
if participant.Identity == participantID {
70+
r.RoomState[i].Participants[j].CanPublish = canPublish
7171

7272
if r.Hub != nil {
7373
r.Hub.Publish(hub.Message{
@@ -91,14 +91,14 @@ func (r *Repository) UpdateParticipant(roomID string, participant *livekit.Parti
9191
for i, roomState := range r.RoomState {
9292
if roomState.RoomID.String() == roomID {
9393
for j, p := range roomState.Participants {
94-
if *p.Identity == participant.Identity {
94+
if p.Identity == participant.Identity {
9595
t := time.Unix(participant.JoinedAt, 0).In(time.FixedZone("Asia/Tokyo", 9*60*60))
9696
r.RoomState[i].Participants[j] = Participant{
97-
Identity: &participant.Identity,
98-
JoinedAt: &t,
99-
Name: &participant.Name,
97+
Identity: participant.Identity,
98+
JoinedAt: t,
99+
Name: participant.Name,
100100
Attributes: &participant.Attributes,
101-
CanPublish: &participant.Permission.CanPublish,
101+
CanPublish: participant.Permission.CanPublish,
102102
}
103103

104104
if r.Hub != nil {
@@ -123,7 +123,7 @@ func (r *Repository) RemoveParticipant(roomID string, participantID string) {
123123
for i, roomState := range r.RoomState {
124124
if roomState.RoomID.String() == roomID {
125125
for j, participant := range roomState.Participants {
126-
if *participant.Identity == participantID {
126+
if participant.Identity == participantID {
127127
r.RoomState[i].Participants = slices.Delete(r.RoomState[i].Participants, j, j+1)
128128

129129
if r.Hub != nil {
@@ -244,9 +244,9 @@ func (r *Repository) GetRoomsWithParticipantsByLiveKitServer(ctx context.Context
244244
for _, p := range partResp.Participants {
245245
t := time.Unix(p.JoinedAt, 0).In(time.FixedZone("Asia/Tokyo", 9*60*60))
246246
Participants = append(Participants, Participant{
247-
Identity: &p.Identity,
248-
JoinedAt: &t,
249-
Name: &p.Name,
247+
Identity: p.Identity,
248+
JoinedAt: t,
249+
Name: p.Name,
250250
Attributes: &p.Attributes,
251251
})
252252
}
@@ -265,7 +265,7 @@ func (r *Repository) GetRoomsWithParticipantsByLiveKitServer(ctx context.Context
265265

266266
roomWithParticipants = append(roomWithParticipants, RoomWithParticipants{
267267
Metadata: &metadata.Status,
268-
IsWebinar: &metadata.IsWebinar,
268+
IsWebinar: metadata.IsWebinar,
269269
RoomID: roomID,
270270
Participants: Participants,
271271
})

0 commit comments

Comments
 (0)