React Native - OneSignal Push Notifications concept setup with conditioning - javascript

I have created a school app which shows the students about the class if it is going to take place or not (Like substitute plan).
In the app, students have two options in the settings, first to select the class (I send the selected class as a tag in OneSignal) and then to select the courses they have in that class (The courses are stored in app local storage in an array).
Now I use these settings that the student has set (the class and the courses) to pass it as a parameter in my API to get the filtered results, and it is also working good.
The problem is just now how should I notify the students when there is a new result or an update?
I did notifications setup only for classes and it is working, first I compare the results and if there is any new result in the new and previous state, the students selected that class will be notified.
But now I also want to apply the course's condition, that if the student has selected any courses then my server side (server side is in PHP) should first check for an update of the selected class and then only send the students the notification which has selected that course, and if the student has selected many courses and there are more than one update for the selected courses only one notification should be sent.
Many Thanks in Advance! I hope I was able to explain it.

as far as i understand u want to select a subset of students dynamically. can we register all students for notif and then call the onesignal api on a subset on the fly?

Related

Looping with Firestore querying [Web/Javascript]

How would I go about setting up a loop to query through my Firestore database structure? I don't believe I'm allowed to post pictures or links yet, so I'll try to give some path examples here. Note that there is a lot more to it than these examples.
Rating->Arrow->Arrow-Rating->(user ID)->(data fields)show_name, user_id, rating
Rating->Arrow->Arrow-Rating->(different user ID)->(data fields)show_name, user_id, rating
......
Rating->Flash->Flash-Rating->(user ID)->((data fields)show_name, user_id, rating<br />
......
To give a quick rundown of what this is all about, I'm trying to develop a mock site (with functionality) for a project, where I can display user created information (user info is created from a concurrently developed Android application) such as ratings.
Basically what I'm trying to do is get and display the average rating for each show, by getting each 'rating' field from each user in the respective "Rating" paths... i.e., getting a user rating from each show (Show-Rating->User ID/(data fields)), going to the next user from the same show, and then going to the next show and doing the same.
I'm just not entirely sure how to start going about this.
I suggest you use a cloud function that listens for changes in the ratings node. Use OnUpdate listener
Store every movie rating in its own node, and only query that node for the rating
This will reduce a lot of computation on the client side and will also be more efficient
Use this guide that describes a distributed counter

Paypal Express Checkout / React - Send Product Information

I'm working on a shop app that I want to use Paypal with to checkout.
I have installed this very nifty React implementation of the Express Checkout Button - https://www.npmjs.com/package/react-paypal-express-checkout
After setting up my merchant account, developer app, and sandbox accounts it was working right away.
The only issue I'm running into is that my app has a built-in cart; Keeping track of what items the user intends to purchase and what options they have selected for each one ( Color, size, quantity, etc ), and the seller needs to know this information so they can ship the correct products.
I was wondering if there is a way I could send some additional information with the purchase to let the seller know what products the user has purchased and what options they have selected. If somehow I could just send one extra string to appear in the seller's account I could easily attach the user's cart info.
Sorry if this is a noob-ish question. I am still fairly new to web-dev.
So I found in the documentation that you can send a table of items using item_list. With each item you can attach a name, as well as a list of options ( size, color, etc,. ) But I cannot find how to format this list in the documentation, and no one seems to know.
So as a workaround I am just attaching the options to the name so the buyer and seller can see a full list of every item and their options.
Here's what it looks like in your paypal transaction -
If anyone needs to use this I forked the node package above and implemented this functionality. Hopefully this can help someone trying to implement paypal into their react shop.

How could I manage permissions of jhipster's authorities?

I am coding a webapp using JHipster code generator.
I created 2 extra roles, now I have 5 in total:
ROLE_USER, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_PRESIDENT, ROLE_VICE_PRESIDENT
I was wondering how could I manage their permissions to show some RESTs.
For example, I would like to let the PRESIDENT add new users to database, other simple users should not see the web service that do the work.
Is there a file that I'm ignoring by mistake that could help me with this feature?
Giving thanks in advice for your precious time,
Manuel
Adding new roles to JHipster needs to be added in 2 places.
The obvious one is the AngularJS frontend. To add your new role to user edit view, you add them to the select options in "user-management.controller.js" at vm.authorities = ['ROLE_USER', 'ROLE_ADMIN']
To enforce the role at different places in UI, you either add your roles to the state JS files. Just add them to data.authorities (check user-management.state.js)
If you like to have a template block visible only if a user has the proper role, check out the hasAnyAuthority directive.
The other Part is to secure the backend. If using a current JHipster version and SQL database, authorities are stored in the database. Add your custom roles to authorities.csv of your liquibase migrations.
Last but not least, you can enforce roles in WebSecurityConfiguration or MicroserviceSecurityConfiguration (just look at the existing antMatchers)

How do I set up services and controllers to communicate effectively?

I am creating a search and filter application for rooms. The user is able to search for a room name (e.g. Conference Room 101) and also able to add filters to narrow down their search (e.g. capacity = 6). I am trying to figure out a good solution of how to setup my services and controllers and have come up with the following solution:
The filterService gets updated by the filterCtrl through the UI and broadcasts('run:search'). This then triggers the searchResultsCtrl to ask searchResultsService for updated searchResults. The same process happens when the user types into the search field (searchFieldCtrl is updated, then updates searchFieldService).
Once searchResultsService receives the request, it gets all the rooms from roomService, applies the filters using applyFilters inside filterService, then gets the searchField and filters out the remaining rooms.
Is this a good solution using broadcasts or is there a better solution that I am missing?
Edit: I've added a workflow diagram for the filters. The same workflow happens for searchField but updates searchFieldCtrl and searchFieldService.

Meteor.js collection & user permission structure

We are starting development of a meteor app that allows users to create a profile, submit a set of search criteria and receive products (held in the app's db) curated by an administrator. I am wondering what the most elegant way of setting up the collections for this would be.
So far, our thinking is to:
Automatically generate user id's (accounts-ui package) and roles (alanning:meteor-roles package) as soon as the search process is
started
Add all user information, including the user id and role generated in step 1, to a "clients" collection
Add all search criteria selected by the user, as well as the user-id, to a separate "searches" collection.
Use search criteria to filter objects in a "products" collection, and deliver results to an admin who then manually curates from
filtered results.
Given the information I've provided, does this sound like the most elegant structure?

Categories

Resources