Skip to content

Commit

Permalink
Merge pull request #920 from alromh87/master
Browse files Browse the repository at this point in the history
Fix #903
  • Loading branch information
BenGamma authored Mar 27, 2020
2 parents 80f1109 + e50e5e6 commit 4f037b3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion functions/src/Integrations/firebase-discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export const notifyPinAccepted = functions.firestore
.document('v3_mappins/{pinId}')
.onWrite(async (change, context) => {
const info = change.after.exists ? change.after.data() : null
if (info === null || info.moderation !== 'accepted') {
const prevInfo = change.before.exists ? change.before.data() : null
const beenAccepted = (prevInfo !== null) ? prevInfo.hasBeenAccepted : null;
if (info === null || info.moderation !== 'accepted' || beenAccepted) {
return
}
const { _id, type } = info
Expand Down
1 change: 1 addition & 0 deletions src/models/common.models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export type IModerationStatus =

export interface IModerable {
moderation: IModerationStatus
hasBeenAccepted?: boolean
_createdBy?: string
_id?: string
}
Expand Down
4 changes: 3 additions & 1 deletion src/stores/Maps/maps.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ export class MapsStore extends ModuleStore {
if (!hasAdminRights(this.activeUser)) {
return false
}
if (pin.moderation === 'accepted') {
pin.hasBeenAccepted = true
}
this.setPin(pin)
}
public needsModeration(pin: IMapPin) {
Expand All @@ -177,7 +180,6 @@ export class MapsStore extends ModuleStore {
_id: user.userName,
location: user.location!.latlng,
type: user.profileType ? user.profileType : 'member',
// TODO: keep moderation status ... ' Should we being duplicating info ¿?(user/pin)'
moderation: 'awaiting-moderation',
}
if (user.workspaceType) {
Expand Down

0 comments on commit 4f037b3

Please sign in to comment.