@@ -25,6 +25,45 @@ def initialize(client)
2525 @client = client
2626 end
2727
28+ # Experimental: Check user profile
29+ #
30+ # Warning: This is an experimental feature and the API is subject to change.
31+ #
32+ # This function is used to check a user profile for moderation.
33+ # This will not create any review queue items for the user profile.
34+ # You can just use this to check whether to allow a certain user profile to be created or not.
35+ #
36+ # @param [string] user_id User ID to be checked
37+ # @param [Hash] profile Profile data to be checked
38+ # @option profile [String] :username Username to be checked
39+ # @option profile [String] :image Image URL to be checked
40+ # @return [StreamChat::StreamResponse]
41+ sig do
42+ params (
43+ user_id : String ,
44+ profile : T ::Hash [ Symbol , T . nilable ( String ) ]
45+ ) . returns ( StreamChat ::StreamResponse )
46+ end
47+ def check_user_profile ( user_id , profile )
48+ raise ArgumentError , 'Either username or image must be provided' if profile [ :username ] . nil? && profile [ :image ] . nil?
49+
50+ moderation_payload = { }
51+ moderation_payload [ :texts ] = [ profile [ :username ] ] if profile [ :username ]
52+ moderation_payload [ :images ] = [ profile [ :image ] ] if profile [ :image ]
53+
54+ check (
55+ T . must ( MODERATION_ENTITY_TYPES [ :userprofile ] ) ,
56+ user_id ,
57+ moderation_payload ,
58+ 'user_profile:default' ,
59+ entity_creator_id : user_id ,
60+ options : {
61+ force_sync : true ,
62+ test_mode : true
63+ }
64+ )
65+ end
66+
2867 # Flags a user with a reason
2968 #
3069 # @param [string] flagged_user_id User ID to be flagged
0 commit comments