Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak proxy for universal link registration #517

Merged
merged 2 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/platform/src/organizations/OrganizationMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import App from '../app'

export const organizationMiddleware = async (ctx: Context, next: () => void) => {
const organizationId = ctx.cookies.get('organization', { signed: true })
if (organizationId) {
if (!App.main.env.config.multiOrg) {
ctx.state.organization = await getDefaultOrganization()
} else if (organizationId) {
ctx.state.organization = await getOrganization(parseInt(organizationId))
} else if (ctx.subdomains && ctx.subdomains[0]) {
const subdomain = ctx.subdomains[0]
ctx.state.organization = await getOrganizationByUsername(subdomain)
} else if (App.main.env.config.multiOrg) {
ctx.state.organization = await getDefaultOrganization()
}
return next()
}
19 changes: 12 additions & 7 deletions apps/platform/src/providers/push/PushJob.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { EncodedJob, Job } from '../../queue'
import { PushTemplate } from '../../render/Template'
import { createEvent } from '../../users/UserEventRepository'
import { MessageTrigger } from '../MessageTrigger'
import PushError from './PushError'
import { disableNotifications } from '../../users/UserRepository'
Expand All @@ -9,6 +8,7 @@ import { finalizeSend, loadSendJob, messageLock, prepareSend } from '../MessageT
import { loadPushChannel } from '.'
import App from '../../app'
import { releaseLock } from '../../core/Lock'
import { EventPostJob } from '../../jobs'

export default class PushJob extends Job {
static $name = 'push'
Expand Down Expand Up @@ -60,13 +60,18 @@ export default class PushJob extends Job {
})

// Create an event about the disabling
await createEvent(user, {
name: 'notifications_disabled',
data: {
...context,
tokens: error.invalidTokens,
await EventPostJob.from({
project_id: project.id,
user_id: user.id,
event: {
name: 'notifications_disabled',
external_id: user.external_id,
data: {
...context,
tokens: error.invalidTokens,
},
},
})
}).queue()
} else {
App.main.error.notify(error)
}
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/docker/nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ server {
proxy_pass http://api:3001;
}

location ~ ^\/(uploads|unsubscribe|.well-known|(?:c$|c\/)|(?:o$|o\/)) {
location ~ ^\/(uploads|unsubscribe|\.well-known|(?:c$|c\/)|(?:o$|o\/)) {
rewrite ^\/(.*)$ /api/$1 break;
proxy_pass http://api:3001;
}
Expand Down
Loading