Private (owner-only) BuddyVariables
Posted: 20 Jul 2013, 00:49
Hello,
These last days I've been working on implementing a BuddyList system for a project that I've been working on and I've got an idea for a new feature (actually, this can lead to two different feature suggestions).
This BuddyList system has all the common features: add/remove buddy, buddy requests, etc. and we also wanted to implement an "Ignore Requests" feature. Basically, this is a flag that, when true, the user doesn't receive any AddBuddy invitations.
As this is a BuddyList system specific setting, I don't think storing this setting at the database would be a great idea, in terms of organization. Therefore, I've concluded that the best way to store it would be through the BuddyStorage system. So I've decided to use Offline BuddyVariables, but there are some problems with them for this use case:
1. Offline BuddyVariables are transmitted to the owner's buddies, even when he's not online;
2. When updated, if you want to send the update to the owner, by enabling the updateClients flag, it will also update all the owner's buddies about that change;
With this in mind, I tried to find a way to actually separate offline variables from "private" ones. I've noticed that when the BuddyList system is going to send the BuddyVariables to the owner, it calls only the loadList() method of the StorageClass, while when it wants to load the variables from an offline user, it calls the getOfflineVariables() method. So, in order to accomplish what I wanted, I added a separate method for filtering the "private" variables from the buddyList file and I only call it at the end of the loadList() method, and then set these variables to the BuddyProperties object.
But, there's also a problem with this approach. By doing that, the variables are set as online BuddyVariables (I could even turn them into offline, but it would lead to the same problem), and so, the owner's buddies were still receiving them.
So... after struggling for a while, I've decided to continue, I've let my current implementation, which sends the variable only to the owner and doesn't send it when he's not online, but also sends it to his buddies when he's online...
In order to solve this, which I think is a small gap on the whole API, I've came with two ideas. The first one is pretty straight forward, simply implement an extra flag for the SFSBuddyVariable class, for example called isPrivate(), and then update the code responsible for sending the BuddyVariables update so that it doesn't send the update for these kind of variables.
The second idea, which gives a lot more customization possibilities to the developer, is creating a SystemControllerFilter that, instead of acting with the data sent from the client before reaching the Server API, it would act before the data sent from the server actually went through the network. This would enable us (developers) to actually filter the data that is going to be sent by the Server API. In my use case, with that feature, I could simply intercept the BUDDY_VARIABLES_UPDATE event and remove the "private" variables from there.
What do you think?
Thanks for reading
These last days I've been working on implementing a BuddyList system for a project that I've been working on and I've got an idea for a new feature (actually, this can lead to two different feature suggestions).
This BuddyList system has all the common features: add/remove buddy, buddy requests, etc. and we also wanted to implement an "Ignore Requests" feature. Basically, this is a flag that, when true, the user doesn't receive any AddBuddy invitations.
As this is a BuddyList system specific setting, I don't think storing this setting at the database would be a great idea, in terms of organization. Therefore, I've concluded that the best way to store it would be through the BuddyStorage system. So I've decided to use Offline BuddyVariables, but there are some problems with them for this use case:
1. Offline BuddyVariables are transmitted to the owner's buddies, even when he's not online;
2. When updated, if you want to send the update to the owner, by enabling the updateClients flag, it will also update all the owner's buddies about that change;
With this in mind, I tried to find a way to actually separate offline variables from "private" ones. I've noticed that when the BuddyList system is going to send the BuddyVariables to the owner, it calls only the loadList() method of the StorageClass, while when it wants to load the variables from an offline user, it calls the getOfflineVariables() method. So, in order to accomplish what I wanted, I added a separate method for filtering the "private" variables from the buddyList file and I only call it at the end of the loadList() method, and then set these variables to the BuddyProperties object.
But, there's also a problem with this approach. By doing that, the variables are set as online BuddyVariables (I could even turn them into offline, but it would lead to the same problem), and so, the owner's buddies were still receiving them.
So... after struggling for a while, I've decided to continue, I've let my current implementation, which sends the variable only to the owner and doesn't send it when he's not online, but also sends it to his buddies when he's online...
In order to solve this, which I think is a small gap on the whole API, I've came with two ideas. The first one is pretty straight forward, simply implement an extra flag for the SFSBuddyVariable class, for example called isPrivate(), and then update the code responsible for sending the BuddyVariables update so that it doesn't send the update for these kind of variables.
The second idea, which gives a lot more customization possibilities to the developer, is creating a SystemControllerFilter that, instead of acting with the data sent from the client before reaching the Server API, it would act before the data sent from the server actually went through the network. This would enable us (developers) to actually filter the data that is going to be sent by the Server API. In my use case, with that feature, I could simply intercept the BUDDY_VARIABLES_UPDATE event and remove the "private" variables from there.
What do you think?
Thanks for reading