Skip to content

Commit

Permalink
Merge pull request #2014 from anyproto/GO-4140-fix-middle-issues
Browse files Browse the repository at this point in the history
GO-4865 | GO-4617 | GO-4866 | GO-4758 | GO-4851:  web publishing fixes
  • Loading branch information
AnastasiaShemyakinskaya authored Jan 17, 2025
2 parents 8d120bf + aabc126 commit 63d784a
Show file tree
Hide file tree
Showing 13 changed files with 3,311 additions and 2,157 deletions.
6 changes: 6 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,9 @@ packages:
github.com/anyproto/anytype-heart/core/kanban:
interfaces:
Service:
github.com/anyproto/anytype-heart/core/core/inviteservice:
interfaces:
InviteService:
github.com/anyproto/anytype-heart/core/identity:
interfaces:
Service:
43 changes: 26 additions & 17 deletions core/block/restriction/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,22 @@ var (
model.Restrictions_TypeChange,
model.Restrictions_Template,
model.Restrictions_Duplicate,
model.Restrictions_Publish,
}
objRestrictEditAndDuplicate = ObjectRestrictions{
objRestrictEditPublishAndDuplicate = ObjectRestrictions{
model.Restrictions_Blocks,
model.Restrictions_LayoutChange,
model.Restrictions_TypeChange,
model.Restrictions_Template,
model.Restrictions_Duplicate,
model.Restrictions_Publish,
}
objRestrictEdit = ObjectRestrictions{
objRestrictEditAndPublish = ObjectRestrictions{
model.Restrictions_Blocks,
model.Restrictions_LayoutChange,
model.Restrictions_TypeChange,
model.Restrictions_Template,
model.Restrictions_Publish,
}
sysTypesRestrictions = ObjectRestrictions{
model.Restrictions_Blocks,
Expand All @@ -44,6 +47,7 @@ var (
model.Restrictions_Template,
model.Restrictions_Details,
model.Restrictions_Delete,
model.Restrictions_Publish,
}
sysRelationsRestrictions = ObjectRestrictions{
model.Restrictions_Blocks,
Expand All @@ -53,17 +57,18 @@ var (
model.Restrictions_Delete,
model.Restrictions_Relations,
model.Restrictions_Details,
model.Restrictions_Publish,
}

objectRestrictionsByLayout = map[model.ObjectTypeLayout]ObjectRestrictions{
model.ObjectType_basic: {},
model.ObjectType_profile: {},
model.ObjectType_todo: {},
model.ObjectType_set: objRestrictEdit,
model.ObjectType_collection: objRestrictEdit,
model.ObjectType_objectType: objRestrictEdit,
model.ObjectType_relation: objRestrictEdit,
model.ObjectType_file: objRestrictEditAndDuplicate,
model.ObjectType_set: objRestrictEditAndPublish,
model.ObjectType_collection: objRestrictEditAndPublish,
model.ObjectType_objectType: objRestrictEditAndPublish,
model.ObjectType_relation: objRestrictEditAndPublish,
model.ObjectType_file: objRestrictEditPublishAndDuplicate,
model.ObjectType_dashboard: {
model.Restrictions_Details,
model.Restrictions_Relations,
Expand All @@ -80,14 +85,14 @@ var (
},

model.ObjectType_bookmark: {},
model.ObjectType_relationOption: objRestrictEdit,
model.ObjectType_relationOption: objRestrictEditAndPublish,
model.ObjectType_relationOptionsList: {
model.Restrictions_Template,
},
model.ObjectType_participant: objRestrictAll,
model.ObjectType_chat: objRestrictEditAndDuplicate,
model.ObjectType_chatDerived: objRestrictEditAndDuplicate,
model.ObjectType_tag: objRestrictEdit,
model.ObjectType_chat: objRestrictEditPublishAndDuplicate,
model.ObjectType_chatDerived: objRestrictEditPublishAndDuplicate,
model.ObjectType_tag: objRestrictEditAndPublish,
}

objectRestrictionsBySBType = map[smartblock.SmartBlockType]ObjectRestrictions{
Expand All @@ -107,6 +112,7 @@ var (
model.Restrictions_TypeChange,
model.Restrictions_Template,
model.Restrictions_Duplicate,
model.Restrictions_Publish,
},
smartblock.SmartBlockTypeWorkspace: {
model.Restrictions_Blocks,
Expand All @@ -116,18 +122,20 @@ var (
model.Restrictions_TypeChange,
model.Restrictions_Template,
model.Restrictions_Duplicate,
model.Restrictions_Publish,
},
smartblock.SmartBlockTypeFileObject: objRestrictEditAndDuplicate,
smartblock.SmartBlockTypeFileObject: objRestrictEditPublishAndDuplicate,
smartblock.SmartBlockTypeArchive: objRestrictAll,
smartblock.SmartBlockTypeBundledRelation: objRestrictAll,
smartblock.SmartBlockTypeSubObject: objRestrictEdit,
smartblock.SmartBlockTypeObjectType: objRestrictEdit,
smartblock.SmartBlockTypeRelation: objRestrictEdit,
smartblock.SmartBlockTypeSubObject: objRestrictEditAndPublish,
smartblock.SmartBlockTypeObjectType: objRestrictEditAndPublish,
smartblock.SmartBlockTypeRelation: objRestrictEditAndPublish,
smartblock.SmartBlockTypeBundledObjectType: objRestrictAll,
smartblock.SmartBlockTypeBundledTemplate: objRestrictAll,
smartblock.SmartBlockTypeTemplate: {
model.Restrictions_TypeChange,
model.Restrictions_Template,
model.Restrictions_Publish,
},
smartblock.SmartBlockTypeWidget: {
model.Restrictions_Relations,
Expand All @@ -137,15 +145,16 @@ var (
model.Restrictions_TypeChange,
model.Restrictions_Template,
model.Restrictions_Duplicate,
model.Restrictions_Publish,
},
smartblock.SmartBlockTypeMissingObject: objRestrictAll,
smartblock.SmartBlockTypeDate: objRestrictAll,
smartblock.SmartBlockTypeAccountOld: {
model.Restrictions_Template,
},
smartblock.SmartBlockTypeParticipant: objRestrictAll,
smartblock.SmartBlockTypeChatObject: objRestrictEditAndDuplicate,
smartblock.SmartBlockTypeChatDerivedObject: objRestrictEditAndDuplicate,
smartblock.SmartBlockTypeChatObject: objRestrictEditPublishAndDuplicate,
smartblock.SmartBlockTypeChatDerivedObject: objRestrictEditPublishAndDuplicate,
}
)

Expand Down
6 changes: 3 additions & 3 deletions core/block/restriction/object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ func TestService_ObjectRestrictionsById(t *testing.T) {

t.Run("sets and collections should have edit restrictions", func(t *testing.T) {
collection := givenRestrictionHolder(coresb.SmartBlockTypePage, bundle.TypeKeyCollection)
assert.ErrorIs(t, rs.GetRestrictions(collection).Object.Check(objRestrictEdit...), ErrRestricted)
assert.ErrorIs(t, rs.GetRestrictions(collection).Object.Check(objRestrictEditAndPublish...), ErrRestricted)
set := givenRestrictionHolder(coresb.SmartBlockTypePage, bundle.TypeKeySet)
assert.ErrorIs(t, rs.GetRestrictions(set).Object.Check(objRestrictEdit...), ErrRestricted)
assert.ErrorIs(t, rs.GetRestrictions(set).Object.Check(objRestrictEditAndPublish...), ErrRestricted)
})

t.Run("plain pages should not have any restrictions", func(t *testing.T) {
Expand Down Expand Up @@ -95,7 +95,7 @@ func TestService_ObjectRestrictionsById(t *testing.T) {

t.Run("chat should have edit and duplication restrictions", func(t *testing.T) {
assert.ErrorIs(t, rs.GetRestrictions(givenRestrictionHolder(coresb.SmartBlockTypeChatObject, bundle.TypeKeyChat)).Object.Check(
objRestrictEditAndDuplicate...,
objRestrictEditPublishAndDuplicate...,
), ErrRestricted)
})
}
Expand Down
2 changes: 1 addition & 1 deletion core/date/date_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestBuildDetailsFromTimestamp(t *testing.T) {
assert.Zero(t, tt.Hour())
assert.Zero(t, tt.Minute())
assert.Zero(t, tt.Second())
assert.Len(t, details.GetInt64List(bundle.RelationKeyRestrictions), 8)
assert.Len(t, details.GetInt64List(bundle.RelationKeyRestrictions), 9)
})
}
}
Loading

0 comments on commit 63d784a

Please sign in to comment.