Skip to content

Commit

Permalink
fix(server): revert 55cad96 (#2633)
Browse files Browse the repository at this point in the history
* Revert "refactor(server/upload): convert js to ts (#2618)"

This reverts commit e9f7286.

* Revert "feat(logging): pass request logger to core/services/objects (#2599)"

This reverts commit ee3e9af.

* Revert "feat(server): configurable maximum objects POST size and improved logging (#2594)"

This reverts commit 55cad96.
  • Loading branch information
iainsproat authored Aug 12, 2024
1 parent fc079b2 commit f2c5677
Show file tree
Hide file tree
Showing 23 changed files with 377 additions and 584 deletions.
4 changes: 2 additions & 2 deletions packages/fileimport-service/ifc/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = class ServerAPI {
obj.id = crypto.createHash('md5').update(JSON.stringify(obj)).digest('hex')
}

await this.createObject({ streamId: this.streamId, object: obj })
await this.createObject(this.streamId, obj)

return obj.id
}
Expand All @@ -40,7 +40,7 @@ module.exports = class ServerAPI {
return await this.createObjectsBatched(this.streamId, objs)
}

async createObject({ streamId, object }) {
async createObject(streamId, object) {
const insertionObject = this.prepInsertionObject(streamId, object)

const closures = []
Expand Down
4 changes: 2 additions & 2 deletions packages/server/modules/activitystream/tests/activity.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('Activity @activity', () => {
streamSecret.id = resStream1.body.data.streamCreate

// create commit (cr2)
testObj2.id = await createObject({ streamId: streamSecret.id, object: testObj2 })
testObj2.id = await createObject(streamSecret.id, testObj2)
const resCommit1 = await sendRequest(userCr.token, {
query: `mutation { commitCreate(commit: {streamId: "${streamSecret.id}", branchName: "main", objectId: "${testObj2.id}", message: "first commit"})}`
})
Expand All @@ -152,7 +152,7 @@ describe('Activity @activity', () => {
branchPublic.id = resBranch.body.data.branchCreate

// create commit #2 (iz3)
testObj.id = await createObject({ streamId: streamPublic.id, object: testObj })
testObj.id = await createObject(streamPublic.id, testObj)
const resCommit2 = await sendRequest(userIz.token, {
query: `mutation { commitCreate(commit: { streamId: "${streamPublic.id}", branchName: "${branchPublic.name}", objectId: "${testObj.id}", message: "first commit" })}`
})
Expand Down
34 changes: 11 additions & 23 deletions packages/server/modules/comments/tests/comments.graph.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ const queryComments = async ({ apollo, resources, shouldSucceed }) => {
bar: crs({ length: 5 })
}

const objectId = await createObject({ streamId: resources.streamId, object })
const objectId = await createObject(resources.streamId, object)

const numberOfComments = 3
const commentIds = await Promise.all(
Expand Down Expand Up @@ -361,12 +361,9 @@ const queryStreamCommentCount = async ({ apollo, resources, shouldSucceed }) =>
}

const queryObjectCommentCount = async ({ apollo, resources, shouldSucceed }) => {
const objectId = await createObject({
streamId: resources.streamId,
object: {
foo: 'bar',
noise: crs({ length: 5 })
}
const objectId = await createObject(resources.streamId, {
foo: 'bar',
noise: crs({ length: 5 })
})
await createComment({
userId: resources.testActorId,
Expand Down Expand Up @@ -397,12 +394,9 @@ const queryObjectCommentCount = async ({ apollo, resources, shouldSucceed }) =>
}

const queryCommitCommentCount = async ({ apollo, resources, shouldSucceed }) => {
const objectId = await createObject({
streamId: resources.streamId,
object: {
foo: 'bar',
notSignal: crs({ length: 10 })
}
const objectId = await createObject(resources.streamId, {
foo: 'bar',
notSignal: crs({ length: 10 })
})
const commitId = await createCommitByBranchName({
streamId: resources.streamId,
Expand Down Expand Up @@ -444,12 +438,9 @@ const queryCommitCollectionCommentCount = async ({
resources,
shouldSucceed
}) => {
const objectId = await createObject({
streamId: resources.streamId,
object: {
foo: 'bar',
almostMakesSense: crs({ length: 10 })
}
const objectId = await createObject(resources.streamId, {
foo: 'bar',
almostMakesSense: crs({ length: 10 })
})
const commitId = await createCommitByBranchName({
streamId: resources.streamId,
Expand Down Expand Up @@ -852,10 +843,7 @@ describe('Graphql @comments', () => {
})
}

const objectId = await createObject({
streamId: stream.id,
object: { test: 'object' }
})
const objectId = await createObject(stream.id, { test: 'object' })

const { id: commentId } = await createComment({
userId: myTestActor.id,
Expand Down
55 changes: 17 additions & 38 deletions packages/server/modules/comments/tests/comments.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ describe('Comments @comments', () => {

stream.id = await createStream({ ...stream, ownerId: user.id })

testObject1.id = await createObject({ streamId: stream.id, object: testObject1 })
testObject2.id = await createObject({ streamId: stream.id, object: testObject2 })
testObject1.id = await createObject(stream.id, testObject1)
testObject2.id = await createObject(stream.id, testObject2)

commitId1 = await createCommitByBranchName({
streamId: stream.id,
Expand Down Expand Up @@ -163,7 +163,7 @@ describe('Comments @comments', () => {
const streamA = { name: 'Stream A' }
streamA.id = await createStream({ ...streamA, ownerId: user.id })
const objA = { foo: 'bar' }
objA.id = await createObject({ streamId: streamA.id, object: objA })
objA.id = await createObject(streamA.id, objA)
const commA = {}
commA.id = await createCommitByBranchName({
streamId: streamA.id,
Expand All @@ -177,7 +177,7 @@ describe('Comments @comments', () => {
const streamB = { name: 'Stream B' }
streamB.id = await createStream({ ...streamB, ownerId: otherUser.id })
const objB = { qux: 'mux' }
objB.id = await createObject({ streamId: streamB.id, object: objB })
objB.id = await createObject(streamB.id, objB)
const commB = {}
commB.id = await createCommitByBranchName({
streamId: streamB.id,
Expand Down Expand Up @@ -267,7 +267,7 @@ describe('Comments @comments', () => {
const stream = { name: 'Bean Counter' }
stream.id = await createStream({ ...stream, ownerId: user.id })
const obj = { foo: 'bar' }
obj.id = await createObject({ streamId: stream.id, object: obj })
obj.id = await createObject(stream.id, obj)
const commit = {}
commit.id = await createCommitByBranchName({
streamId: stream.id,
Expand Down Expand Up @@ -358,7 +358,7 @@ describe('Comments @comments', () => {
const streamOther = { name: 'Bean Counter' }
streamOther.id = await createStream({ ...streamOther, ownerId: user.id })
const objOther = { 'are you bored': 'yes' }
objOther.id = await createObject({ streamId: streamOther.id, object: objOther })
objOther.id = await createObject(streamOther.id, objOther)
const commitOther = {}
commitOther.id = await createCommitByBranchName({
streamId: streamOther.id,
Expand Down Expand Up @@ -560,10 +560,7 @@ describe('Comments @comments', () => {
})

it('Should not return the same comment multiple times for multi resource comments', async () => {
const localObjectId = await createObject({
streamId: stream.id,
object: { testObject: 1 }
})
const localObjectId = await createObject(stream.id, { testObject: 1 })

const commentCount = 3
for (let i = 0; i < commentCount; i++) {
Expand Down Expand Up @@ -603,11 +600,8 @@ describe('Comments @comments', () => {
})

it('Should handle cursor and limit for queries', async () => {
const localObjectId = await createObject({
streamId: stream.id,
object: {
testObject: 'something completely different'
}
const localObjectId = await createObject(stream.id, {
testObject: 'something completely different'
})

const createdComments = []
Expand Down Expand Up @@ -697,10 +691,7 @@ describe('Comments @comments', () => {
})

it('Should return all the referenced resources for a comment', async () => {
const localObjectId = await createObject({
streamId: stream.id,
object: { anotherTestObject: 1 }
})
const localObjectId = await createObject(stream.id, { anotherTestObject: 1 })
const inputResources = [
{ resourceId: stream.id, resourceType: 'stream' },
{ resourceId: commitId1, resourceType: 'commit' },
Expand Down Expand Up @@ -731,10 +722,7 @@ describe('Comments @comments', () => {
})

it('Should return the same data when querying a single comment vs a list of comments', async () => {
const localObjectId = await createObject({
streamId: stream.id,
object: { anotherTestObject: 42 }
})
const localObjectId = await createObject(stream.id, { anotherTestObject: 42 })
await createComment({
userId: user.id,
input: {
Expand Down Expand Up @@ -765,11 +753,8 @@ describe('Comments @comments', () => {
})

it('Should be able to edit a comment text', async () => {
const localObjectId = await createObject({
streamId: stream.id,
object: {
anotherTestObject: crs({ length: 10 })
}
const localObjectId = await createObject(stream.id, {
anotherTestObject: crs({ length: 10 })
})
const { id: commentId } = await createComment({
userId: user.id,
Expand Down Expand Up @@ -804,11 +789,8 @@ describe('Comments @comments', () => {
})

it('Should not be allowed to edit a comment of another user if its restricted', async () => {
const localObjectId = await createObject({
streamId: stream.id,
object: {
anotherTestObject: crs({ length: 10 })
}
const localObjectId = await createObject(stream.id, {
anotherTestObject: crs({ length: 10 })
})
const { id: commentId } = await createComment({
userId: user.id,
Expand Down Expand Up @@ -926,11 +908,8 @@ describe('Comments @comments', () => {
})

it('Should not query archived comments unless asked', async () => {
const localObjectId = await createObject({
streamId: stream.id,
object: {
testObject: crs({ length: 10 })
}
const localObjectId = await createObject(stream.id, {
testObject: crs({ length: 10 })
})

const commentCount = 15
Expand Down
8 changes: 4 additions & 4 deletions packages/server/modules/core/graph/resolvers/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ export = {
context.resourceAccessRules
)

const ids = await createObjects({
streamId: args.objectInput.streamId,
objects: args.objectInput.objects
})
const ids = await createObjects(
args.objectInput.streamId,
args.objectInput.objects
)
return ids
}
}
Expand Down
Loading

0 comments on commit f2c5677

Please sign in to comment.