Only send events to clients who need it

- User events (star, rating, plays) only sent to same user
- Don't send to the client (browser window) that originated the event
This commit is contained in:
Deluan
2021-06-15 18:35:08 -04:00
parent 5f6f74ff2d
commit b65e76293a
13 changed files with 197 additions and 63 deletions
+4
View File
@@ -1,15 +1,19 @@
import { fetchUtils } from 'react-admin'
import { v4 as uuidv4 } from 'uuid'
import { baseUrl } from '../utils'
import config from '../config'
import jwtDecode from 'jwt-decode'
const customAuthorizationHeader = 'X-ND-Authorization'
const clientUniqueIdHeader = 'X-ND-Client-Unique-Id'
const clientUniqueId = uuidv4()
const httpClient = (url, options = {}) => {
url = baseUrl(url)
if (!options.headers) {
options.headers = new Headers({ Accept: 'application/json' })
}
options.headers.set(clientUniqueIdHeader, clientUniqueId)
const token = localStorage.getItem('token')
if (token) {
options.headers.set(customAuthorizationHeader, `Bearer ${token}`)