(dblog database.GetConnectionLogsOffsetRow)
| 99 | } |
| 100 | |
| 101 | func convertConnectionLog(dblog database.GetConnectionLogsOffsetRow) codersdk.ConnectionLog { |
| 102 | var ip *netip.Addr |
| 103 | if dblog.ConnectionLog.Ip.Valid { |
| 104 | parsedIP, ok := netip.AddrFromSlice(dblog.ConnectionLog.Ip.IPNet.IP) |
| 105 | if ok { |
| 106 | ip = &parsedIP |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | var user *codersdk.User |
| 111 | if dblog.ConnectionLog.UserID.Valid { |
| 112 | sdkUser := db2sdk.User(database.User{ |
| 113 | ID: dblog.ConnectionLog.UserID.UUID, |
| 114 | Email: dblog.UserEmail.String, |
| 115 | Username: dblog.UserUsername.String, |
| 116 | CreatedAt: dblog.UserCreatedAt.Time, |
| 117 | UpdatedAt: dblog.UserUpdatedAt.Time, |
| 118 | Status: dblog.UserStatus.UserStatus, |
| 119 | RBACRoles: dblog.UserRoles, |
| 120 | LoginType: dblog.UserLoginType.LoginType, |
| 121 | AvatarURL: dblog.UserAvatarUrl.String, |
| 122 | Deleted: dblog.UserDeleted.Bool, |
| 123 | LastSeenAt: dblog.UserLastSeenAt.Time, |
| 124 | QuietHoursSchedule: dblog.UserQuietHoursSchedule.String, |
| 125 | Name: dblog.UserName.String, |
| 126 | }, []uuid.UUID{}) |
| 127 | user = &sdkUser |
| 128 | } |
| 129 | |
| 130 | var ( |
| 131 | webInfo *codersdk.ConnectionLogWebInfo |
| 132 | sshInfo *codersdk.ConnectionLogSSHInfo |
| 133 | ) |
| 134 | |
| 135 | switch dblog.ConnectionLog.Type { |
| 136 | case database.ConnectionTypeWorkspaceApp, |
| 137 | database.ConnectionTypePortForwarding: |
| 138 | webInfo = &codersdk.ConnectionLogWebInfo{ |
| 139 | UserAgent: dblog.ConnectionLog.UserAgent.String, |
| 140 | User: user, |
| 141 | SlugOrPort: dblog.ConnectionLog.SlugOrPort.String, |
| 142 | StatusCode: dblog.ConnectionLog.Code.Int32, |
| 143 | } |
| 144 | case database.ConnectionTypeSsh, |
| 145 | database.ConnectionTypeReconnectingPty, |
| 146 | database.ConnectionTypeJetbrains, |
| 147 | database.ConnectionTypeVscode: |
| 148 | sshInfo = &codersdk.ConnectionLogSSHInfo{ |
| 149 | ConnectionID: dblog.ConnectionLog.ConnectionID.UUID, |
| 150 | DisconnectReason: dblog.ConnectionLog.DisconnectReason.String, |
| 151 | } |
| 152 | if dblog.ConnectionLog.DisconnectTime.Valid { |
| 153 | sshInfo.DisconnectTime = &dblog.ConnectionLog.DisconnectTime.Time |
| 154 | } |
| 155 | if dblog.ConnectionLog.Code.Valid { |
| 156 | sshInfo.ExitCode = &dblog.ConnectionLog.Code.Int32 |
| 157 | } |
| 158 | } |
no test coverage detected