Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskcenter
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
taskcenter
Commits
c5675226
Commit
c5675226
authored
Oct 11, 2024
by
贾浩@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update telegram bind action
parent
668e385d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
1 deletion
+21
-1
constant.go
constant/constant.go
+3
-1
tg_task.go
dao/tg_task.go
+11
-0
task.go
sync/task.go
+7
-0
No files found.
constant/constant.go
View file @
c5675226
...
@@ -35,6 +35,7 @@ func IsValidPlatform(platform string) bool {
...
@@ -35,6 +35,7 @@ func IsValidPlatform(platform string) bool {
}
}
const
(
const
(
TaskActionBind
=
"bind"
TaskActionJoin
=
"join"
TaskActionJoin
=
"join"
TaskActionActive
=
"active"
TaskActionActive
=
"active"
TaskActionFollow
=
"follow"
TaskActionFollow
=
"follow"
...
@@ -45,6 +46,7 @@ const (
...
@@ -45,6 +46,7 @@ const (
)
)
var
validActions
=
map
[
string
]
bool
{
var
validActions
=
map
[
string
]
bool
{
TaskActionBind
:
true
,
TaskActionJoin
:
true
,
TaskActionJoin
:
true
,
TaskActionActive
:
true
,
TaskActionActive
:
true
,
TaskActionFollow
:
true
,
TaskActionFollow
:
true
,
...
@@ -61,7 +63,7 @@ func IsValidAction(action string) bool {
...
@@ -61,7 +63,7 @@ func IsValidAction(action string) bool {
var
TaskAction
=
map
[
string
][]
string
{
var
TaskAction
=
map
[
string
][]
string
{
TaskPlatformApp
:
{
TaskActionActive
,
TaskActionInvite
},
TaskPlatformApp
:
{
TaskActionActive
,
TaskActionInvite
},
TaskPlatformTelegram
:
{
TaskActionJoin
,
TaskActionActive
},
TaskPlatformTelegram
:
{
TaskActionJoin
,
TaskActionActive
,
TaskActionBind
},
TaskPlatformTwitter
:
{
TaskActionFollow
,
TaskActionLike
,
TaskActionReply
,
TaskActionRetweet
},
TaskPlatformTwitter
:
{
TaskActionFollow
,
TaskActionLike
,
TaskActionReply
,
TaskActionRetweet
},
}
}
...
...
dao/tg_task.go
View file @
c5675226
...
@@ -7,6 +7,8 @@ import (
...
@@ -7,6 +7,8 @@ import (
"io"
"io"
"net/http"
"net/http"
"strings"
"strings"
"taskcenter/constant"
dbModel
"taskcenter/model/db"
"time"
"time"
log
"github.com/sirupsen/logrus"
log
"github.com/sirupsen/logrus"
...
@@ -90,3 +92,12 @@ func httpPost(url string, body io.Reader) ([]byte, error) {
...
@@ -90,3 +92,12 @@ func httpPost(url string, body io.Reader) ([]byte, error) {
defer
resp
.
Body
.
Close
()
defer
resp
.
Body
.
Close
()
return
io
.
ReadAll
(
resp
.
Body
)
return
io
.
ReadAll
(
resp
.
Body
)
}
}
func
(
d
*
Dao
)
CheckTGBind
(
userId
string
)
(
ok
bool
,
err
error
)
{
// 任务完成表中是否存在该用户
sql
:=
`SELECT COUNT(1) FROM %s AS T JOIN %s AS TH ON T.id = TH.task_id WHERE TH.user_id = ? AND T.platform = ? AND T.action = ? AND T.start >= ? AND T.end <= ? AND T.deleted_at IS NULL AND TH.deleted_at IS NULL`
sql
=
fmt
.
Sprintf
(
sql
,
(
&
dbModel
.
Task
{})
.
TableName
(),
(
&
dbModel
.
TaskHistory
{})
.
TableName
())
var
ct
int64
err
=
d
.
db
.
Raw
(
sql
,
userId
,
constant
.
TaskPlatformTelegram
,
constant
.
TaskActionBind
,
time
.
Now
()
.
Unix
(),
time
.
Now
()
.
Unix
())
.
Count
(
&
ct
)
.
Error
return
ct
>
0
,
err
}
sync/task.go
View file @
c5675226
...
@@ -78,6 +78,13 @@ func (s *Sync) SyncTask(taskId int, userId string) (ok bool, err error) {
...
@@ -78,6 +78,13 @@ func (s *Sync) SyncTask(taskId int, userId string) (ok bool, err error) {
return
false
,
err
return
false
,
err
}
}
return
taskDone
,
nil
return
taskDone
,
nil
case
constant
.
TaskActionBind
:
alreadyDone
,
err
:=
s
.
d
.
CheckTGBind
(
userId
)
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"check tg bind error"
)
return
false
,
err
}
return
!
alreadyDone
,
nil
default
:
default
:
return
false
,
fmt
.
Errorf
(
"unknown task action: %s"
,
task
.
Action
)
return
false
,
fmt
.
Errorf
(
"unknown task action: %s"
,
task
.
Action
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment