Skip to content

Commit d13b9dc

Browse files
authored
Merge branch 'main' into asherman/nats-replicas
2 parents e1105b8 + 9623516 commit d13b9dc

2 files changed

Lines changed: 109 additions & 34 deletions

File tree

cmd/lfx-v1-sync-helper/handlers_meetings.go

Lines changed: 104 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,14 @@ func convertMapToInputMeeting(ctx context.Context, v1Data map[string]any) (*meet
198198
}
199199
}
200200

201+
// Resolve the primary committee SFID to its v2 UID.
202+
if meeting.Committee != "" {
203+
committeeMappingKey := fmt.Sprintf("committee.sfid.%s", meeting.Committee)
204+
if entry, err := mappingsKV.Get(ctx, committeeMappingKey); err == nil {
205+
meeting.CommitteeUID = string(entry.Value())
206+
}
207+
}
208+
201209
// Set show_meeting_attendees (an attribute that does not exist in PCC)
202210
meeting.ShowMeetingAttendees = shouldShowMeetingAttendees(meeting)
203211

@@ -314,27 +322,46 @@ func handleZoomMeetingUpdate(ctx context.Context, key string, v1Data map[string]
314322

315323
// Try to get committee mappings from the index first
316324
var committees []string
325+
meeting.Committees = []Committee{}
317326
committeeMappings := make(map[string]mappingCommittee)
318327
indexKey := fmt.Sprintf("v1-mappings.meeting-mappings.%s", meetingID)
319328
indexEntry, err := mappingsKV.Get(ctx, indexKey)
320329
if err == nil && indexEntry != nil {
321330
if err := json.Unmarshal(indexEntry.Value(), &committeeMappings); err != nil {
322331
funcLogger.With(errKey, err).WarnContext(ctx, "failed to unmarshal meeting mapping index")
323332
} else {
324-
// Extract committee IDs from the mappings
325-
for committeeID := range committeeMappings {
326-
committees = append(committees, committeeID)
333+
// Resolve each committee's v1 SFID to its v2 UID via the committee.sfid mapping.
334+
for _, cm := range committeeMappings {
335+
committeeMappingKey := fmt.Sprintf("committee.sfid.%s", cm.CommitteeID)
336+
if entry, err := mappingsKV.Get(ctx, committeeMappingKey); err == nil {
337+
committeeUID := string(entry.Value())
338+
committees = append(committees, committeeUID)
339+
meeting.Committees = append(meeting.Committees, Committee{
340+
UID: committeeUID,
341+
AllowedVotingStatuses: cm.CommitteeFilters,
342+
})
343+
} else {
344+
funcLogger.With("committee_sfid", cm.CommitteeID).WarnContext(ctx, "committee SFID not found in mappings, skipping")
345+
}
327346
}
328347
}
329348
}
330349

331-
// Fallback: Extract committees from v1Data if no mappings found
350+
// Fallback: Extract committees from v1Data if no mappings found.
351+
// committee["uid"] in v1Data is a v1 SFID — resolve it to the v2 UID.
332352
if len(committees) == 0 {
333353
if committeesData, ok := v1Data["committees"].([]any); ok {
334354
for _, c := range committeesData {
335355
if committee, ok := c.(map[string]any); ok {
336-
if committeeUID, ok := committee["uid"].(string); ok && committeeUID != "" {
337-
committees = append(committees, committeeUID)
356+
if committeeSFID, ok := committee["uid"].(string); ok && committeeSFID != "" {
357+
committeeMappingKey := fmt.Sprintf("committee.sfid.%s", committeeSFID)
358+
if entry, err := mappingsKV.Get(ctx, committeeMappingKey); err == nil {
359+
committeeUID := string(entry.Value())
360+
committees = append(committees, committeeUID)
361+
meeting.Committees = append(meeting.Committees, Committee{UID: committeeUID})
362+
} else {
363+
funcLogger.With("committee_sfid", committeeSFID).WarnContext(ctx, "committee SFID not found in mappings (fallback), skipping")
364+
}
338365
}
339366
}
340367
}
@@ -635,15 +662,21 @@ func handleZoomMeetingMappingUpdate(ctx context.Context, key string, v1Data map[
635662
funcLogger.With(errKey, err).WarnContext(ctx, "failed to release meeting mapping lock")
636663
}
637664

638-
// Build the committee list from the now-complete index.
665+
// Build the committee list from the now-complete index, resolving each v1 SFID to its v2 UID.
639666
committees := []string{}
640667
meeting.Committees = []Committee{}
641668
for _, committee := range committeeMappings {
642-
committees = append(committees, committee.CommitteeID)
643-
meeting.Committees = append(meeting.Committees, Committee{
644-
UID: committee.CommitteeID,
645-
AllowedVotingStatuses: committee.CommitteeFilters,
646-
})
669+
committeeMappingKey := fmt.Sprintf("committee.sfid.%s", committee.CommitteeID)
670+
if entry, err := mappingsKV.Get(ctx, committeeMappingKey); err == nil {
671+
committeeUID := string(entry.Value())
672+
committees = append(committees, committeeUID)
673+
meeting.Committees = append(meeting.Committees, Committee{
674+
UID: committeeUID,
675+
AllowedVotingStatuses: committee.CommitteeFilters,
676+
})
677+
} else {
678+
funcLogger.With("committee_sfid", committee.CommitteeID).WarnContext(ctx, "committee SFID not found in mappings, skipping")
679+
}
647680
}
648681

649682
tags := getMeetingTags(meeting)
@@ -746,11 +779,17 @@ func handleZoomMeetingMappingDelete(ctx context.Context, key string, mappingID s
746779
committees := []string{}
747780
meeting.Committees = []Committee{}
748781
for _, committee := range committeeMappings {
749-
committees = append(committees, committee.CommitteeID)
750-
meeting.Committees = append(meeting.Committees, Committee{
751-
UID: committee.CommitteeID,
752-
AllowedVotingStatuses: committee.CommitteeFilters,
753-
})
782+
committeeMappingKey := fmt.Sprintf("committee.sfid.%s", committee.CommitteeID)
783+
if entry, err := mappingsKV.Get(ctx, committeeMappingKey); err == nil {
784+
committeeUID := string(entry.Value())
785+
committees = append(committees, committeeUID)
786+
meeting.Committees = append(meeting.Committees, Committee{
787+
UID: committeeUID,
788+
AllowedVotingStatuses: committee.CommitteeFilters,
789+
})
790+
} else {
791+
funcLogger.With("committee_sfid", committee.CommitteeID).WarnContext(ctx, "committee SFID not found in mappings, skipping")
792+
}
754793
}
755794

756795
tags := getMeetingTags(meeting)
@@ -1254,27 +1293,46 @@ func handleZoomPastMeetingUpdate(ctx context.Context, key string, v1Data map[str
12541293

12551294
// Try to get committee mappings from the index first
12561295
var committees []string
1296+
pastMeeting.Committees = []Committee{}
12571297
committeeMappings := make(map[string]mappingCommittee)
12581298
indexKey := fmt.Sprintf("v1-mappings.past-meeting-mappings.%s", uid)
12591299
indexEntry, err := mappingsKV.Get(ctx, indexKey)
12601300
if err == nil && indexEntry != nil {
12611301
if err := json.Unmarshal(indexEntry.Value(), &committeeMappings); err != nil {
12621302
funcLogger.With(errKey, err).WarnContext(ctx, "failed to unmarshal past meeting mapping index")
12631303
} else {
1264-
// Extract committee IDs from the mappings
1265-
for committeeID := range committeeMappings {
1266-
committees = append(committees, committeeID)
1304+
// Resolve each committee's v1 SFID to its v2 UID via the committee.sfid mapping.
1305+
for _, cm := range committeeMappings {
1306+
committeeMappingKey := fmt.Sprintf("committee.sfid.%s", cm.CommitteeID)
1307+
if entry, err := mappingsKV.Get(ctx, committeeMappingKey); err == nil {
1308+
committeeUID := string(entry.Value())
1309+
committees = append(committees, committeeUID)
1310+
pastMeeting.Committees = append(pastMeeting.Committees, Committee{
1311+
UID: committeeUID,
1312+
AllowedVotingStatuses: cm.CommitteeFilters,
1313+
})
1314+
} else {
1315+
funcLogger.With("committee_sfid", cm.CommitteeID).WarnContext(ctx, "committee SFID not found in mappings, skipping")
1316+
}
12671317
}
12681318
}
12691319
}
12701320

1271-
// Fallback: Extract committees from v1Data if no mappings found
1321+
// Fallback: Extract committees from v1Data if no mappings found.
1322+
// committee["uid"] in v1Data is a v1 SFID — resolve it to the v2 UID.
12721323
if len(committees) == 0 {
12731324
if committeesData, ok := v1Data["committees"].([]any); ok {
12741325
for _, c := range committeesData {
12751326
if committee, ok := c.(map[string]any); ok {
1276-
if committeeUID, ok := committee["uid"].(string); ok && committeeUID != "" {
1277-
committees = append(committees, committeeUID)
1327+
if committeeSFID, ok := committee["uid"].(string); ok && committeeSFID != "" {
1328+
committeeMappingKey := fmt.Sprintf("committee.sfid.%s", committeeSFID)
1329+
if entry, err := mappingsKV.Get(ctx, committeeMappingKey); err == nil {
1330+
committeeUID := string(entry.Value())
1331+
committees = append(committees, committeeUID)
1332+
pastMeeting.Committees = append(pastMeeting.Committees, Committee{UID: committeeUID})
1333+
} else {
1334+
funcLogger.With("committee_sfid", committeeSFID).WarnContext(ctx, "committee SFID not found in mappings (fallback), skipping")
1335+
}
12781336
}
12791337
}
12801338
}
@@ -1451,15 +1509,21 @@ func handleZoomPastMeetingMappingUpdate(ctx context.Context, key string, v1Data
14511509
funcLogger.With(errKey, err).WarnContext(ctx, "failed to release past meeting mapping lock")
14521510
}
14531511

1454-
// Build the committee list from the now-complete index and populate the past meeting struct.
1512+
// Build the committee list from the now-complete index, resolving each v1 SFID to its v2 UID.
14551513
committees := []string{}
14561514
pastMeeting.Committees = []Committee{}
14571515
for _, committee := range committeeMappings {
1458-
committees = append(committees, committee.CommitteeID)
1459-
pastMeeting.Committees = append(pastMeeting.Committees, Committee{
1460-
UID: committee.CommitteeID,
1461-
AllowedVotingStatuses: committee.CommitteeFilters,
1462-
})
1516+
committeeMappingKey := fmt.Sprintf("committee.sfid.%s", committee.CommitteeID)
1517+
if entry, err := mappingsKV.Get(ctx, committeeMappingKey); err == nil {
1518+
committeeUID := string(entry.Value())
1519+
committees = append(committees, committeeUID)
1520+
pastMeeting.Committees = append(pastMeeting.Committees, Committee{
1521+
UID: committeeUID,
1522+
AllowedVotingStatuses: committee.CommitteeFilters,
1523+
})
1524+
} else {
1525+
funcLogger.With("committee_sfid", committee.CommitteeID).WarnContext(ctx, "committee SFID not found in mappings, skipping")
1526+
}
14631527
}
14641528

14651529
tags := getPastMeetingTags(pastMeeting)
@@ -1562,11 +1626,17 @@ func handleZoomPastMeetingMappingDelete(ctx context.Context, key string, mapping
15621626
committees := []string{}
15631627
pastMeeting.Committees = []Committee{}
15641628
for _, committee := range committeeMappings {
1565-
committees = append(committees, committee.CommitteeID)
1566-
pastMeeting.Committees = append(pastMeeting.Committees, Committee{
1567-
UID: committee.CommitteeID,
1568-
AllowedVotingStatuses: committee.CommitteeFilters,
1569-
})
1629+
committeeMappingKey := fmt.Sprintf("committee.sfid.%s", committee.CommitteeID)
1630+
if entry, err := mappingsKV.Get(ctx, committeeMappingKey); err == nil {
1631+
committeeUID := string(entry.Value())
1632+
committees = append(committees, committeeUID)
1633+
pastMeeting.Committees = append(pastMeeting.Committees, Committee{
1634+
UID: committeeUID,
1635+
AllowedVotingStatuses: committee.CommitteeFilters,
1636+
})
1637+
} else {
1638+
funcLogger.With("committee_sfid", committee.CommitteeID).WarnContext(ctx, "committee SFID not found in mappings, skipping")
1639+
}
15701640
}
15711641

15721642
tags := getPastMeetingTags(pastMeeting)

cmd/lfx-v1-sync-helper/models_meetings.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ type meetingInput struct {
343343
// It is a Global Secondary Index on the meeting table.
344344
Committee string `json:"committee"`
345345

346+
// CommitteeUID is the v2 UID of the committee.
347+
CommitteeUID string `json:"committee_uid,omitempty"`
348+
346349
// CommitteeFilters is the list of filters associated with the committee
347350
CommitteeFilters []string `json:"committee_filters"`
348351

@@ -548,6 +551,7 @@ func (m *meetingInput) UnmarshalJSON(data []byte) error {
548551
ProjectSFID string `json:"project_sfid"`
549552
ProjectUID string `json:"project_uid"`
550553
Committee string `json:"committee"`
554+
CommitteeUID string `json:"committee_uid,omitempty"`
551555
CommitteeFilters []string `json:"committee_filters"`
552556
Committees []Committee `json:"committees,omitempty"`
553557
User string `json:"user_id"`
@@ -747,6 +751,7 @@ func (m *meetingInput) UnmarshalJSON(data []byte) error {
747751
m.ProjectSFID = tmp.ProjectSFID
748752
m.ProjectUID = tmp.ProjectUID
749753
m.Committee = tmp.Committee
754+
m.CommitteeUID = tmp.CommitteeUID
750755
m.CommitteeFilters = tmp.CommitteeFilters
751756
m.Committees = tmp.Committees
752757
m.User = tmp.User

0 commit comments

Comments
 (0)