Flagging a channel user

Flag and Unflag a channel user

While having moderators surveying your chats is great, this doesn't scale well. A way to overcome this is to let your users do the work for your moderators: by letting users report other users or specific messages, the work of moderators goes from scanning each message in each channel to investigate each user report (to both users and messages) and react only when deemed necessary.

Flag and Unflag Users

In order to flag a user, create an instance of AmityUserFlagger first:

let userRepository: AmityUserRepository = AmityUserRepository(client: client)
let userToBeFlaggedObject: AmityObject<AmityUser> = userRepository.user(forId: "badUser")

guard let userToBeFlagged: AmityUser = userToBeFlaggedObject.object else { return }

let userFlagger = AmityUserFlagger(client: client, userId: IdOfuserToBeFlagged)

The AmityUserFlagger lets you flag and unflag a user. It also exposes an asynchronous way to check whether the current logged-in user has already flagged the given user or not.

Flag a user

To flag a user, call the following method:

// flag the user
userFlagger.flag { success, error in
  ...
}

Unflag a user

To unflag a user, call the following method:

// unflag the user

userFlagger.unflag { success, error in
  ...
}

Check whether we have already flagged this user

// check whether we already have flagged this user 
userFlagger.isFlaggedByMe { [weak self] isFlaggedByMe in
  if isFlaggedByMe {
    ...
  } else {
    ...
  }
}

Last updated