Move channel name to notes
This commit is contained in:
4
asana.go
4
asana.go
@@ -23,6 +23,7 @@ type addTaskRequest struct {
|
||||
|
||||
type addTaskRequestInt struct {
|
||||
Name string `json:"name"`
|
||||
HtmlNotes string `json:"html_notes"`
|
||||
Workspace string `json:"workspace"`
|
||||
Assignee string `json:"assignee"`
|
||||
Projects []string `json:"projects"`
|
||||
@@ -38,10 +39,11 @@ func NewAsanaClient() *AsanaClient {
|
||||
}
|
||||
}
|
||||
|
||||
func (ac *AsanaClient) CreateTask(name string) error {
|
||||
func (ac *AsanaClient) CreateTask(name string, notes string) error {
|
||||
body := &addTaskRequest{
|
||||
Data: &addTaskRequestInt{
|
||||
Name: name,
|
||||
HtmlNotes: notes,
|
||||
Workspace: ac.workspace,
|
||||
Assignee: ac.assignee,
|
||||
Projects: []string{ac.project},
|
||||
|
||||
17
slack.go
17
slack.go
@@ -231,9 +231,22 @@ func (sc *SlackClient) GetTitle(item *Item, user *User, channel *Channel) (strin
|
||||
case channel.IsIm:
|
||||
return fmt.Sprintf("[%s] %s", user.Name, item.Message.Text), nil
|
||||
case channel.IsMpIm:
|
||||
return fmt.Sprintf("[%s -> %s] %s", user.Name, sc.getTaggedNamesString(channel.Purpose.Value), item.Message.Text), nil
|
||||
return fmt.Sprintf("[%s] %s", user.Name, item.Message.Text), nil
|
||||
case channel.IsChannel:
|
||||
return fmt.Sprintf("[%s -> #%s] %s", user.Name, channel.Name, item.Message.Text), nil
|
||||
return fmt.Sprintf("[%s] %s", user.Name, item.Message.Text), nil
|
||||
default:
|
||||
return "", fmt.Errorf("unknown channel type: %#v", channel)
|
||||
}
|
||||
}
|
||||
|
||||
func (sc *SlackClient) GetNotes(item *Item, user *User, channel *Channel) (string, error) {
|
||||
switch {
|
||||
case channel.IsIm:
|
||||
return "", nil
|
||||
case channel.IsMpIm:
|
||||
return fmt.Sprintf("<body>In %s</body>", sc.getTaggedNamesString(channel.Purpose.Value)), nil
|
||||
case channel.IsChannel:
|
||||
return fmt.Sprintf("<body>In #%s</body>", channel.Name), nil
|
||||
default:
|
||||
return "", fmt.Errorf("unknown channel type: %#v", channel)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,10 @@ func main() {
|
||||
for {
|
||||
time.Sleep(time.Duration(rand.Intn(60)) * time.Second)
|
||||
|
||||
Poll(ac, sc)
|
||||
err = Poll(ac, sc)
|
||||
if err != nil {
|
||||
log.Printf("%s", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,9 +53,14 @@ func Poll(ac *AsanaClient, sc *SlackClient) error {
|
||||
return err
|
||||
}
|
||||
|
||||
notes, err := sc.GetNotes(item, user, channel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Printf("%s\n", title)
|
||||
|
||||
err = ac.CreateTask(title)
|
||||
err = ac.CreateTask(title, notes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user