1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-10 01:51:07 +09:00

GO-966 add event: objectRestrictionsSet

used to inform client when the restrictions of object has been changed
This commit is contained in:
Roman Khafizianov 2023-04-25 18:17:59 +02:00 committed by Mikhail Iudin
parent b783b6104d
commit 4c4644d5a3
No known key found for this signature in database
GPG key ID: FAAAA8BAABDFF1C0
4 changed files with 568 additions and 349 deletions

View file

@ -180,7 +180,6 @@ type smartBlock struct {
lastDepDetails map[string]*pb.EventObjectDetailsSet
restrictionsUpdater func()
restrictions restriction.Restrictions
restrictionsChanged bool
objectStore objectstore.ObjectStore
relationService relation2.Service
isDeleted bool
@ -330,7 +329,7 @@ func (sb *smartBlock) SetRestrictions(r restriction.Restrictions) {
return
}
sb.restrictions = r
sb.restrictionsChanged = true
sb.SendEvent([]*pb.EventMessage{{Value: &pb.EventMessageValueOfObjectRestrictionsSet{ObjectRestrictionsSet: &pb.EventObjectRestrictionsSet{Id: sb.Id(), Restrictions: r.Proto()}}}})
}
func (sb *smartBlock) SetIsDeleted() {
@ -636,7 +635,7 @@ func (sb *smartBlock) Apply(s *state.State, flags ...ApplyFlag) (err error) {
}
}
if checkRestrictions {
if err = s.CheckRestrictions(); err != nil {
if err = s.ParentState().CheckRestrictions(); err != nil {
return
}
}

View file

@ -1242,7 +1242,8 @@
- [Event.Object.Relations.Amend](#anytype.Event.Object.Relations.Amend)
- [Event.Object.Relations.Remove](#anytype.Event.Object.Relations.Remove)
- [Event.Object.Remove](#anytype.Event.Object.Remove)
- [Event.Object.Restriction](#anytype.Event.Object.Restriction)
- [Event.Object.Restrictions](#anytype.Event.Object.Restrictions)
- [Event.Object.Restrictions.Set](#anytype.Event.Object.Restrictions.Set)
- [Event.Object.Subscription](#anytype.Event.Object.Subscription)
- [Event.Object.Subscription.Add](#anytype.Event.Object.Subscription.Add)
- [Event.Object.Subscription.Counters](#anytype.Event.Object.Subscription.Counters)
@ -19367,6 +19368,7 @@ Precondition: user A opened a block
| objectRelationsAmend | [Event.Object.Relations.Amend](#anytype.Event.Object.Relations.Amend) | | |
| objectRelationsRemove | [Event.Object.Relations.Remove](#anytype.Event.Object.Relations.Remove) | | |
| objectRemove | [Event.Object.Remove](#anytype.Event.Object.Remove) | | |
| objectRestrictionsSet | [Event.Object.Restrictions.Set](#anytype.Event.Object.Restrictions.Set) | | |
| subscriptionAdd | [Event.Object.Subscription.Add](#anytype.Event.Object.Subscription.Add) | | |
| subscriptionRemove | [Event.Object.Subscription.Remove](#anytype.Event.Object.Subscription.Remove) | | |
| subscriptionPosition | [Event.Object.Subscription.Position](#anytype.Event.Object.Subscription.Position) | | |
@ -19563,9 +19565,19 @@ Unset existing detail keys
<a name="anytype.Event.Object.Restriction"></a>
<a name="anytype.Event.Object.Restrictions"></a>
### Event.Object.Restriction
### Event.Object.Restrictions
<a name="anytype.Event.Object.Restrictions.Set"></a>
### Event.Object.Restrictions.Set

File diff suppressed because it is too large Load diff

View file

@ -29,6 +29,8 @@ message Event {
Object.Remove objectRemove = 54;
Object.Restrictions.Set objectRestrictionsSet = 55;
Object.Subscription.Add subscriptionAdd = 60;
Object.Subscription.Remove subscriptionRemove = 61;
Object.Subscription.Position subscriptionPosition = 62;
@ -205,9 +207,11 @@ message Event {
repeated string ids = 1;
}
message Restriction {
string id = 1;
anytype.model.Restrictions restrictions = 2;
message Restrictions {
message Set {
string id = 1;
anytype.model.Restrictions restrictions = 2;
}
}
}
message Block {