fix: default message text query (#3064)

This commit is contained in:
Fabi 2022-01-19 15:13:04 +01:00 committed by GitHub
parent 3902f9adb5
commit eaaf76a6eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -168,14 +168,9 @@ func (q *Queries) CustomMessageTextByTypeAndLanguage(ctx context.Context, aggreg
sq.Eq{
MessageTextColType.identifier(): messageType,
},
sq.Or{
sq.Eq{
MessageTextColAggregateID.identifier(): aggregateID,
},
sq.Eq{
MessageTextColAggregateID.identifier(): domain.IAMID,
},
},
},
).
OrderBy(MessageTextColAggregateID.identifier()).
@ -185,7 +180,11 @@ func (q *Queries) CustomMessageTextByTypeAndLanguage(ctx context.Context, aggreg
}
row := q.client.QueryRowContext(ctx, query, args...)
return scan(row)
msg, err := scan(row)
if errors.IsNotFound(err) {
return q.IAMMessageTextByTypeAndLanguage(ctx, messageType, language)
}
return msg, err
}
func (q *Queries) IAMMessageTextByTypeAndLanguage(ctx context.Context, messageType, language string) (*MessageText, error) {
@ -219,6 +218,7 @@ func (q *Queries) IAMMessageTextByTypeAndLanguage(ctx context.Context, messageTy
}
result := notificationText.GetMessageTextByType(messageType)
result.IsDefault = true
result.AggregateID = domain.IAMID
return result, nil
}