mirror of
https://github.com/yibaiba/hideck.git
synced 2026-12-06 00:01:20 +00:00
[restore-vowifi-25.08] preserve SMS delivery metadata
This commit is contained in:
1 parent
ea3aa089ba
commit
71d8598f86
2 files changed
+28
-14
No files matched your search
+12
-10
@@ -417,14 +417,15 @@ func deliveryStatusFromInternal(st *imscore.DeliveryStatus) *messaging.DeliveryS
|
||||
Acks: st.Acks,
|
||||
State: st.State,
|
||||
LastError: st.LastError,
|
||||
CreatedAt: st.CreatedAt,
|
||||
UpdatedAt: st.UpdatedAt,
|
||||
}
|
||||
for _, p := range st.Parts {
|
||||
out.Parts = append(out.Parts, messaging.DeliveryPartStatus{
|
||||
PartNo: p.PartNo,
|
||||
CallID: p.CallID,
|
||||
State: p.State,
|
||||
SIPCode: p.SIPCode,
|
||||
RPCause: p.RPCause,
|
||||
PartNo: p.PartNo, CallID: p.CallID, InReplyTo: p.InReplyTo, RPMR: p.RPMR,
|
||||
State: p.State, SIPCode: p.SIPCode, RPCause: p.RPCause,
|
||||
RPCauseText: p.RPCauseText, ErrorText: p.ErrorText,
|
||||
SentAt: p.SentAt, ReportAt: p.ReportAt, CreatedAt: p.CreatedAt, UpdatedAt: p.UpdatedAt,
|
||||
})
|
||||
}
|
||||
return out
|
||||
@@ -445,14 +446,15 @@ func deliveryStatusToInternal(st *messaging.DeliveryStatus) *imscore.DeliverySta
|
||||
Acks: st.Acks,
|
||||
State: st.State,
|
||||
LastError: st.LastError,
|
||||
CreatedAt: st.CreatedAt,
|
||||
UpdatedAt: st.UpdatedAt,
|
||||
}
|
||||
for _, p := range st.Parts {
|
||||
out.Parts = append(out.Parts, imscore.DeliveryPartStatus{
|
||||
PartNo: p.PartNo,
|
||||
CallID: p.CallID,
|
||||
State: p.State,
|
||||
SIPCode: p.SIPCode,
|
||||
RPCause: p.RPCause,
|
||||
PartNo: p.PartNo, CallID: p.CallID, InReplyTo: p.InReplyTo, RPMR: p.RPMR,
|
||||
State: p.State, SIPCode: p.SIPCode, RPCause: p.RPCause,
|
||||
RPCauseText: p.RPCauseText, ErrorText: p.ErrorText,
|
||||
SentAt: p.SentAt, ReportAt: p.ReportAt, CreatedAt: p.CreatedAt, UpdatedAt: p.UpdatedAt,
|
||||
})
|
||||
}
|
||||
return out
|
||||
|
||||
+16
-4
@@ -370,6 +370,9 @@ func TestRuntimeCoreDeliveryStorePreservesOptionalSIPResults(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeliveryStatusConversion(t *testing.T) {
|
||||
createdAt := time.Date(2026, time.August, 10, 1, 58, 25, 0, time.UTC)
|
||||
updatedAt := createdAt.Add(300 * time.Millisecond)
|
||||
reportAt := updatedAt
|
||||
internal := &imscore.DeliveryStatus{
|
||||
MessageID: "m1",
|
||||
IMSI: "310260123456789",
|
||||
@@ -379,17 +382,26 @@ func TestDeliveryStatusConversion(t *testing.T) {
|
||||
PartsTotal: 1,
|
||||
Acks: 1,
|
||||
State: "delivered",
|
||||
Parts: []imscore.DeliveryPartStatus{{PartNo: 1, CallID: "c1", State: "delivered", SIPCode: 200}},
|
||||
CreatedAt: createdAt,
|
||||
UpdatedAt: updatedAt,
|
||||
Parts: []imscore.DeliveryPartStatus{{
|
||||
PartNo: 1, CallID: "c1", InReplyTo: "reply-c1", RPMR: 23,
|
||||
State: "delivered", SIPCode: 200, RPCause: 0, RPCauseText: "accepted",
|
||||
ErrorText: "", SentAt: createdAt, ReportAt: &reportAt,
|
||||
CreatedAt: createdAt, UpdatedAt: updatedAt,
|
||||
}},
|
||||
}
|
||||
ext := deliveryStatusFromInternal(internal)
|
||||
if ext.MessageID != "m1" || ext.State != "delivered" {
|
||||
if ext.MessageID != "m1" || ext.State != "delivered" || ext.CreatedAt != createdAt || ext.UpdatedAt != updatedAt {
|
||||
t.Errorf("converted = %+v", ext)
|
||||
}
|
||||
if len(ext.Parts) != 1 || ext.Parts[0].SIPCode != 200 {
|
||||
if len(ext.Parts) != 1 || ext.Parts[0].SIPCode != 200 || ext.Parts[0].RPMR != 23 ||
|
||||
ext.Parts[0].InReplyTo != "reply-c1" || ext.Parts[0].ReportAt == nil || *ext.Parts[0].ReportAt != reportAt {
|
||||
t.Errorf("parts = %+v", ext.Parts)
|
||||
}
|
||||
back := deliveryStatusToInternal(ext)
|
||||
if back.MessageID != "m1" || len(back.Parts) != 1 {
|
||||
if back.MessageID != "m1" || back.CreatedAt != createdAt || len(back.Parts) != 1 ||
|
||||
back.Parts[0].RPMR != 23 || back.Parts[0].UpdatedAt != updatedAt {
|
||||
t.Errorf("round-trip = %+v", back)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user