| 693 | return obj.get_feature_state_value(identity=self.context.get("identity")) |
| 694 | |
| 695 | def save(self, **kwargs): # type: ignore[no-untyped-def] |
| 696 | try: |
| 697 | response = super().save(**kwargs) # type: ignore[no-untyped-call] |
| 698 | |
| 699 | feature_state = self.instance |
| 700 | if ( |
| 701 | not feature_state.identity_id # type: ignore[union-attr] |
| 702 | and feature_state.feature.external_resources.exists() # type: ignore[union-attr] |
| 703 | and feature_state.environment.project.github_project.exists() # type: ignore[union-attr] |
| 704 | and feature_state.environment.project.organisation.github_config.exists() # type: ignore[union-attr] |
| 705 | ): |
| 706 | call_github_task( |
| 707 | organisation_id=feature_state.feature.project.organisation_id, # type: ignore[union-attr] |
| 708 | type=GitHubEventType.FLAG_UPDATED.value, |
| 709 | feature=feature_state.feature, # type: ignore[union-attr] |
| 710 | segment_name=None, |
| 711 | url=None, |
| 712 | feature_states=[feature_state], |
| 713 | ) |
| 714 | |
| 715 | if isinstance(feature_state, FeatureState): |
| 716 | post_gitlab_state_change_comment_for_feature_state(feature_state) |
| 717 | |
| 718 | return response |
| 719 | |
| 720 | except django.core.exceptions.ValidationError as e: |
| 721 | raise serializers.ValidationError(str(e)) |
| 722 | |
| 723 | def validate_feature(self, feature): # type: ignore[no-untyped-def] |
| 724 | if self.instance and self.instance.feature_id != feature.id: # type: ignore[union-attr] |