Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
corrideat committed Dec 5, 2024
1 parent cf128a5 commit 3b30b0e
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 30 deletions.
2 changes: 0 additions & 2 deletions backend/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,8 @@ const defaultSocketEventHandlers = {

for (const channelID of socket.subscriptions) {
// Remove this socket from the channel subscribers.
console.error('@@@@CHID', channelID)
server.subscribersByChannelID[channelID].delete(socket)
}
console.error('@@@@CLOSED PUBSUB', [...socket.subscriptions])
socket.subscriptions.clear()
},

Expand Down
5 changes: 0 additions & 5 deletions backend/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ export const pushServerActionhandlers: any = {
[PUSH_SERVER_ACTION_TYPE.SEND_PUBLIC_KEY] () {
const socket = this
socket.send(createMessage(REQUEST_TYPE.PUSH_ACTION, { type: PUSH_SERVER_ACTION_TYPE.SEND_PUBLIC_KEY, data: getVapidPublicKey() }))
console.error('@@@@SENT PK')
},
async [PUSH_SERVER_ACTION_TYPE.STORE_SUBSCRIPTION] (payload) {
const socket = this
Expand Down Expand Up @@ -202,7 +201,6 @@ export const pushServerActionhandlers: any = {
server.pushSubscriptions[subscriptionId].subscriptions.add(channelID)
})
saveSubscription(server, subscriptionId)
console.error('@@@@ADD PUSH SUBSCRIPTION', subscriptionId, subscription.endpoint)
},
[PUSH_SERVER_ACTION_TYPE.DELETE_SUBSCRIPTION] () {
const socket = this
Expand Down Expand Up @@ -273,9 +271,6 @@ export const postEvent = async (subscription: Object, event: ?string): Promise<v
['ttl', '60']
],
body
}).then(async (req) => {
console.error('@@@@postEvent', body, event, subscription.endpoint, req.status, await req.text())
return req
})

if (!req.ok) {
Expand Down
2 changes: 0 additions & 2 deletions backend/rfc8291Ikm.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ export default async (uaPublic: Uint8Array, salt: SharedArrayBuffer): Promise<[A
32 << 3
)

console.error('@@@ asPublic IKM', Buffer.from(asPublic).toString('hex'), Buffer.from(IKM).toString('hex'))

// Role in RFC8188: `asPublic` is used as key ID, IKM as IKM.
return [asPublic, IKM]
}
4 changes: 0 additions & 4 deletions backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,24 +229,20 @@ sbp('okTurtles.data/set', PUBSUB_INSTANCE, createServer(hapi.listener, {
const { server } = this

const subscriptionId = socket.pushSubscriptionId
console.error('@@@PUSHSUBS close evt', socket.pushSubscriptionId)

if (!subscriptionId) return
delete socket.pushSubscriptionId

console.error('@@@PUSHSUBS close', socket.pushSubscriptionId, server.pushSubscriptions[subscriptionId], server.pushSubscriptions[subscriptionId].sockets.size)
if (!server.pushSubscriptions[subscriptionId]) return

server.pushSubscriptions[subscriptionId].sockets.delete(socket)
delete socket.pushSubscriptionId

if (server.pushSubscriptions[subscriptionId].sockets.size === 0) {
console.error('@@@PUSHSUBS close sz=0', socket.pushSubscriptionId, server.pushSubscriptions[subscriptionId])
server.pushSubscriptions[subscriptionId].subscriptions.forEach((channelID) => {
if (!server.subscribersByChannelID[channelID]) {
server.subscribersByChannelID[channelID] = new Set()
}
console.error('@@@PUSHSUBS close add', socket.pushSubscriptionId, channelID)
server.subscribersByChannelID[channelID].add(server.pushSubscriptions[subscriptionId])
})
}
Expand Down
2 changes: 0 additions & 2 deletions backend/vapid.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ const generateJwt = async (endpoint: URL): Promise<string> => {
)
).toString('base64url')

console.error('@@@JWT', [header, body, signature].join('.'))

return [header, body, signature].join('.')
}

Expand Down
1 change: 1 addition & 0 deletions frontend/controller/serviceworkers/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ self.addEventListener('push', function (event) {
}).catch((e) => {
console.error('Error processing push event', e)
if (data.contractType === 'gi.contracts/chatroom') {
// TODO: Text for this notification
return makeNotification({ title: '@@@err', body: e.message })
}
}))
Expand Down
8 changes: 0 additions & 8 deletions frontend/model/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ const localforage = {
reject(new Error('Unsupported characters in name: -'))
return
}
// TODO REMOVEME
if (!self.indexedDB) {
throw new Error('NO self.indexedDB' + typeof indexedDB)
}
if (!self.indexedDB.open) {
throw new Error('NO self.indexedDB.open')
}
// END TODO REMOVEME
const request = self.indexedDB.open(name + '--' + storeName)

// Create the object store if it doesn't exist
Expand Down
1 change: 0 additions & 1 deletion frontend/model/notifications/messageReceivePostEffect.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ async function messageReceivePostEffect ({
memberID: string,
chatRoomName: string
}): Promise<void> {
// TODO: This can't be a root getter when running in a SW
const rootGetters = await sbp('state/vuex/getters')
const rootState = await sbp('state/vuex/state')
const identityContractID = rootState.loggedIn?.identityContractID
Expand Down
4 changes: 0 additions & 4 deletions test/cypress/integration/group-chat-direct-message.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,10 @@ describe('Create/Join direct messages and orders of direct message channels', ()
})

it('user3 adds user2 to the DM, so all group members are in the same DM', () => {
cy.log('@@XXXXXXXX')
switchUser(user3)
cy.log('@@YYYYYYYY')
cy.giRedirectToGroupChat()
cy.log('@@ZZZZZZZZ')

openDMByMembers([user4, user1])
cy.log('@@WWWWWWW')

cy.getByDT('channelName').within(() => {
cy.getByDT('menuTrigger').click()
Expand Down
3 changes: 1 addition & 2 deletions test/cypress/support/output-logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ Cypress.on('fail', (error) => {
// capture them with the handler above. The logs can get pretty big, and this
// interferes with being able to upload test results to Cypress Cloud. Hence,
// the `.slice(-500)` part below to only keep the last 500 lines.
// TODO: Restore the slice part
error.stack += '[' + logs./* slice(-500) */join('\n') + ']'
error.stack += '[' + logs.slice(-500).join('\n') + ']'
// clear logs after fail so we dont see duplicate logs
logs = []
// still need to throw the error so tests wont be marked as a pass
Expand Down

0 comments on commit 3b30b0e

Please sign in to comment.