Merge pull request #10104 from 2403905/issue-10011

Added the ShareUpdate activity in the space context.
This commit is contained in:
Roman Perekhod
2024-09-23 11:19:10 +02:00
committed by GitHub
13 changed files with 93 additions and 43 deletions

View File

@@ -78,12 +78,6 @@ func ShareRemoved(r *collaboration.RemoveShareResponse, req *collaboration.Remov
// ShareUpdated converts the response to an event
func ShareUpdated(r *collaboration.UpdateShareResponse, req *collaboration.UpdateShareRequest, executant *user.UserId) events.ShareUpdated {
updated := ""
if req.Field.GetPermissions() != nil {
updated = "permissions"
} else if req.Field.GetDisplayName() != "" {
updated = "displayname"
}
return events.ShareUpdated{
Executant: executant,
ShareID: r.Share.Id,
@@ -93,7 +87,7 @@ func ShareUpdated(r *collaboration.UpdateShareResponse, req *collaboration.Updat
GranteeGroupID: r.Share.GetGrantee().GetGroupId(),
Sharer: r.Share.Creator,
MTime: r.Share.Mtime,
Updated: updated,
UpdateMask: req.GetUpdateMask().GetPaths(),
}
}
@@ -139,7 +133,7 @@ func LinkUpdated(r *link.UpdatePublicShareResponse, req *link.UpdatePublicShareR
DisplayName: r.Share.DisplayName,
Expiration: r.Share.Expiration,
PasswordProtected: r.Share.PasswordProtected,
CTime: r.Share.Ctime,
MTime: r.Share.Mtime,
Token: r.Share.Token,
FieldUpdated: link.UpdatePublicShareRequest_Update_Type_name[int32(req.Update.GetType())],
}

View File

@@ -84,8 +84,9 @@ type ShareUpdated struct {
Sharer *user.UserId
MTime *types.Timestamp
// indicates what was updated - one of "displayname", "permissions"
Updated string
Updated string // Deprecated
// indicates what was updated
UpdateMask []string
}
// Unmarshal to fulfill umarshaller interface
@@ -165,7 +166,7 @@ type LinkUpdated struct {
DisplayName string
Expiration *types.Timestamp
PasswordProtected bool
CTime *types.Timestamp
MTime *types.Timestamp
Token string
FieldUpdated string

View File

@@ -146,6 +146,9 @@ func TSToUnixNano(ts *types.Timestamp) uint64 {
// TSToTime converts a protobuf Timestamp to Go's time.Time.
func TSToTime(ts *types.Timestamp) time.Time {
if ts == nil {
return time.Time{}
}
return time.Unix(int64(ts.Seconds), int64(ts.Nanos))
}