share accepted/declined events

Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
jkoberg
2022-03-12 14:19:41 +01:00
parent 2fa08495f7
commit f01263859b
4 changed files with 71 additions and 10 deletions
+18
View File
@@ -10,6 +10,9 @@ const (
ActionSharePasswordUpdated = "share_password_updated"
ActionShareExpirationUpdated = "share_expiration_updated"
ActionShareRemoved = "file_unshared"
ActionShareAccepted = "share_accepted"
ActionShareDeclined = "share_declined"
ActionLinkAccessed = "public_link_accessed"
)
// MessageShareCreated returns the human readable string that describes the action
@@ -41,3 +44,18 @@ func MessageShareRemoved(sharer, shareid, itemid string) string {
func MessageLinkRemoved(shareid string) string {
return fmt.Sprintf("public link id:'%s' was removed", shareid)
}
// MessageShareAccepted returns the human readable string that describes the action
func MessageShareAccepted(userid, shareid, sharerid string) string {
return fmt.Sprintf("user '%s' accepted share '%s' from user '%s'", userid, shareid, sharerid)
}
// MessageShareDeclined returns the human readable string that describes the action
func MessageShareDeclined(userid, shareid, sharerid string) string {
return fmt.Sprintf("user '%s' declined share '%s' from user '%s'", userid, shareid, sharerid)
}
// MessageLinkAccessed returns the human readable string that describes the action
func MessageLinkAccessed(linkid string, success bool) string {
return fmt.Sprintf("link '%s' was accessed. Success: %b", linkid, success)
}
+23 -1
View File
@@ -168,7 +168,29 @@ func LinkRemoved(ev events.LinkRemoved) AuditEventShareRemoved {
// ReceivedShareUpdated converts a ReceivedShareUpdated event to an AuditEventReceivedShareUpdated
func ReceivedShareUpdated(ev events.ReceivedShareUpdated) AuditEventReceivedShareUpdated {
return AuditEventReceivedShareUpdated{}
uid := ev.Sharer.GetOpaqueId()
sid := ev.ShareID.GetOpaqueId()
with, typ := extractGrantee(ev.GranteeUserID, ev.GranteeGroupID)
itemID := ev.ItemID.GetOpaqueId()
msg, utype := "", ""
switch ev.State {
case "SHARE_STATE_ACCEPTED":
msg = MessageShareAccepted(with, sid, uid)
utype = ActionShareAccepted
case "SHARE_STATE_DECLINED":
msg = MessageShareDeclined(with, sid, uid)
utype = ActionShareDeclined
}
base := BasicAuditEvent(with, formatTime(ev.MTime), msg, utype)
return AuditEventReceivedShareUpdated{
AuditEventSharing: SharingAuditEvent(sid, itemID, uid, base),
ShareType: typ,
ShareWith: with,
// NOTE: those values are not in the event and can therefore not be filled at the moment
ItemType: "",
}
}
// LinkAccessed converts a LinkAccessed event to an AuditEventLinkAccessed
-4
View File
@@ -67,10 +67,6 @@ type AuditEventReceivedShareUpdated struct {
ItemType string // file or folder
ShareType string // group user or link
ShareWith string // The UID or GID of the share recipient.
Path string // The path of the shared item.
Owner string // The UID of the owner of the shared item.
FileID string // The file identifier for the item shared.
ShareID string // The sharing identifier. (not available for public_link_accessed)
}
// AuditEventLinkAccessed is the event logged when a link is accessed