Ban a User in a particular firebase firestore group chat for predefined time - flutter

I am very new to coding. but i managed to build a group chat app using a low code platform called flutterflow. i managed to spend significant amount of time on it and was able to build a public group chat app except few functionalities. I am hoping to find help from here. for the following questions.
I have chat mods appointed on a group level. like if you create a group, you are a founder and you can assign mods to that perticular group chat. now i want these mods to be able to ban a user in that particular group chat.
I have tried created a subcollection in groups called "banned user" and created two feilds. one is "banned users" document reference to users. and another is "banned_till" to record a time stamp until the user gets banned.
Problem with this is when i ban a user twice, it creates two documents in the user reference with the same user. and two documents has different "banned_till" times. which one it is supposed to pick?
i tried to do this and put a conditional visibility to the chat that "if current time is less than or equal to banned_till time" it wont let user type in the textfield to chat. but this is giving me gray screen.
I am very new to this. any help would be appreciated.

there is specific way to do so. you have to set custom logic. like save all banned users in a firebase database object with thier max time and procced next.

Related

How to Implement "Your contact just joined app" feature

I am building a mobile app (in flutter firebase, but the answer does not have to be firebase specific). And I would like to implement a feature that notifies users whenever anyone from their contact list joins the app. This seems like a very EXPENSIVE feature.
At the top of my head, I see a lambda/cloud function that is triggered everytime a user joins and then searches a database of users and their respective contacts for the existence of the new user's phone number. To me, this solution does not scale well for two reasons: if the number of total users is in the millions and the number of users joining simultaneously is a lot.
My better solution is to get the user's contacts upon joining and then searching a database of current users contacts for any of the phone numbers of the newly joined user.
Is there a solution better than the second one? If so, what is it? If the second solution is standard, what kind of backend storage mechanism provides the best search and retrieval time for a database of users and their respective contacts?
In the case of large users ill not do first solution because that may slow the sign up process instead i will creat a cron job that runs at a specific time or periodically it will get the list of the latest users signed up that day or that hour whatever you prefer then that cron will check the new user if related to any user in the databases and send a notification right away, or a better solution create a temporary table in a database in another server insert the notification informations into the other server, creat another cron job in the second server it will run at a specific time to sendthe notification

How to know the count of repeated entries in Firestore flutter?

I'm creating a appointment app in flutter using firebase in which I have keep the track of people that got appointment repeatedly based on their phone number . How do I get this count of repeated entries?
it would be better if you add some code and more information to your question so we can can answer correctly but based on my understanding you want to check if this user repeatedly booked appointments using your app considering that it is a logged in user not a guest,
in this case inside your Firestore collection that contains the users i assume that each document represent a user add to each document (user information) a counter (integer variable) called for example "appointementsNumber" and every time a user book an appointment this counter will be increased by one, in this case you are able to know how many times this user booked an appointment.
hopefully i did understand your question correctly.

FIrestore chat rooms with bucketing

First i'd like to add that while this is a Firestore question, im open to hear suggestions about integrating an additional Google service.
The System
I have a chat feature in my application. Since there could be a very decent scale, I decided to have a limit to a chat group.
Chat groups are not created by users and should be created automatically by using some sort of an incrementing index (e.g: room_1, room_2, ...., room_n).
The limit on each chat group is 100 users at most.
So if I have 100k users online, I'd expect to have 1k groups (aka n=1000).
The Issues
How can I distribute users, upon signing in, to chat groups? (Lets say the strategy is to fill current rooms first, hence the 'bucketing' in the title)
Since users can close the app without pressing "quit" or something, I need the system to know to adjust
You can add a counter to the room document and increment/decrement it using by FieldValue.increment, here is an usage example in Javascript:
//when a user enter the room
db.collection('chat_rooms').doc('room_1').update({
userCount: firebase.firestore.FieldValue.increment(1)
});
//when a user quits the room
db.collection('chat_rooms').doc('room_1').update({
userCount: firebase.firestore.FieldValue.increment(-1)
});
Since FieldValue.increment() gets the current value of the counter you don't need to worry about racing conditions, which is good given that you expect to have a huge number of user so this will be constantly updated.
You can wrap this arround a check of the room counter and if the room is over the limit of users you set for rooms a new room can start being filled.
For your second question a bit more information is required, but assuming you are using android you can use the onAppBackgrounded function in the example provided in this community answer to call the update that decrements the counter in the chat room document if the app is backgrounded or closed by the user, as part of the "forcing" him out of the room.

Swift - Parse - Friend list - Possibility to create groups of friends

Could someone give me a link (github/gitlab) of a swift projet which show the possibility of managing Users on Parse.
For example , I would like for a user (who have 15 friends):
to create a group with 5 friends for example (the user could add a name for this group)
to delete if necessary the group
to send a message(textfield) to a group
to send a message (textfield) to a user
For the UI, I would like if it exists, to manager user like the Springboard (having the picture of user in round), and when you longpress on it, you have a cross to delete /and 'block sign' to block user.
And the user could drag/drop other user on his friend list to create a group (like on the Springboard when you create a group of app)
Thanks for helping me !
Have a nice day!
I've not come across such framework for parse/swift. I think you need to build it yourself.
This might help you in the direction:
Friend/de-friend people: https://stackoverflow.com/a/32557977/3314336 &
Parse Swift: User relations with a "friends request"
Send messages framework: https://github.com/slackhq/SlackTextViewController
What you're asking for is pretty general and extensive. You could use Roles and Relations to manage friend groups. You could have Group objects, give them an owner, and a relation for all the members of the group.
For chat, I'd recommend not trying to just build that directly into Parse. Twilio recently released their Programmable Chat feature, which is awesome. Sounds like it'd be beneficial for you to use that.

How do I show information to users belonging to different groups (web) in modx

I have created a website using modx evolution v1.0.2.
The website that I have developed has 12 different types of users (categorized in groups). Each user will be shown a different price depending on the group to which he belongs.
Till now I have been able to fetch the group name of current logged in user (created a snippet for that), but how can I achieve the above mentioned functionality so that each user should be able to see only the price that I have coded according to his group.
For example:
If a user is associated with the 'ocassional' group then he should be shown the price as , say, 50 bucks
and if a user is associated with the 'regular' group then he should be shown the price as, say, 40 bucks
I can easily do this by coding a single snippet for every product's variant, but there are a lot of variants (more than 100 and growing).
I have created a resource(page) for every product and it's variant. Every variant has a price. It is this price that I want to be shown according to the logged in user group membership.
I hope I am able to explain my query clearly.
Please help me do this functionality.
Thanks
I'm not really convinced that modx (as much as i love it) is a great solution for e-commerce sites.
However, the best solution might be to use the database to store the prices of variants per user group and retrieve them yourself using a snippet.