Skip to content

Commit

Permalink
Revert "First federation steps (#80)"
Browse files Browse the repository at this point in the history
This reverts commit e1e6bed.
  • Loading branch information
mariha committed Mar 6, 2022
1 parent f5fad05 commit 6f13210
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 43 deletions.
1 change: 0 additions & 1 deletion config/lib/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ module.exports.initHelmetHeaders = function (app) {
'fcm.googleapis.com',
'www.facebook.com',
'https://sentry.io',
`http://192.168.0.134/`,
],

// Allows control over Flash and other plugins.
Expand Down
7 changes: 2 additions & 5 deletions modules/offers/client/api/offers.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ export async function getOffer(offerId) {
* @param {int} offerId - id of offer
* @returns Promise<Offer[]> - array of the found offers with limited info, mainly offer id and type.
*/
export async function queryOffers(query = {}, baseUrl = ``) {
const { data } = await axios.get(
`/api/offers?${new URLSearchParams(query)}`,
{ baseURL: baseUrl },
);
export async function queryOffers(query = {}) {
const { data } = await axios.get(`/api/offers?${new URLSearchParams(query)}`);
return data;
}
8 changes: 4 additions & 4 deletions modules/offers/server/controllers/offers.server.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,11 @@ exports.delete = function (req, res) {
* List of Offers
*/
exports.list = function (req, res) {
/* if (!req.user) {
if (!req.user) {
return res.status(403).send({
message: errorService.getErrorMessageByKey('forbidden'),
});
} */
}

// Validate required bounding box query parameters
const coordinateKeys = [
Expand Down Expand Up @@ -608,7 +608,7 @@ exports.list = function (req, res) {
}
}

/* // Filter out users that do not share any circles with the authenticated user
// Filter out users that do not share any circles with the authenticated user
// and chose to not appear in those searches.
const showOnlyInMyCirclesQueries = [{ showOnlyInMyCircles: false }];
req.user.member?.forEach(function (membership) {
Expand All @@ -622,7 +622,7 @@ exports.list = function (req, res) {
$match: {
$or: showOnlyInMyCirclesQueries,
},
}); */
});

// Pick fields and convert to GeoJson Feature
query.push({
Expand Down
6 changes: 3 additions & 3 deletions modules/offers/server/policies/offers.server.policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ exports.invokeRolesPolicies = function () {
*/
exports.isAllowed = function (req, res, next) {
// No offers for non-authenticated nor for authenticated but un-published users
/* if (!req.user || (req.user && !req.user.public)) {
if (!req.user || (req.user && !req.user.public)) {
return res.status(403).send({
message: errorService.getErrorMessageByKey('forbidden'),
});
} */
}

// If an offer is being processed and the current user owns it, then allow any manipulation
if (req.offer && req.user && req.offer.user === req.user._id) {
return next();
}

// Check for user roles
const roles = ['user'];
const roles = req.user && req.user.roles ? req.user.roles : ['guest'];
acl.areAnyRolesAllowed(
roles,
req.route.path,
Expand Down
2 changes: 0 additions & 2 deletions modules/offers/server/routes/offers.server.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
*/
const offersPolicy = require('../policies/offers.server.policy');
const offers = require('../controllers/offers.server.controller');
const cors = require('cors');

module.exports = function (app) {
app.use(cors()); // this is not the place for this but it somehow works here, this adds cors headers
app
.route('/api/offers-by/:offerUserId')
.all(offersPolicy.isAllowed)
Expand Down
25 changes: 3 additions & 22 deletions modules/search/client/components/SearchMap.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,19 +314,13 @@ export default function SearchMap({
}

const layerId = features[0]?.layer?.id;
// add also federated-host-maybe and no
const isFederated = features[0]?.properties?.offer === 'federated-host-yes';

switch (layerId) {
// Hosting or meeting offer
case unclusteredPointLayer.id:
if (features[0]?.id) {
setSelectedState(features[0]);
if (!isFederated) {
openOfferById(features[0].id);
} else {
window.open('https://openhospitality.network'); // get this from elsewhere
}
openOfferById(features[0].id);
}
break;
// Clusters
Expand Down Expand Up @@ -363,29 +357,16 @@ export default function SearchMap({

try {
// @TODO: cancellation when need to re-fetch
const dataFederated = await queryOffers(
{
filters,
...boundingBox,
},
`http://192.168.0.134/`,
);
const data = await queryOffers({
filters,
...boundingBox,
});
dataFederated.features.map(obj => {
const rObj = obj;
rObj.properties.offer = 'federated-host-yes';
return rObj;
});
data.features = data.features.concat(dataFederated.features);
setOffers(data);
} catch (err) {
} catch {
// @TODO Error handling
process.env.NODE_ENV === 'development' &&
// eslint-disable-next-line no-console
console.error(err);
console.error('Could not load offers.');
}
}

Expand Down
8 changes: 2 additions & 6 deletions modules/search/client/components/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,11 @@ export const unclusteredPointLayer = {

// Host yes
'host-yes',
'#3E6B71',
'#58ba58',

// Host no
'host-maybe',
'#ECEFF1',

// federated-host-yes
'federated-host-yes',
'#B0BEC5',
'#f2ae43',

// Other:
'#ccc',
Expand Down

0 comments on commit 6f13210

Please sign in to comment.