refactor: Redesign twitter trigger and actions
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import getCurrentUser from '../../common/get-current-user';
|
||||
import getUserByUsername from '../../common/get-user-by-username';
|
||||
import getUserTweets from '../../common/get-user-tweets';
|
||||
|
||||
export default {
|
||||
@@ -20,18 +18,13 @@ export default {
|
||||
],
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
return this.getTweets($, await $.db.flow.lastInternalId());
|
||||
return await getUserTweets($, {
|
||||
currentUser: true,
|
||||
lastInternalId: $.db.flow.lastInternalId,
|
||||
});
|
||||
},
|
||||
|
||||
async testRun($: IGlobalVariable) {
|
||||
return this.getTweets($);
|
||||
},
|
||||
|
||||
async getTweets($: IGlobalVariable, lastInternalId?: string) {
|
||||
const { username } = await getCurrentUser($);
|
||||
const user = await getUserByUsername($, username);
|
||||
|
||||
const tweets = await getUserTweets($, user.id, lastInternalId);
|
||||
return tweets;
|
||||
return await getUserTweets($, { currentUser: true });
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user