Skip to content

Commit

Permalink
Fix empty XML caused by recent database update (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
nezorflame authored and xeals committed Nov 28, 2018
1 parent 17d5cc8 commit b27fb6f
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions types/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var (
"EXPIRE_STARTED",
"NOTIFIED",
"READ_RECEIPT_COUNT",
"UNIDENTIFIED",
}

MMSCSVHeaders = []string{
Expand Down Expand Up @@ -90,6 +91,7 @@ var (
"EXPIRE_STARTED",
"NOTIFIED",
"READ_RECEIPT_COUNT",
"UNIDENTIFIED",
}
)

Expand All @@ -116,6 +118,7 @@ type SQLSMS struct {
ExpireStarted uint64 // default 0
Notified uint64 // default 0
ReadReceiptCount uint64 // default 0
Unidentified uint64 // default 0
}

// StatementToSMS converts a of SQL statement to a single SMS.
Expand All @@ -125,10 +128,11 @@ func StatementToSMS(sql *signal.SqlStatement) *SQLSMS {

// ParametersToSMS converts a set of SQL parameters to a single SMS.
func ParametersToSMS(ps []*signal.SqlStatement_SqlParameter) *SQLSMS {
if len(ps) != 22 {
if len(ps) < 22 {
return nil
}
return &SQLSMS{

result := &SQLSMS{
ID: ps[0].GetIntegerParameter(),
ThreadID: ps[1].IntegerParameter,
Address: ps[2].StringParamter,
Expand All @@ -152,6 +156,11 @@ func ParametersToSMS(ps []*signal.SqlStatement_SqlParameter) *SQLSMS {
Notified: ps[20].GetIntegerParameter(),
ReadReceiptCount: ps[21].GetIntegerParameter(),
}
if len(ps) == 23 {
result.Unidentified = ps[22].GetIntegerParameter()
}

return result
}

type SQLMMS struct {
Expand Down Expand Up @@ -197,6 +206,7 @@ type SQLMMS struct {
ExpireStarted uint64 // default 0
Notified uint64 // default 0
ReadReceiptCount uint64 // default 0
Unidentified uint64 // default 0
}

// StatementToMMS converts a of SQL statement to a single MMS.
Expand All @@ -209,7 +219,8 @@ func ParametersToMMS(ps []*signal.SqlStatement_SqlParameter) *SQLMMS {
if len(ps) < 42 {
return nil
}
return &SQLMMS{

result := &SQLMMS{
ID: ps[0].GetIntegerParameter(),
ThreadID: ps[1].IntegerParameter,
DateSent: ps[2].IntegerParameter,
Expand Down Expand Up @@ -253,6 +264,11 @@ func ParametersToMMS(ps []*signal.SqlStatement_SqlParameter) *SQLMMS {
Notified: ps[40].GetIntegerParameter(),
ReadReceiptCount: ps[41].GetIntegerParameter(),
}
if len(ps) == 43 {
result.Unidentified = ps[42].GetIntegerParameter()
}

return result
}

type SQLPart struct {
Expand Down

0 comments on commit b27fb6f

Please sign in to comment.