func FaxRecv(sess *agi.Session) { sess.Answer() uid := strings.Split(sess.Env["uniqueid"], ".") _, err := sess.SetVariable("FAXFILENAME", fmt.Sprintf("%s_%s_%s", sess.Env["callerid"], sess.Env["dnid"], uid[0])) _, err = sess.SetVariable("FAXOPT(headerinfo)", fmt.Sprintf("Received_by_%s_%s", sess.Env["callerid"], uid[0])) _, err = sess.SetVariable("FAXOPT(localstationid)", sess.Env["callerid"]) _, err = sess.SetVariable("FAXOPT(maxrate)", "14400") _, err = sess.SetVariable("FAXOPT(minrate)", "4800") filename, err := sess.GetVariable("FAXFILENAME") _, err = sess.Exec("ReceiveFax", fmt.Sprintf(FAXDIR+FAXRECVSTR, filename.Dat)) if err != nil { LoggerErr(err) } else { fs, err := sess.GetVariable("FAXSTATUS") fp, err := sess.GetVariable("FAXPAGES") fb, err := sess.GetVariable("FAXBITRATE") fr, err := sess.GetVariable("FAXRESOLUTION") if err != nil { LoggerErr(err) } if fs.Dat == "" || fs.Dat == "FAILED" { fs.Dat = "FAILED" } msg := fmt.Sprintf("Статус: %s\nС номера: %s\nНа номер: %s\nКоличество страниц: %s\nСкорость передачи(bitrate): %s\nРазрешение файла: %s", fs.Dat, sess.Env["callerid"], sess.Env["dnid"], fp.Dat, fb.Dat, fr.Dat) NotifyMail("ФаксВходящий", sess.Env["callerid"], msg, MAIL) NotifyMail("ФаксВходящий", sess.Env["callerid"], msg, "fax-"+sess.Env["dnid"]) } sess.Hangup() }
func BlockedFromPSTN(sess *agi.Session) { dbinfo := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=%s", DBHost, DBPort, DBUser, DBPass, DBName, DBSSL) db, err := sql.Open(DBType, dbinfo) if err != nil { LoggerErr(err) } rows, err := db.Query(fmt.Sprintf(BLOCKPSTNQUERY, sess.Env["callerid"])) if err != nil { LoggerErr(err) } defer rows.Close() var arg1, arg2 string for rows.Next() { rows.Scan(&arg1, &arg2) } db.Close() if len(arg1) != 0 && len(arg2) != 0 { _, err := sess.Exec("UserEvent", fmt.Sprintf(UEBLOCKEDABON, sess.Env["callerid"], sess.Env["uniqueid"])) if err != nil { LoggerErr(err) } sess.Hangup() } }