|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +module GetStream |
| 4 | + |
| 5 | + module Generated |
| 6 | + |
| 7 | + class ModerationClient |
| 8 | + |
| 9 | + # Experimental: Check user profile |
| 10 | + # |
| 11 | + # Warning: This is an experimental feature and the API is subject to change. |
| 12 | + # |
| 13 | + # This function is used to check a user profile for moderation. |
| 14 | + # This will not create any review queue items for the user profile. |
| 15 | + # You can just use this to check whether to allow a certain user profile |
| 16 | + # to be created or not. |
| 17 | + # |
| 18 | + # @param user_id [String] User ID to be checked |
| 19 | + # @param profile [Hash] Profile data to be checked |
| 20 | + # @option profile [String] :username Username to be checked |
| 21 | + # @option profile [String] :image Image URL to be checked |
| 22 | + # @return [Models::CheckResponse] |
| 23 | + # |
| 24 | + # @example |
| 25 | + # client.moderation.check_user_profile('user-id', |
| 26 | + # { username: 'bad_username', image: 'https://example.com/profile.jpg' }) |
| 27 | + def check_user_profile(user_id, profile) |
| 28 | + if profile[:username].nil? && profile[:image].nil? |
| 29 | + raise ArgumentError, 'Either username or image must be provided' |
| 30 | + end |
| 31 | + |
| 32 | + moderation_payload = Models::ModerationPayload.new |
| 33 | + moderation_payload.texts = [profile[:username]] if profile[:username] |
| 34 | + moderation_payload.images = [profile[:image]] if profile[:image] |
| 35 | + |
| 36 | + check_request = Models::CheckRequest.new( |
| 37 | + entity_type: 'userprofile', |
| 38 | + entity_id: user_id, |
| 39 | + entity_creator_id: user_id, |
| 40 | + moderation_payload: moderation_payload, |
| 41 | + config_key: 'user_profile:default', |
| 42 | + options: { force_sync: true, test_mode: true }, |
| 43 | + ) |
| 44 | + |
| 45 | + check(check_request) |
| 46 | + end |
| 47 | + |
| 48 | + end |
| 49 | + |
| 50 | + end |
| 51 | + |
| 52 | +end |
0 commit comments