|
@@ -1087,16 +1087,28 @@ export const getTweetUserFollowStatus = (params) => {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- messageCenter.send(params.iframeId, 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', {
|
|
|
- list, tweetId, type, iframeId: params.iframeId, iframeGUId
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId: params.iframeId,
|
|
|
+ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ list, tweetId, type, iframeId: params.iframeId, iframeGUId
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
// chrome.runtime.sendMessage({ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', data: list, tweetId, type: params.type, iframeId: params.iframeId }, () => { })
|
|
|
}).catch(err => {
|
|
|
- messageCenter.send(params.iframeId, 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', {
|
|
|
- list: [], tweetId, type, iframeId: params.iframeId, iframeGUId
|
|
|
- })
|
|
|
- // chrome.runtime.sendMessage({ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', data: [], tweetId, type: params.type, iframeId: params.iframeId }, () => { })
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId: params.iframeId,
|
|
|
+ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ list: [], tweetId, type, iframeId: params.iframeId, iframeGUId
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // chrome.runtime.sendMessage({ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', data: [], tweetId, type: params.type, iframeId: params.iframeId }, () => { })
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -1462,32 +1474,32 @@ export function doTaskTwitterAPI({ task_data, task_type, tasks, iframeId }) {
|
|
|
}
|
|
|
|
|
|
export function doTaskIframeTwitterAPI(params) {
|
|
|
- let {tweet_Id, tweet_text, task_type, tasks, iframeGUId} = JSON.parse(params.data);
|
|
|
- if(task_type == 'tasks') {
|
|
|
- tasks.forEach((item) => {
|
|
|
- switch (String(item.type)) {
|
|
|
- // 关注指定用户
|
|
|
- case '1':
|
|
|
- item.relatedUsers.forEach((item) => {
|
|
|
- if (item.name && item.twitterUserId) {
|
|
|
- TwitterFollowAPI(item, tweet_Id);
|
|
|
- }
|
|
|
- })
|
|
|
- break
|
|
|
- // 点赞
|
|
|
- case '2':
|
|
|
- TwitterLikeAPI(tweet_Id)
|
|
|
- break
|
|
|
- // 推文发推
|
|
|
- case '10':
|
|
|
- // 发推
|
|
|
- TwitterApiCreateTweet({ text: tweet_text, tweet_Id, iframeId: params.iframeId, iframeGUId, iframeMsg: true })
|
|
|
- break
|
|
|
- }
|
|
|
- })
|
|
|
- } else if(task_type == 'like') {
|
|
|
- TwitterLikeAPI(tweet_Id)
|
|
|
- }
|
|
|
+ let { tweet_Id, tweet_text, task_type, tasks, iframeGUId } = JSON.parse(params.data);
|
|
|
+ if (task_type == 'tasks') {
|
|
|
+ tasks.forEach((item) => {
|
|
|
+ switch (String(item.type)) {
|
|
|
+ // 关注指定用户
|
|
|
+ case '1':
|
|
|
+ item.relatedUsers.forEach((item) => {
|
|
|
+ if (item.name && item.twitterUserId) {
|
|
|
+ TwitterFollowAPI(item, tweet_Id);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ break
|
|
|
+ // 点赞
|
|
|
+ case '2':
|
|
|
+ TwitterLikeAPI(tweet_Id)
|
|
|
+ break
|
|
|
+ // 推文发推
|
|
|
+ case '10':
|
|
|
+ // 发推
|
|
|
+ TwitterApiCreateTweet({ text: tweet_text, tweet_Id, iframeId: params.iframeId, iframeGUId, iframeMsg: true })
|
|
|
+ break
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (task_type == 'like') {
|
|
|
+ TwitterLikeAPI(tweet_Id)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export function showJoinDialog(data) {
|
|
@@ -1637,7 +1649,7 @@ const TwitterLikeAPI = (tweet_Id) => {
|
|
|
}
|
|
|
|
|
|
const TwitterApiCreateTweet = ({ text, tweet_Id, iframeId,
|
|
|
- iframeGUId, iframeMsg }) => {
|
|
|
+ iframeGUId, iframeMsg }) => {
|
|
|
let data = {
|
|
|
queryId: "hC1nuE-2d1NX5LYBuuAvtQ",
|
|
|
features: {
|
|
@@ -1683,25 +1695,36 @@ const TwitterApiCreateTweet = ({ text, tweet_Id, iframeId,
|
|
|
"x-twitter-client-language": "en"
|
|
|
},
|
|
|
}).then(function (response) {
|
|
|
- console.log(response)
|
|
|
- let data = response.data;
|
|
|
- if(iframeMsg) {
|
|
|
- messageCenter.send(iframeId, 'CONTENT_CREATE_TWEET_FINISH', {
|
|
|
- tweet_Id, iframeId, iframeGUId, response: data, done: true
|
|
|
- })
|
|
|
- } else {
|
|
|
- chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'createTweet1', task_data: '', task_done: '是', response, iframeId })
|
|
|
- }
|
|
|
+ console.log(response)
|
|
|
+ let data = response.data;
|
|
|
+ if (iframeMsg) {
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId,
|
|
|
+ actionType: 'CONTENT_CREATE_TWEET_FINISH'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ tweet_Id, iframeId, iframeGUId, response: data, done: true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'createTweet1', task_data: '', task_done: '是', response, iframeId })
|
|
|
+ }
|
|
|
}).catch(function (err) {
|
|
|
- console.log('err --1', err)
|
|
|
- if(iframeMsg) {
|
|
|
- messageCenter.send(iframeId, 'CONTENT_CREATE_TWEET_FINISH', {
|
|
|
- tweet_Id, iframeId, iframeGUId, done: false
|
|
|
- })
|
|
|
-
|
|
|
- } else {
|
|
|
- chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'createTweet1', task_data: '', task_done: '否', iframeId })
|
|
|
- }
|
|
|
+ console.log('err --1', err)
|
|
|
+ if (iframeMsg) {
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId,
|
|
|
+ actionType: 'CONTENT_CREATE_TWEET_FINISH'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ tweet_Id, iframeId, iframeGUId, done: false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'createTweet1', task_data: '', task_done: '否', iframeId })
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -1732,22 +1755,35 @@ export const TwitterApiUserByScreenName = (params, cb) => {
|
|
|
let { screen_name, tweetId = '', objectType = '', iframeId = '', iframeMsg = false, iframeGUId } = params;
|
|
|
|
|
|
TwitterApiUserByScreenNameReq({ screen_name }).then(function (response) {
|
|
|
- if(iframeMsg) {
|
|
|
- messageCenter.send(iframeId, 'CONTENT_API_GET_TWEET_USER_INFO_END', {
|
|
|
- iframeGUId, response: response.data.data || {}, objectType
|
|
|
- })
|
|
|
- } else {
|
|
|
- chrome.runtime.sendMessage({ actionType: "CONTENT_API_GET_TWEET_USER_INFO_RES", data: response.data.data || {}, tweetId, objectType, iframeId }, () => { })
|
|
|
- }
|
|
|
+ if (iframeMsg) {
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId,
|
|
|
+ actionType: 'CONTENT_API_GET_TWEET_USER_INFO_END'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ iframeGUId, response: response.data.data || {}, objectType
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ chrome.runtime.sendMessage({ actionType: "CONTENT_API_GET_TWEET_USER_INFO_RES", data: response.data.data || {}, tweetId, objectType, iframeId }, () => { })
|
|
|
+ }
|
|
|
|
|
|
}).catch(function (err) {
|
|
|
- if(iframeMsg) {
|
|
|
- messageCenter.send(iframeId, 'CONTENT_API_GET_TWEET_USER_INFO_END', {
|
|
|
- iframeGUId, response: {}, objectType
|
|
|
- })
|
|
|
- } else {
|
|
|
- chrome.runtime.sendMessage({ actionType: "CONTENT_API_GET_TWEET_USER_INFO_RES", data: {}, tweetId, objectType, iframeId }, () => { })
|
|
|
- }
|
|
|
+ if (iframeMsg) {
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId,
|
|
|
+ actionType: 'CONTENT_API_GET_TWEET_USER_INFO_END'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ iframeGUId, response: {}, objectType
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ chrome.runtime.sendMessage({ actionType: "CONTENT_API_GET_TWEET_USER_INFO_RES", data: {}, tweetId, objectType, iframeId }, () => { })
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -2804,11 +2840,11 @@ export const showPublishDialog = () => {
|
|
|
|
|
|
// 获取推文发送回去
|
|
|
export const sendContentByTwitterID = (params) => {
|
|
|
- let {tweet_Id, iframeGUId} = JSON.parse(params.data);
|
|
|
+ let { tweet_Id, iframeGUId } = JSON.parse(params.data);
|
|
|
// 获取内容
|
|
|
let txt = parseCard.getContentByTwitterId(tweet_Id);
|
|
|
messageCenter.send(params.iframeId, 'CONTENT_GET_TWEET_TXT', {
|
|
|
- iframeGUId, tweet_Id, txt
|
|
|
+ iframeGUId, tweet_Id, txt
|
|
|
})
|
|
|
// 发送
|
|
|
// chrome.runtime.sendMessage({
|