added mastodon interfaces
This commit is contained in:
parent
c3ec804956
commit
04a3cb92e5
@ -109,6 +109,7 @@
|
||||
<TypeScriptCompile Include="src\app\models\stream.models.ts" />
|
||||
<TypeScriptCompile Include="src\app\services\auth.service.ts" />
|
||||
<TypeScriptCompile Include="src\app\services\models\api.settings.ts" />
|
||||
<TypeScriptCompile Include="src\app\services\models\mastodon.interfaces.ts" />
|
||||
<TypeScriptCompile Include="src\environments\environment.prod.ts" />
|
||||
<TypeScriptCompile Include="src\environments\environment.ts" />
|
||||
<TypeScriptCompile Include="src\main.ts" />
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Component, OnInit, Input } from "@angular/core";
|
||||
import { AuthService } from "../../services/auth.service";
|
||||
import { TokenData } from "../../services/models/mastodon.interfaces";
|
||||
|
||||
@Component({
|
||||
selector: "app-register-new-account",
|
||||
@ -20,8 +21,8 @@ export class RegisterNewAccountComponent implements OnInit {
|
||||
|
||||
onSubmit(): boolean {
|
||||
this.authService.getToken(this.mastodonNode, this.email, this.password)
|
||||
.then((res: string) => {
|
||||
this.result = res;
|
||||
.then((res: TokenData) => {
|
||||
this.result = res.access_token;
|
||||
})
|
||||
.catch(err => {
|
||||
this.result = err;
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { Http, Response, RequestOptions } from "@angular/http";
|
||||
import { ApiRoutes } from "./models/api.settings";
|
||||
import { TokenData } from "./models/mastodon.interfaces";
|
||||
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
@ -11,7 +12,7 @@ export class AuthService {
|
||||
}
|
||||
|
||||
getToken(
|
||||
mastodonNode: string, email: string, password: string): Promise<string> {
|
||||
mastodonNode: string, email: string, password: string): Promise<TokenData> {
|
||||
|
||||
//TODO retrieve those via API
|
||||
const clientId = localStorage.getItem("client_id");
|
||||
@ -34,7 +35,7 @@ export class AuthService {
|
||||
.then((res: Response) => {
|
||||
const result = res.json();
|
||||
console.warn(result);
|
||||
return result;
|
||||
return result as TokenData;
|
||||
});
|
||||
}
|
||||
|
||||
|
124
Mamoth/src/app/services/models/mastodon.interfaces.ts
Normal file
124
Mamoth/src/app/services/models/mastodon.interfaces.ts
Normal file
@ -0,0 +1,124 @@
|
||||
export interface TokenData {
|
||||
access_token: string;
|
||||
token_type: string;
|
||||
scope: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface Account {
|
||||
id: number;
|
||||
username: string;
|
||||
acct: string;
|
||||
display_name: string;
|
||||
locked: string;
|
||||
created_at: string;
|
||||
followers_count: number;
|
||||
following_count: number;
|
||||
statuses_count: number;
|
||||
note: string;
|
||||
url: string;
|
||||
avatar: string;
|
||||
avatar_static: string;
|
||||
header: string;
|
||||
header_static: string;
|
||||
}
|
||||
|
||||
export interface Application {
|
||||
name: string;
|
||||
website: string;
|
||||
}
|
||||
|
||||
export interface Attachment {
|
||||
id: string;
|
||||
type: 'image' | 'video' | 'gifv';
|
||||
url: string;
|
||||
remote_url: string;
|
||||
preview_url: string;
|
||||
text_url: string;
|
||||
}
|
||||
|
||||
export interface Card {
|
||||
url: string;
|
||||
title: string;
|
||||
description: string;
|
||||
image: string;
|
||||
}
|
||||
|
||||
export interface Context {
|
||||
ancestors: Status[];
|
||||
descendants: Status[];
|
||||
}
|
||||
|
||||
export interface Error {
|
||||
error: string;
|
||||
}
|
||||
|
||||
export interface Instance {
|
||||
uri: string;
|
||||
title: string;
|
||||
description: string;
|
||||
email: string;
|
||||
}
|
||||
|
||||
export interface Mention {
|
||||
url: string;
|
||||
username: string;
|
||||
acct: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface Notification {
|
||||
id: string;
|
||||
type: 'mention' | 'reblog' | 'favourite' | 'follow';
|
||||
created_at: string;
|
||||
account: Account;
|
||||
status?: Status;
|
||||
}
|
||||
|
||||
export interface Relationship {
|
||||
id: string;
|
||||
following: string;
|
||||
followed_by: string;
|
||||
blocking: string;
|
||||
muting: string;
|
||||
requested: string;
|
||||
}
|
||||
|
||||
export interface Report {
|
||||
id: string;
|
||||
action_taken: boolean;
|
||||
}
|
||||
|
||||
export interface Results {
|
||||
accounts: Account[];
|
||||
statuses: Status[];
|
||||
hashtags: string[];
|
||||
}
|
||||
|
||||
export interface Status {
|
||||
id: string;
|
||||
uri: string;
|
||||
url: string;
|
||||
account: string;
|
||||
in_reply_to_id: string;
|
||||
in_reply_to_account_id: string;
|
||||
reblog: string;
|
||||
content: string;
|
||||
created_at: string;
|
||||
reblogs_count: string;
|
||||
favourites_count: string;
|
||||
reblogged: string;
|
||||
favourited: string;
|
||||
sensitive: string;
|
||||
spoiler_text: string;
|
||||
visibility: string;
|
||||
media_attachments: string;
|
||||
mentions: string;
|
||||
tags: string;
|
||||
application: Application;
|
||||
}
|
||||
export interface Tag {
|
||||
name: string;
|
||||
url: string;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user