diff --git a/model/chat.go b/model/chat.go
index 05bc35721..16e099d72 100644
--- a/model/chat.go
+++ b/model/chat.go
@@ -68,7 +68,7 @@ type Chat struct {
}
// getColors returns all colors chat names are mapped to
-func (c Chat) getColors() []string {
+func getColors() []string {
return []string{"#368bd6", "#ac3ba8", "#0dbd8b", "#e64f7a", "#ff812d", "#2dc2c5", "#5c56f5", "#74d12c"}
}
@@ -103,7 +103,7 @@ func (c *Chat) BeforeCreate(tx *gorm.DB) (err error) {
}
// set chat color:
- colors := c.getColors()
+ colors := getColors()
userIdInt, err := strconv.Atoi(c.UserID)
if err != nil {
c.Color = colors[0]
@@ -135,6 +135,12 @@ func (c *Chat) AfterFind(_ *gorm.DB) (err error) {
return nil
}
+// getUrlHtml returns the html for urls, the tag includes target="_blank" and rel="nofollow noopener"
+func getUrlHtml(url string) string {
+ h := blackfriday.Run([]byte(url))
+ return strings.TrimSuffix(string(chatHTMLPolicy.SanitizeBytes(h)), "\n")
+}
+
// SanitiseMessage sets chat.SanitizedMessage to the sanitized html version of chat.Message, including tags for links
func (c *Chat) SanitiseMessage() {
msg := html.EscapeString(c.Message)
@@ -142,7 +148,7 @@ func (c *Chat) SanitiseMessage() {
newMsg := ""
for _, urlIndex := range urls {
newMsg += msg[:urlIndex[0]]
- newMsg += c.getUrlHtml(msg[urlIndex[0]:urlIndex[1]])
+ newMsg += getUrlHtml(msg[urlIndex[0]:urlIndex[1]])
}
if len(urls) > 0 {
newMsg += msg[urls[len(urls)-1][1]:]
@@ -151,9 +157,3 @@ func (c *Chat) SanitiseMessage() {
}
c.SanitizedMessage = newMsg
}
-
-// getUrlHtml returns the html for urls, the tag includes target="_blank" and rel="nofollow noopener"
-func (c Chat) getUrlHtml(url string) string {
- h := blackfriday.Run([]byte(url))
- return strings.TrimSuffix(string(chatHTMLPolicy.SanitizeBytes(h)), "\n")
-}
diff --git a/model/course.go b/model/course.go
index 5514d390e..0bda2b39e 100755
--- a/model/course.go
+++ b/model/course.go
@@ -72,12 +72,12 @@ func (c *Course) ToDTO() CourseDTO {
}
// GetUrl returns the URL of the course, e.g. /course/2022/S/MyCourse
-func (c Course) GetUrl() string {
+func (c *Course) GetUrl() string {
return fmt.Sprintf("/course/%d/%s/%s", c.Year, c.TeachingTerm, c.Slug)
}
// GetStreamUrl returns the URL of the stream, e.g. /w/MyStream/42
-func (c Course) GetStreamUrl(stream Stream) string {
+func (c *Course) GetStreamUrl(stream Stream) string {
return fmt.Sprintf("/w/%s/%d", c.Slug, stream.ID)
}
@@ -87,7 +87,7 @@ type CameraPresetPreference struct {
}
// GetCameraPresetPreference retrieves the camera preset preferences
-func (c Course) GetCameraPresetPreference() []CameraPresetPreference {
+func (c *Course) GetCameraPresetPreference() []CameraPresetPreference {
var res []CameraPresetPreference
err := json.Unmarshal([]byte(c.CameraPresetPreferences), &res)
if err != nil {
@@ -111,7 +111,7 @@ type SourcePreference struct {
}
// GetSourcePreference retrieves the source preferences
-func (c Course) GetSourcePreference() []SourcePreference {
+func (c *Course) GetSourcePreference() []SourcePreference {
var res []SourcePreference
err := json.Unmarshal([]byte(c.SourcePreferences), &res)
if err != nil {
@@ -121,7 +121,7 @@ func (c Course) GetSourcePreference() []SourcePreference {
}
// GetSourceModeForLectureHall retrieves the source preference for the given lecture hall, returns default SourcePreference if non-existing
-func (c Course) GetSourceModeForLectureHall(id uint) SourceMode {
+func (c *Course) GetSourceModeForLectureHall(id uint) SourceMode {
for _, preference := range c.GetSourcePreference() {
if preference.LectureHallID == id {
return preference.SourceMode
@@ -131,7 +131,7 @@ func (c Course) GetSourceModeForLectureHall(id uint) SourceMode {
}
// CanUseSource returns whether the specified source type is allowed for the lecture hall id given
-func (c Course) CanUseSource(lectureHallID uint, sourceType string) bool {
+func (c *Course) CanUseSource(lectureHallID uint, sourceType string) bool {
mode := c.GetSourceModeForLectureHall(lectureHallID)
switch sourceType {
case "PRES":
@@ -155,7 +155,7 @@ func (c *Course) SetSourcePreference(pref []SourcePreference) {
}
// CompareTo used for sorting. Falling back to old java habits...
-func (c Course) CompareTo(other Course) bool {
+func (c *Course) CompareTo(other Course) bool {
if !other.HasNextLecture() {
return true
}
@@ -163,7 +163,7 @@ func (c Course) CompareTo(other Course) bool {
}
// IsLive returns whether the course has a lecture that is live
-func (c Course) IsLive() bool {
+func (c *Course) IsLive() bool {
for _, s := range c.Streams {
if s.LiveNow {
return true
@@ -173,7 +173,7 @@ func (c Course) IsLive() bool {
}
// IsNextLectureStartingSoon checks whether the course has a lecture that starts soon
-func (c Course) IsNextLectureStartingSoon() bool {
+func (c *Course) IsNextLectureStartingSoon() bool {
for _, s := range c.Streams {
if s.IsComingUp() {
return true
@@ -183,7 +183,7 @@ func (c Course) IsNextLectureStartingSoon() bool {
}
// NumStreams returns the number of streams for the course that are VoDs or live
-func (c Course) NumStreams() int {
+func (c *Course) NumStreams() int {
res := 0
for i := range c.Streams {
if c.Streams[i].Recording || c.Streams[i].LiveNow {
@@ -193,7 +193,7 @@ func (c Course) NumStreams() int {
return res
}
-func (c Course) StreamTimes() []string {
+func (c *Course) StreamTimes() []string {
streamTimes := make([]string, len(c.Streams))
for i, s := range c.Streams {
@@ -204,7 +204,7 @@ func (c Course) StreamTimes() []string {
}
// HasRecordings returns whether the course has any recordings.
-func (c Course) HasRecordings() bool {
+func (c *Course) HasRecordings() bool {
for i := range c.Streams {
if c.Streams[i].Recording {
return true
@@ -214,17 +214,17 @@ func (c Course) HasRecordings() bool {
}
// NumUsers returns the number of users enrolled in the course
-func (c Course) NumUsers() int {
+func (c *Course) NumUsers() int {
return len(c.Users)
}
// NextLectureHasReachedTimeSlot returns whether the courses next lecture arrived at its timeslot
-func (c Course) NextLectureHasReachedTimeSlot() bool {
+func (c *Course) NextLectureHasReachedTimeSlot() bool {
return c.GetNextLecture().TimeSlotReached()
}
// GetNextLecture returns the next lecture of the course
-func (c Course) GetNextLecture() Stream {
+func (c *Course) GetNextLecture() *Stream {
var earliestLecture Stream
earliestLectureDate := time.Now().Add(time.Hour * 24 * 365 * 10) // 10 years from now.
for _, s := range c.Streams {
@@ -233,27 +233,27 @@ func (c Course) GetNextLecture() Stream {
earliestLecture = s
}
}
- return earliestLecture
+ return &earliestLecture
}
// GetLastRecording returns the most recent lecture of the course
// Assumes an ascending order of c.Streams
-func (c Course) GetLastRecording() Stream {
+func (c *Course) GetLastRecording() *Stream {
var lastLecture Stream
now := time.Now()
for _, s := range c.Streams {
if s.Start.After(now) {
- return lastLecture
+ return &lastLecture
}
if s.Recording {
lastLecture = s
}
}
- return lastLecture
+ return &lastLecture
}
// GetLiveStreams returns the current live streams of the course or an empty slice if none are live
-func (c Course) GetLiveStreams() []Stream {
+func (c *Course) GetLiveStreams() []Stream {
var res []Stream
for _, s := range c.Streams {
if s.LiveNow {
@@ -264,7 +264,7 @@ func (c Course) GetLiveStreams() []Stream {
}
// GetNextLectureDate returns the next lecture date of the course
-func (c Course) GetNextLectureDate() time.Time {
+func (c *Course) GetNextLectureDate() time.Time {
// TODO: Refactor this with IsNextLectureSelfStream when the sorting error fixed
earliestLectureDate := time.Now().Add(time.Hour * 24 * 365 * 10) // 10 years from now.
for _, s := range c.Streams {
@@ -276,17 +276,17 @@ func (c Course) GetNextLectureDate() time.Time {
}
// IsNextLectureSelfStream checks whether the next lecture is a self stream
-func (c Course) IsNextLectureSelfStream() bool {
+func (c *Course) IsNextLectureSelfStream() bool {
return c.GetNextLecture().IsSelfStream()
}
// GetNextLectureDateFormatted returns a JavaScript friendly formatted date string
-func (c Course) GetNextLectureDateFormatted() string {
+func (c *Course) GetNextLectureDateFormatted() string {
return c.GetNextLectureDate().Format("2006-01-02 15:04:05")
}
// HasNextLecture checks whether there is another upcoming lecture
-func (c Course) HasNextLecture() bool {
+func (c *Course) HasNextLecture() bool {
n := time.Now()
for _, s := range c.Streams {
if s.Start.After(n) {
@@ -297,12 +297,12 @@ func (c Course) HasNextLecture() bool {
}
// HasStreams checks whether the lecture has any streams (recorded, live or upcoming) associated to it
-func (c Course) HasStreams() bool {
+func (c *Course) HasStreams() bool {
return len(c.Streams) > 0
}
// GetRecordings returns all recording of this course as streams
-func (c Course) GetRecordings() []Stream {
+func (c *Course) GetRecordings() []Stream {
var recordings []Stream
for _, s := range c.Streams {
if s.Recording {
@@ -313,22 +313,22 @@ func (c Course) GetRecordings() []Stream {
}
// IsHidden returns true if visibility is set to 'hidden' and false if not
-func (c Course) IsHidden() bool {
+func (c *Course) IsHidden() bool {
return c.Visibility == "hidden"
}
// IsLoggedIn returns true if visibility is set to 'loggedin' and false if not
-func (c Course) IsLoggedIn() bool {
+func (c *Course) IsLoggedIn() bool {
return c.Visibility == "loggedin"
}
// IsEnrolled returns true if visibility is set to 'enrolled' and false if not
-func (c Course) IsEnrolled() bool {
+func (c *Course) IsEnrolled() bool {
return c.Visibility == "enrolled"
}
// AdminJson is the JSON representation of a courses streams for the admin panel
-func (c Course) AdminJson(lhs []LectureHall) []gin.H {
+func (c *Course) AdminJson(lhs []LectureHall) []gin.H {
var res []gin.H
for _, s := range c.Streams {
res = append(res, s.getJson(lhs, c))
diff --git a/model/file.go b/model/file.go
index 824b3300c..679940050 100644
--- a/model/file.go
+++ b/model/file.go
@@ -33,7 +33,7 @@ type File struct {
Type FileType `gorm:"not null; default: 1"`
}
-func (f File) GetDownloadFileName() string {
+func (f *File) GetDownloadFileName() string {
pts := strings.Split(f.Path, "/")
if len(pts) == 0 {
return ""
@@ -41,7 +41,7 @@ func (f File) GetDownloadFileName() string {
return pts[len(pts)-1]
}
-func (f File) GetFriendlyFileName() string {
+func (f *File) GetFriendlyFileName() string {
fn := f.GetDownloadFileName()
if strings.Contains(strings.ToLower(fn), "cam") {
return "Camera-view"
@@ -57,7 +57,7 @@ func (f File) GetFriendlyFileName() string {
}
// GetVodTypeByName infers the type of a video file based on its name.
-func (f File) GetVodTypeByName() string {
+func (f *File) GetVodTypeByName() string {
if strings.HasSuffix(f.Path, "CAM.mp4") {
return "CAM"
}
@@ -67,11 +67,11 @@ func (f File) GetVodTypeByName() string {
return "COMB"
}
-func (f File) IsThumb() bool {
+func (f *File) IsThumb() bool {
return f.Type == FILETYPE_THUMB_CAM || f.Type == FILETYPE_THUMB_PRES || f.Type == FILETYPE_THUMB_COMB
}
-func (f File) IsURL() bool {
+func (f *File) IsURL() bool {
parsedUrl, err := url.Parse(f.Path)
if err != nil {
return false
diff --git a/model/info-page.go b/model/info-page.go
index b5fe0d046..182ec0892 100644
--- a/model/info-page.go
+++ b/model/info-page.go
@@ -22,7 +22,7 @@ type InfoPage struct {
Type InfoPageType `gorm:"not null; default: 1"`
}
-func (mt InfoPage) Render() template.HTML {
+func (mt *InfoPage) Render() template.HTML {
var renderedContent template.HTML = ""
switch mt.Type {
case INFOPAGE_MARKDOWN:
diff --git a/model/lecture_hall.go b/model/lecture_hall.go
index 383029058..02ff5b323 100644
--- a/model/lecture_hall.go
+++ b/model/lecture_hall.go
@@ -27,7 +27,7 @@ const (
Panasonic
)
-func (l LectureHall) NumSources() int {
+func (l *LectureHall) NumSources() int {
num := 0
if l.CombIP != "" {
num++
diff --git a/model/notification.go b/model/notification.go
index 2fe9f6e31..9470ca62b 100644
--- a/model/notification.go
+++ b/model/notification.go
@@ -43,6 +43,6 @@ func (n *Notification) AfterFind(_ *gorm.DB) error {
return nil
}
-func (n Notification) GetBodyForGoTemplate() template.HTML {
+func (n *Notification) GetBodyForGoTemplate() template.HTML {
return template.HTML(n.SanitizedBody)
}
diff --git a/model/poll.go b/model/poll.go
index 83f2844d1..1baa53071 100644
--- a/model/poll.go
+++ b/model/poll.go
@@ -23,7 +23,7 @@ type PollOption struct {
Votes []User `gorm:"many2many:poll_option_user_votes" json:"-"`
}
-func (o PollOption) GetStatsMap(votes int64) gin.H {
+func (o *PollOption) GetStatsMap(votes int64) gin.H {
return gin.H{
"ID": o.ID,
"answer": o.Answer,
diff --git a/model/server-notification.go b/model/server-notification.go
index 074d0ed6c..bcde37299 100644
--- a/model/server-notification.go
+++ b/model/server-notification.go
@@ -18,21 +18,21 @@ type ServerNotification struct {
Expires time.Time `gorm:"not null"`
}
-func (s ServerNotification) BeforeCreate(tx *gorm.DB) (err error) {
+func (s *ServerNotification) BeforeCreate(tx *gorm.DB) (err error) {
if s.Expires.Before(s.Start) {
err = errors.New("can't save notification where expires is before start")
}
return
}
-func (s ServerNotification) FormatFrom() string {
+func (s *ServerNotification) FormatFrom() string {
return s.Start.Format("2006-01-02 15:04")
}
-func (s ServerNotification) FormatExpires() string {
+func (s *ServerNotification) FormatExpires() string {
return s.Expires.Format("2006-01-02 15:04")
}
-func (s ServerNotification) HTML() template.HTML {
+func (s *ServerNotification) HTML() template.HTML {
return template.HTML(s.Text)
}
diff --git a/model/stream-unit.go b/model/stream-unit.go
index ded7391ac..bef98aee0 100644
--- a/model/stream-unit.go
+++ b/model/stream-unit.go
@@ -19,11 +19,11 @@ type StreamUnit struct {
StreamID uint `gorm:"not null"`
}
-func (s StreamUnit) GetUnitDurationMS() uint {
+func (s *StreamUnit) GetUnitDurationMS() uint {
return s.UnitEnd - s.UnitStart
}
-func (s StreamUnit) GetRoundedUnitLen() string {
+func (s *StreamUnit) GetRoundedUnitLen() string {
lenS := (s.UnitEnd - s.UnitStart) / 1000
lenM := lenS / 60
lenH := lenM / 60
@@ -35,7 +35,7 @@ func (s StreamUnit) GetRoundedUnitLen() string {
return fmt.Sprintf("%2dmin, %2dsec", lenM, lenS)
}
-func (s StreamUnit) GetDescriptionHTML() template.HTML {
+func (s *StreamUnit) GetDescriptionHTML() template.HTML {
unsafe := blackfriday.Run([]byte(s.UnitDescription))
html := bluemonday.
UGCPolicy().
diff --git a/model/stream.go b/model/stream.go
index fc3572c71..1f771e5af 100755
--- a/model/stream.go
+++ b/model/stream.go
@@ -64,7 +64,7 @@ type DownloadableVod struct {
}
// GetVodFiles returns all downloadable files that user can see when using the download dropdown for a stream.
-func (s Stream) GetVodFiles() []DownloadableVod {
+func (s *Stream) GetVodFiles() []DownloadableVod {
dFiles := make([]DownloadableVod, 0)
if s.PlaylistUrl != "" {
@@ -88,7 +88,7 @@ func (s Stream) GetVodFiles() []DownloadableVod {
return dFiles
}
-func (s Stream) GetLGThumbnail() (string, error) {
+func (s *Stream) GetLGThumbnail() (string, error) {
thumbs := map[string]string{}
for _, file := range s.Files {
if file.Type == FILETYPE_THUMB_LG_CAM_PRES {
@@ -119,7 +119,7 @@ func (s Stream) GetLGThumbnail() (string, error) {
return "", fmt.Errorf("no large thumbnail found")
}
-func (s Stream) GetLGThumbnailForVideoType(videoType VideoType) (string, error) {
+func (s *Stream) GetLGThumbnailForVideoType(videoType VideoType) (string, error) {
mapping := map[VideoType]FileType{
VideoTypePresentation: FILETYPE_THUMB_LG_PRES,
VideoTypeCamera: FILETYPE_THUMB_LG_CAM,
@@ -138,7 +138,7 @@ func (s Stream) GetLGThumbnailForVideoType(videoType VideoType) (string, error)
}
// GetThumbIdForSource returns the id of file that stores the thumbnail sprite for a specific source type.
-func (s Stream) GetThumbIdForSource(source string) uint {
+func (s *Stream) GetThumbIdForSource(source string) uint {
var fileType FileType
switch source {
case "CAM":
@@ -158,67 +158,67 @@ func (s Stream) GetThumbIdForSource(source string) uint {
}
// GetStartInSeconds returns the number of seconds until the stream starts (or 0 if it has already started or is a vod)
-func (s Stream) GetStartInSeconds() int {
+func (s *Stream) GetStartInSeconds() int {
if s.LiveNow || s.Recording {
return 0
}
return int(time.Until(s.Start).Seconds())
}
-func (s Stream) GetName() string {
+func (s *Stream) GetName() string {
if s.Name != "" {
return s.Name
}
return fmt.Sprintf("Lecture: %s", s.Start.Format("Jan 2, 2006"))
}
-func (s Stream) IsConverting() bool {
+func (s *Stream) IsConverting() bool {
return len(s.TranscodingProgresses) > 0
}
// IsDownloadable returns true if the stream is a recording and has at least one stream associated with it.
-func (s Stream) IsDownloadable() bool {
+func (s *Stream) IsDownloadable() bool {
return s.Recording && (s.PlaylistUrl != "" || s.PlaylistUrlPRES != "" || s.PlaylistUrlCAM != "")
}
// IsSelfStream returns whether the stream is a scheduled stream in a lecture hall
-func (s Stream) IsSelfStream() bool {
+func (s *Stream) IsSelfStream() bool {
return s.LectureHallID == 0
}
// IsPast returns whether the stream end time was reached
-func (s Stream) IsPast() bool {
+func (s *Stream) IsPast() bool {
return s.End.Before(time.Now()) || s.Ended
}
// IsComingUp returns whether the stream begins in 30 minutes
-func (s Stream) IsComingUp() bool {
+func (s *Stream) IsComingUp() bool {
eligibleForWait := s.Start.Before(time.Now().Add(30*time.Minute)) && time.Now().Before(s.End)
return !s.IsPast() && !s.Recording && !s.LiveNow && eligibleForWait
}
// TimeSlotReached returns whether stream has passed the starting time
-func (s Stream) TimeSlotReached() bool {
+func (s *Stream) TimeSlotReached() bool {
// Used to stop displaying the timer when there is less than 1 minute left
return time.Now().After(s.Start.Add(-time.Minute)) && time.Now().Before(s.End)
}
// IsStartingInOneDay returns whether the stream starts within 1 day
-func (s Stream) IsStartingInOneDay() bool {
+func (s *Stream) IsStartingInOneDay() bool {
return s.Start.After(time.Now().Add(24 * time.Hour))
}
// IsStartingInMoreThanOneDay returns whether the stream starts in at least 2 days
-func (s Stream) IsStartingInMoreThanOneDay() bool {
+func (s *Stream) IsStartingInMoreThanOneDay() bool {
return s.Start.After(time.Now().Add(48 * time.Hour))
}
// IsPlanned returns whether the stream is planned or not
-func (s Stream) IsPlanned() bool {
+func (s *Stream) IsPlanned() bool {
return !s.Recording && !s.LiveNow && !s.IsPast() && !s.IsComingUp()
}
-func (s Stream) HLSUrl() string {
+func (s *Stream) HLSUrl() string {
hls := s.PlaylistUrl
if s.StartOffset > 0 {
hls = fmt.Sprintf("%s?wowzaplaystart=%d&wowzaplayduration=%d", s.PlaylistUrl, s.StartOffset, s.EndOffset)
@@ -232,7 +232,7 @@ type silence struct {
End uint `json:"end"`
}
-func (s Stream) GetSilencesJson() string {
+func (s *Stream) GetSilencesJson() string {
forServe := make([]silence, len(s.Silences))
for i := range forServe {
forServe[i] = silence{
@@ -246,7 +246,7 @@ func (s Stream) GetSilencesJson() string {
return "[]"
}
-func (s Stream) GetDescriptionHTML() string {
+func (s *Stream) GetDescriptionHTML() string {
unsafe := blackfriday.Run([]byte(s.Description))
html := bluemonday.
UGCPolicy().
@@ -255,11 +255,11 @@ func (s Stream) GetDescriptionHTML() string {
return string(html)
}
-func (s Stream) FriendlyDate() string {
+func (s *Stream) FriendlyDate() string {
return s.Start.Format("Mon 02.01.2006")
}
-func (s Stream) FriendlyTime() string {
+func (s *Stream) FriendlyTime() string {
return s.Start.Format("02.01.2006 15:04") + " - " + s.End.Format("15:04")
}
@@ -272,16 +272,16 @@ func ParsableTimeFormat(time time.Time) string {
}
// ParsableStartTime returns a JavaScript friendly formatted date string
-func (s Stream) ParsableStartTime() string {
+func (s *Stream) ParsableStartTime() string {
return ParsableTimeFormat(s.Start)
}
// ParsableLiveNowTimestamp returns a JavaScript friendly formatted date string
-func (s Stream) ParsableLiveNowTimestamp() string {
+func (s *Stream) ParsableLiveNowTimestamp() string {
return ParsableTimeFormat(s.LiveNowTimestamp)
}
-func (s Stream) FriendlyNextDate() string {
+func (s *Stream) FriendlyNextDate() string {
if now.With(s.Start).EndOfDay() == now.EndOfDay() {
return fmt.Sprintf("Today, %02d:%02d", s.Start.Hour(), s.Start.Minute())
}
@@ -292,7 +292,7 @@ func (s Stream) FriendlyNextDate() string {
}
// Color returns the ui color of the stream that indicates it's status
-func (s Stream) Color() string {
+func (s *Stream) Color() string {
if s.Recording {
if s.Private {
return "gray-500"
@@ -307,7 +307,7 @@ func (s Stream) Color() string {
}
}
-func (s Stream) getJson(lhs []LectureHall, course Course) gin.H {
+func (s *Stream) getJson(lhs []LectureHall, course *Course) gin.H {
var files []gin.H
for _, file := range s.Files {
files = append(files, gin.H{
@@ -363,7 +363,7 @@ func (s Stream) getJson(lhs []LectureHall, course Course) gin.H {
}
}
-func (s Stream) Attachments() []File {
+func (s *Stream) Attachments() []File {
attachments := make([]File, 0)
for _, f := range s.Files {
if f.Type == FILETYPE_ATTACHMENT {
@@ -387,8 +387,8 @@ type StreamDTO struct {
Duration int32
}
-func (s Stream) ToDTO() StreamDTO {
- downloads := []DownloadableVod{}
+func (s *Stream) ToDTO() StreamDTO {
+ var downloads []DownloadableVod
if s.IsDownloadable() {
downloads = s.GetVodFiles()
}
@@ -412,7 +412,7 @@ func (s Stream) ToDTO() StreamDTO {
}
// FirstSilenceAsProgress returns the end of the first silence as a quotient of the length of the stream
-func (s Stream) FirstSilenceAsProgress() float64 {
+func (s *Stream) FirstSilenceAsProgress() float64 {
if len(s.Silences) == 0 {
return 0
}
diff --git a/model/user.go b/model/user.go
index 5b30425b8..e948a143b 100755
--- a/model/user.go
+++ b/model/user.go
@@ -70,7 +70,7 @@ type UserSetting struct {
}
// GetPreferredName returns the preferred name of the user if set, otherwise the firstName from TUMOnline
-func (u User) GetPreferredName() string {
+func (u *User) GetPreferredName() string {
for _, setting := range u.Settings {
if setting.Type == PreferredName {
return setting.Value
@@ -157,7 +157,7 @@ func (u *User) GetCustomSpeeds() (speeds CustomSpeeds) {
}
// GetPreferredGreeting returns the preferred greeting of the user if set, otherwise Moin
-func (u User) GetPreferredGreeting() string {
+func (u *User) GetPreferredGreeting() string {
for _, setting := range u.Settings {
if setting.Type == Greeting {
return setting.Value
@@ -189,7 +189,7 @@ func (u *User) GetSeekingTime() int {
}
// PreferredNameChangeAllowed returns false if the user has set a preferred name within the last 3 months, otherwise true
-func (u User) PreferredNameChangeAllowed() bool {
+func (u *User) PreferredNameChangeAllowed() bool {
for _, setting := range u.Settings {
if setting.Type == PreferredName && time.Since(setting.UpdatedAt) < time.Hour*24*30*3 {
return false
@@ -204,7 +204,7 @@ type AutoSkipSetting struct {
}
// GetAutoSkipEnabled returns whether the user has enabled auto skip
-func (u User) GetAutoSkipEnabled() (AutoSkipSetting, error) {
+func (u *User) GetAutoSkipEnabled() (AutoSkipSetting, error) {
for _, setting := range u.Settings {
if setting.Type == AutoSkip {
var a AutoSkipSetting