forked from FoundKeyGang/FoundKey
parent
c5dd9439d5
commit
538ca2a7c7
2 changed files with 25 additions and 0 deletions
|
@ -64,6 +64,11 @@ export default Vue.extend({
|
|||
inbox
|
||||
}).then((relay: any) => {
|
||||
this.refresh();
|
||||
}).catch((e: any) => {
|
||||
this.$root.dialog({
|
||||
type: 'error',
|
||||
text: e.message || e
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -72,6 +77,11 @@ export default Vue.extend({
|
|||
inbox
|
||||
}).then(() => {
|
||||
this.refresh();
|
||||
}).catch((e: any) => {
|
||||
this.$root.dialog({
|
||||
type: 'error',
|
||||
text: e.message || e
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { addRelay } from '../../../../../services/relay';
|
||||
import { ApiError } from '../../../error';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
|
@ -17,8 +18,22 @@ export const meta = {
|
|||
validator: $.str
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
invalidUrl: {
|
||||
message: 'Invalid URL',
|
||||
code: 'INVALID_URL',
|
||||
id: 'fb8c92d3-d4e5-44e7-b3d4-800d5cef8b2c'
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
export default define(meta, async (ps, user) => {
|
||||
try {
|
||||
if (new URL(ps.inbox).protocol !== 'https:') throw 'https only';
|
||||
} catch {
|
||||
throw new ApiError(meta.errors.invalidUrl);
|
||||
}
|
||||
|
||||
return await addRelay(ps.inbox);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue