WithEntityFilter returns a filter function that filters payloads by entity. Change payloads that match the entity type and ID will return true.
(entity params.ForgeEntity)
| 140 | // WithEntityFilter returns a filter function that filters payloads by entity. |
| 141 | // Change payloads that match the entity type and ID will return true. |
| 142 | func WithEntityFilter(entity params.ForgeEntity) dbCommon.PayloadFilterFunc { |
| 143 | return func(payload dbCommon.ChangePayload) bool { |
| 144 | if params.ForgeEntityType(payload.EntityType) != entity.EntityType { |
| 145 | return false |
| 146 | } |
| 147 | var ent IDGetter |
| 148 | var ok bool |
| 149 | switch payload.EntityType { |
| 150 | case dbCommon.RepositoryEntityType: |
| 151 | if entity.EntityType != params.ForgeEntityTypeRepository { |
| 152 | return false |
| 153 | } |
| 154 | ent, ok = payload.Payload.(params.Repository) |
| 155 | case dbCommon.OrganizationEntityType: |
| 156 | if entity.EntityType != params.ForgeEntityTypeOrganization { |
| 157 | return false |
| 158 | } |
| 159 | ent, ok = payload.Payload.(params.Organization) |
| 160 | case dbCommon.EnterpriseEntityType: |
| 161 | if entity.EntityType != params.ForgeEntityTypeEnterprise { |
| 162 | return false |
| 163 | } |
| 164 | ent, ok = payload.Payload.(params.Enterprise) |
| 165 | default: |
| 166 | return false |
| 167 | } |
| 168 | if !ok { |
| 169 | return false |
| 170 | } |
| 171 | return ent.GetID() == entity.ID |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | func WithEntityJobFilter(ghEntity params.ForgeEntity) dbCommon.PayloadFilterFunc { |
| 176 | return func(payload dbCommon.ChangePayload) bool { |