@@ -199,6 +199,8 @@ pub enum GroupError {
199
199
MissingPendingCommit ,
200
200
#[ error( "Sync failed to wait for intent" ) ]
201
201
SyncFailedToWait ,
202
+ #[ error( "cannot change metadata of DM" ) ]
203
+ DmGroupMetadataForbidden ,
202
204
}
203
205
204
206
impl RetryableError for GroupError {
@@ -596,8 +598,7 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
596
598
///
597
599
/// If so, adds/removes those group members
598
600
pub async fn update_installations ( & self ) -> Result < ( ) , GroupError > {
599
- let conn = self . context ( ) . store ( ) . conn ( ) ?;
600
- let provider = XmtpOpenMlsProvider :: from ( conn) ;
601
+ let provider = self . client . mls_provider ( ) ?;
601
602
self . maybe_update_installations ( & provider, Some ( 0 ) ) . await ?;
602
603
Ok ( ( ) )
603
604
}
@@ -794,12 +795,15 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
794
795
/// Updates the name of the group. Will error if the user does not have the appropriate permissions
795
796
/// to perform these updates.
796
797
pub async fn update_group_name ( & self , group_name : String ) -> Result < ( ) , GroupError > {
798
+ let provider = self . client . mls_provider ( ) ?;
799
+ if self . metadata ( & provider) ?. conversation_type == ConversationType :: Dm {
800
+ return Err ( GroupError :: DmGroupMetadataForbidden ) ;
801
+ }
797
802
let intent_data: Vec < u8 > =
798
803
UpdateMetadataIntentData :: new_update_group_name ( group_name) . into ( ) ;
799
804
let intent = self . queue_intent ( IntentKind :: MetadataUpdate , intent_data) ?;
800
805
801
- self . sync_until_intent_resolved ( & self . client . mls_provider ( ) ?, intent. id )
802
- . await
806
+ self . sync_until_intent_resolved ( & provider, intent. id ) . await
803
807
}
804
808
805
809
/// Updates the permission policy of the group. This requires super admin permissions.
@@ -809,6 +813,10 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
809
813
permission_policy : PermissionPolicyOption ,
810
814
metadata_field : Option < MetadataField > ,
811
815
) -> Result < ( ) , GroupError > {
816
+ let provider = self . client . mls_provider ( ) ?;
817
+ if self . metadata ( & provider) ?. conversation_type == ConversationType :: Dm {
818
+ return Err ( GroupError :: DmGroupMetadataForbidden ) ;
819
+ }
812
820
if permission_update_type == PermissionUpdateType :: UpdateMetadata
813
821
&& metadata_field. is_none ( )
814
822
{
@@ -824,8 +832,7 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
824
832
825
833
let intent = self . queue_intent ( IntentKind :: UpdatePermission , intent_data) ?;
826
834
827
- self . sync_until_intent_resolved ( & self . client . mls_provider ( ) ?, intent. id )
828
- . await
835
+ self . sync_until_intent_resolved ( & provider, intent. id ) . await
829
836
}
830
837
831
838
/// Retrieves the group name from the group's mutable metadata extension.
@@ -847,12 +854,15 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
847
854
& self ,
848
855
group_description : String ,
849
856
) -> Result < ( ) , GroupError > {
857
+ let provider = self . client . mls_provider ( ) ?;
858
+ if self . metadata ( & provider) ?. conversation_type == ConversationType :: Dm {
859
+ return Err ( GroupError :: DmGroupMetadataForbidden ) ;
860
+ }
850
861
let intent_data: Vec < u8 > =
851
862
UpdateMetadataIntentData :: new_update_group_description ( group_description) . into ( ) ;
852
863
let intent = self . queue_intent ( IntentKind :: MetadataUpdate , intent_data) ?;
853
864
854
- self . sync_until_intent_resolved ( & self . client . mls_provider ( ) ?, intent. id )
855
- . await
865
+ self . sync_until_intent_resolved ( & provider, intent. id ) . await
856
866
}
857
867
858
868
pub fn group_description ( & self , provider : impl OpenMlsProvider ) -> Result < String , GroupError > {
@@ -873,13 +883,16 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
873
883
& self ,
874
884
group_image_url_square : String ,
875
885
) -> Result < ( ) , GroupError > {
886
+ let provider = self . client . mls_provider ( ) ?;
887
+ if self . metadata ( & provider) ?. conversation_type == ConversationType :: Dm {
888
+ return Err ( GroupError :: DmGroupMetadataForbidden ) ;
889
+ }
876
890
let intent_data: Vec < u8 > =
877
891
UpdateMetadataIntentData :: new_update_group_image_url_square ( group_image_url_square)
878
892
. into ( ) ;
879
893
let intent = self . queue_intent ( IntentKind :: MetadataUpdate , intent_data) ?;
880
894
881
- self . sync_until_intent_resolved ( & self . client . mls_provider ( ) ?, intent. id )
882
- . await
895
+ self . sync_until_intent_resolved ( & provider, intent. id ) . await
883
896
}
884
897
885
898
/// Retrieves the image URL (square) of the group from the group's mutable metadata extension.
@@ -903,12 +916,15 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
903
916
& self ,
904
917
pinned_frame_url : String ,
905
918
) -> Result < ( ) , GroupError > {
919
+ let provider = self . client . mls_provider ( ) ?;
920
+ if self . metadata ( & provider) ?. conversation_type == ConversationType :: Dm {
921
+ return Err ( GroupError :: DmGroupMetadataForbidden ) ;
922
+ }
906
923
let intent_data: Vec < u8 > =
907
924
UpdateMetadataIntentData :: new_update_group_pinned_frame_url ( pinned_frame_url) . into ( ) ;
908
925
let intent = self . queue_intent ( IntentKind :: MetadataUpdate , intent_data) ?;
909
926
910
- self . sync_until_intent_resolved ( & self . client . mls_provider ( ) ?, intent. id )
911
- . await
927
+ self . sync_until_intent_resolved ( & provider, intent. id ) . await
912
928
}
913
929
914
930
pub fn group_pinned_frame_url (
@@ -968,6 +984,10 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
968
984
action_type : UpdateAdminListType ,
969
985
inbox_id : String ,
970
986
) -> Result < ( ) , GroupError > {
987
+ let provider = self . client . mls_provider ( ) ?;
988
+ if self . metadata ( & provider) ?. conversation_type == ConversationType :: Dm {
989
+ return Err ( GroupError :: DmGroupMetadataForbidden ) ;
990
+ }
971
991
let intent_action_type = match action_type {
972
992
UpdateAdminListType :: Add => AdminListActionType :: Add ,
973
993
UpdateAdminListType :: Remove => AdminListActionType :: Remove ,
@@ -978,8 +998,7 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
978
998
UpdateAdminListIntentData :: new ( intent_action_type, inbox_id) . into ( ) ;
979
999
let intent = self . queue_intent ( IntentKind :: UpdateAdminList , intent_data) ?;
980
1000
981
- self . sync_until_intent_resolved ( & self . client . mls_provider ( ) ?, intent. id )
982
- . await
1001
+ self . sync_until_intent_resolved ( & provider, intent. id ) . await
983
1002
}
984
1003
985
1004
/// Find the `inbox_id` of the group member who added the member to the group
0 commit comments