Skip to content
Snippets Groups Projects
Unverified Commit 74bfcc46 authored by Kevin Lyda's avatar Kevin Lyda
Browse files

Lunch hacking

Incomplete - but updated notes and started implementing CHANGE.
parent 2ecfd7b0
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,7 @@ Switch between MAIL and BULLETIN modes? MAIL commands are documented
## Things to do
* Run [godoc](http://localhost:6060/) and then review where the help text is lacking.
* Missing [RESPOND] [MAIL] [SET PROMPT_EXPIRE] [SET NOREADNEW] [SET NOSHOWNEW] [SET EXPIRE_LIMIT] [SET NOPROMPT_EXPIRE] [SET READNEW] [SET SHOWNEW] [SET DEFAULT_EXPIRE] [SHOW NEW]
* Missing [RESPOND] [MAIL] [SET PROMPT_EXPIRE] [SET NOREADNEW] [SET NOSHOWNEW] [SET NOPROMPT_EXPIRE] [SET READNEW] [SET SHOWNEW] [SHOW NEW]
* Run this.Skew.Safe() before... each command? each write?
* Handle broadcast messages - create a broadcast table and add an expiration column.
* Database
......@@ -31,8 +31,17 @@ Switch between MAIL and BULLETIN modes? MAIL commands are documented
* Commands to connect to Mattermost or mastodon?
* Make a spreadsheet for signups.
* Pager:
* Make / work for search.
* Make "/" work for search.
* Run [VACUUM](https://www.sqlite.org/lang_vacuum.html) on the expire run.
* Notifications:
* Figure out how SHOWNEW, NOTIFY, READNEW and BRIEF work.
* Permissions:
* Review permission requirements for each command.
* Expire. This was created due to file storage limits.
* Code cleanup:
* Review sql queries and clean out the ones not used.
* Review sql queries and find duplicates.
* Use [dupl](https://github.com/mibk/dupl) to find things to generalise.
Polishing. Review each command and put a + next to each as it is
fully done.
......
......@@ -190,9 +190,103 @@ func ActionBack(_ *dclish.Command) error {
return nil
}
// ActionChange handles the `CHANGE` command.
// ActionChange handles the `CHANGE` command. This replaces or modifies
// an existing message.
func ActionChange(cmd *dclish.Command) error {
fmt.Printf("TODO: unimplemented...\n%s\n", cmd.Description)
var err error
optAll := false
if cmd.Flags["/ALL"].Value == "true" {
optAll = true
}
optExpiration := &time.Time{}
if cmd.Flags["/EXPIRATION"].Value != "" {
// dd-mmm-yyyy, or delta time: dddd
exp, err := time.Parse("2006-01-02", cmd.Flags["/EXPIRATION"].Value)
if err != nil {
days, err := strconv.Atoi(cmd.Flags["/EXPIRATION"].Value)
if err != nil {
optExpiration = nil
}
exp := time.Now().AddDate(0, 0, days)
optExpiration = &exp
} else {
optExpiration = &exp
}
}
optGeneral := false
if cmd.Flags["/GENERAL"].Set && this.Folder.Name != "GENERAL" {
return errors.New("Can only be used in the GENERAL folder")
}
if cmd.Flags["/GENERAL"].Value == "true" {
optGeneral = true
}
if cmd.Flags["/GENERAL"].Set && !optGeneral {
return errors.New("Can't specify /NOGENERAL - see /SYSTEM")
}
optNew := false
if cmd.Flags["/NEW"].Value == "true" {
optNew = true
}
optNumber := []int64{this.MsgID}
if cmd.Flags["/NUMBER"].Set && cmd.Flags["/NUMBER"].Value == "" {
return errors.New("Must supply message number(s) if /NUMBER is set")
}
if cmd.Flags["/NUMBER"].Value != "" {
optNumber, err = ParseNumberList(cmd.Flags["/NUMBER"].Value)
if err != nil {
return err
}
}
optPermanent := false
if cmd.Flags["/PERMANENT"].Value == "true" {
optPermanent = true
}
optShutdown := false
if cmd.Flags["/SHUTDOWN"].Value == "true" {
optShutdown = true
}
optSubject := ""
if cmd.Flags["/SUBJECT"].Set && cmd.Flags["/SUBJECT"].Value == "" {
return errors.New("Must supply subject text if /SUBJECT is set")
}
if cmd.Flags["/SUBJECT"].Value != "" {
optSubject = cmd.Flags["/SUBJECT"].Value
}
optSystem := false
if cmd.Flags["/SYSTEM"].Set {
if this.User.Admin == 0 {
return errors.New("Must be admin")
}
if this.Folder.Name != "GENERAL" {
return errors.New("Can only be used in the GENERAL folder")
}
}
if cmd.Flags["/SYSTEM"].Value == "true" {
optSystem = true
}
if cmd.Flags["/SYSTEM"].Set && !optSystem {
return errors.New("Can't specify /NOSYSTEM - see /GENERAL")
}
optText := false
if cmd.Flags["/TEXT"].Value == "true" {
optText = true
}
// Sanity checking.
if optSystem && optGeneral {
return errors.New("Can't specify /SYSTEM and /GENERAL")
}
fmt.Println("TODO: flags parsed, now need to do something.")
return nil
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment