Skip to content

Commit

Permalink
Merge pull request #1718 from KanCraft/feature/fetch-staff-twitter
Browse files Browse the repository at this point in the history
いったん、TwitterのAPIは叩かないように変更
  • Loading branch information
otiai10 authored Aug 9, 2023
2 parents 7d5db17 + 48a9f0f commit e88924f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
45 changes: 25 additions & 20 deletions src/js/Services/API/Twitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,31 @@ export default class TwitterAPI {
) {}

async getOfficialTweets(count = 5): Promise<Status[]> {

Check warning on line 49 in src/js/Services/API/Twitter.ts

View workflow job for this annotation

GitHub Actions / build

'count' is assigned a value but never used
const oauth = OAuthSimple(this.consumer.key, this.consumer.secret);
const request = oauth.sign({
action: "GET",
path: "https://api.twitter.com/1.1/statuses/user_timeline.json",
parameters: {
screen_name: "KanColle_STAFF",
count,
},
signatures: {
oauth_token: this.credential.accessToken,
oauth_secret : this.credential.tokenSecret,
}
});
const res = await fetch(request.signed_url);
const data = await res.json();
if (data.errors) {
console.log(data.errors);
return [];
}
return data;
return [];
/**
* Chrome拡張からTwitterAPIを叩かないようにする.
* TODO: 独自のDatabaseをGitHub上に用意するので、そこをGETするようにする.
*/
// const oauth = OAuthSimple(this.consumer.key, this.consumer.secret);
// const request = oauth.sign({
// action: "GET",
// path: "https://api.twitter.com/1.1/statuses/user_timeline.json",
// parameters: {
// screen_name: "KanColle_STAFF",
// count,
// },
// signatures: {
// oauth_token: this.credential.accessToken,
// oauth_secret : this.credential.tokenSecret,
// }
// });
// const res = await fetch(request.signed_url);
// const data = await res.json();
// if (data.errors) {
// console.log(data.errors);
// return [];
// }
// return data;
}

async uploadSingleImage(img: Blob): Promise<Media> {
Expand Down
5 changes: 3 additions & 2 deletions tests/Services/API/Twitter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ describe("TwitterAPI", () => {
global.TWITTER_CONFIG = { key: "xxx", secret: "xxx" };
describe("getOfficialTweets", () => {
it("なんかとってくる", async () => {
Fetch.replies([{text: "hello"}]);
// Fetch.replies([{text: "hello"}]);
// TODO: GitHub上に独自のDatabaseを用意するので、そこをGETするようにする.
const api = new TwitterAPI();
const statuses = await api.getOfficialTweets();
expect(statuses.length).toBe(1);
expect(statuses.length).toBe(0);
});
});
describe("uploadSingleImage", () => {
Expand Down

0 comments on commit e88924f

Please sign in to comment.