mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 14:50:55 +03:00
notifier plugin: add support for login succeeded events
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -331,18 +331,28 @@ func (m *Manager) NotifyLogEvent(event notifier.LogEventType, protocol, username
|
||||
m.notifLock.RLock()
|
||||
defer m.notifLock.RUnlock()
|
||||
|
||||
e := ¬ifier.LogEvent{
|
||||
Timestamp: time.Now().UnixNano(),
|
||||
Event: event,
|
||||
Protocol: protocol,
|
||||
Username: username,
|
||||
IP: ip,
|
||||
Message: err.Error(),
|
||||
Role: role,
|
||||
}
|
||||
var e *notifier.LogEvent
|
||||
|
||||
for _, n := range m.notifiers {
|
||||
n.notifyLogEvent(e)
|
||||
if util.Contains(n.config.NotifierOptions.LogEvents, int(event)) {
|
||||
if e == nil {
|
||||
message := ""
|
||||
if err != nil {
|
||||
message = err.Error()
|
||||
}
|
||||
|
||||
e = ¬ifier.LogEvent{
|
||||
Timestamp: time.Now().UnixNano(),
|
||||
Event: event,
|
||||
Protocol: protocol,
|
||||
Username: username,
|
||||
IP: ip,
|
||||
Message: message,
|
||||
Role: role,
|
||||
}
|
||||
}
|
||||
n.notifyLogEvent(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user