mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 02:37:24 +08:00
fix: Support filtering notification with contactType
This commit is contained in:
@@ -25,3 +25,8 @@ type NotificationDetails struct {
|
||||
|
||||
UserList jsonutils.JSONObject `json:"user_list"`
|
||||
}
|
||||
|
||||
type NotificationListInput struct {
|
||||
Scope string `json:"scope"`
|
||||
ContactType string `json:"contact_type"`
|
||||
}
|
||||
|
||||
@@ -275,12 +275,12 @@ func (self *SNotificationManager) syncDatabase(ids []string) error {
|
||||
|
||||
// 通知消息列表
|
||||
func (self *SNotificationManager) ListItemFilter(ctx context.Context, q *sqlchemy.SQuery, userCred mcclient.TokenCredential,
|
||||
query jsonutils.JSONObject) (*sqlchemy.SQuery, error) {
|
||||
input api.NotificationListInput) (*sqlchemy.SQuery, error) {
|
||||
|
||||
// no domainID for now
|
||||
scopeStr, err := query.GetString("scope")
|
||||
if err != nil {
|
||||
scopeStr = "system"
|
||||
scopeStr := "system"
|
||||
if len(input.Scope) > 0 {
|
||||
scopeStr = input.Scope
|
||||
}
|
||||
scope := rbacutils.TRbacScope(scopeStr)
|
||||
|
||||
@@ -288,6 +288,10 @@ func (self *SNotificationManager) ListItemFilter(ctx context.Context, q *sqlchem
|
||||
q = q.Equals("uid", userCred.GetUserId())
|
||||
}
|
||||
|
||||
if len(input.ContactType) > 0 {
|
||||
q = q.Equals("contact_type", input.ContactType)
|
||||
}
|
||||
|
||||
q = q.GroupBy("cluster_id").Desc("received_at")
|
||||
return q, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user