Ban User in API interface doesn't have ban reason

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Hassan Khallouf
Posts: 41
Joined: 06 Jul 2017, 04:35

Ban User in API interface doesn't have ban reason

Postby Hassan Khallouf » 01 Nov 2021, 09:34

Hello everyone

recently we implemented a ban request for our mods and we used the following line to do the ban:

Code: Select all

extension.getApi().banUser(...);


However, this method doesn't pass a paramter for ban reason, which will result in no reason recorded for the user if he tried to login again
only ban message paramter is available

internally it's calling the BannedUserManager and passing the reason as an empty string, if we want to use the reason param we have to use the ban manager directly, which goes something like this:

Code: Select all

IBannedUserManager manager = SmartFoxServer.getInstance().getBannedUserManager();
manager.banUser(...);


I find it a very bad practice in general to get the instance this way, but coding practices aside, is there any reason why the ban reason isn't passed in the Api call ?
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Ban User in API interface doesn't have ban reason

Postby Lapo » 02 Nov 2021, 10:54

Hi,
the SFSAPI exposes two banUser methods:

Code: Select all

banUser(User userToBan, User modUser, String banMessage, BanMode mode, int durationMinutes, int delaySeconds)


Code: Select all

banUser(User userToBan, User modUser, String banMessage, String reason, BanMode mode, int durationMinutes, int delaySeconds)


The 2nd one is the one you should be using.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
Hassan Khallouf
Posts: 41
Joined: 06 Jul 2017, 04:35

Re: Ban User in API interface doesn't have ban reason

Postby Hassan Khallouf » 02 Nov 2021, 12:59

are you talking about the ISFSApi interface?
because this is the one we get from calling getApi from an extension, and it only has one ban method overload
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Ban User in API interface doesn't have ban reason

Postby Lapo » 02 Nov 2021, 13:47

What SFS2X version are you using?
Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
Hassan Khallouf
Posts: 41
Joined: 06 Jul 2017, 04:35

Re: Ban User in API interface doesn't have ban reason

Postby Hassan Khallouf » 03 Nov 2021, 09:22

Latest, 2.17.3
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Ban User in API interface doesn't have ban reason

Postby Lapo » 03 Nov 2021, 15:20

Thanks. I was asking because I am working with dev version that is ahead of the latest release.
Indeed the method you're looking for is already present in the current dev version. We should be able to release it within 10-15 days max.

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
Hassan Khallouf
Posts: 41
Joined: 06 Jul 2017, 04:35

Re: Ban User in API interface doesn't have ban reason

Postby Hassan Khallouf » 04 Nov 2021, 09:34

Thanks Lapo, this is really simple issue but the fact that it was missing made me wonder if I have a problem understanding API vs direct usage of managers
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Ban User in API interface doesn't have ban reason

Postby Lapo » 04 Nov 2021, 14:39

Yeah, sorry my bad. Verifying against a development copy bamboozled me :wink:

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 120 guests