Skip to content

Commit

Permalink
10.100.0-l190411040726
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Apr 10, 2019
2 parents 85ada7a + 2a61e3e commit 818277a
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "misskey",
"author": "syuilo <[email protected]>",
"version": "10.100.0-l190410182002",
"version": "10.100.0-l190411040726",
"codename": "nighthike",
"repository": {
"type": "git",
Expand Down
61 changes: 50 additions & 11 deletions src/client/app/common/views/widgets/post-form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
<footer>
<button @click="chooseFile"><fa icon="upload"/></button>
<button @click="chooseFileFromDrive"><fa icon="cloud"/></button>
<button @click="kao"><fa :icon="['far', 'smile']"/></button>
<button @click="setVisibility" ref="visibilityButton">
<span v-if="visibility === 'public'"><fa icon="globe"/></span>
<span v-if="visibility === 'home'"><fa icon="home"/></span>
<span v-if="visibility === 'followers'"><fa icon="unlock"/></span>
<span v-if="visibility === 'specified'"><fa icon="envelope"/></span>
<span v-if="localOnly" class="localOnly"><fa icon="heart"/></span>
</button>
<button @click="post" :disabled="posting" class="post">{{ $t('note') }}</button>
</footer>
</div>
Expand All @@ -46,6 +54,8 @@ import define from '../../../common/define-widget';
import i18n from '../../../i18n';
import insertTextAtCursor from 'insert-text-at-cursor';
import * as XDraggable from 'vuedraggable';
import getFace from '../../../common/scripts/get-face';
import MkVisibilityChooser from '../../../common/views/components/visibility-chooser.vue';
export default define({
name: 'post-form',
Expand All @@ -56,14 +66,17 @@ export default define({
i18n: i18n('desktop/views/widgets/post-form.vue'),
components: {
XDraggable
XDraggable,
MkVisibilityChooser
},
data() {
return {
posting: false,
text: '',
files: [],
visibility: 'public',
localOnly: false,
};
},
Expand All @@ -81,6 +94,11 @@ export default define({
}
},
mounted() {
// デフォルト公開範囲
this.applyVisibility(this.$store.state.settings.defaultNoteVisibility);
},
methods: {
func() {
if (this.props.design == 1) {
Expand Down Expand Up @@ -173,25 +191,39 @@ export default define({
});
},
post() {
this.posting = true;
kao() {
this.text += getFace();
},
let visibility = 'public';
let localOnly = false;
setVisibility() {
const w = this.$root.new(MkVisibilityChooser, {
source: this.$refs.visibilityButton,
currentVisibility: this.visibility
});
w.$once('chosen', v => {
this.applyVisibility(v);
});
},
const m = this.$store.state.settings.defaultNoteVisibility.match(/^local-(.+)/);
applyVisibility(v :string) {
const m = v.match(/^local-(.+)/);
if (m) {
visibility = m[1];
localOnly = true;
this.localOnly = true;
this.visibility = m[1];
} else {
visibility = this.$store.state.settings.defaultNoteVisibility;
this.localOnly = false;
this.visibility = v;
}
},
post() {
this.posting = true;
this.$root.api('notes/create', {
text: this.text == '' ? undefined : this.text,
fileIds: this.files.length > 0 ? this.files.map(f => f.id) : undefined,
visibility,
localOnly,
visibility: this.visibility,
localOnly: this.localOnly,
}).then(data => {
this.clear();
}).catch(err => {
Expand Down Expand Up @@ -294,6 +326,13 @@ export default define({
&:hover
color var(--textHighlighted)
> button > .localOnly
color var(--primary)
position absolute
top 0
right 2px
transform scale(.8)
> .post
display block
margin 0 0 0 auto
Expand Down
3 changes: 2 additions & 1 deletion src/queue/processors/inbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Logger from '../../services/logger';
import { registerOrFetchInstanceDoc } from '../../services/register-or-fetch-instance-doc';
import Instance from '../../models/instance';
import instanceChart from '../../services/chart/instance';
import { validActor } from '../../remote/activitypub/type';

const logger = new Logger('inbox');

Expand Down Expand Up @@ -79,7 +80,7 @@ export default async (job: Bull.Job): Promise<void> => {

// Update Person activityの場合は、ここで署名検証/更新処理まで実施して終了
if (activity.type === 'Update') {
if (activity.object && activity.object.type === 'Person') {
if (activity.object && validActor.includes(activity.object.type)) {
if (user == null) {
logger.warn('Update activity received, but user not registed.');
} else if (!httpSignature.verifySignature(signature, user.publicKey.publicKeyPem)) {
Expand Down
4 changes: 2 additions & 2 deletions src/remote/activitypub/models/person.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import config from '../../../config';
import User, { validateUsername, isValidName, IUser, IRemoteUser, isRemoteUser } from '../../../models/user';
import Resolver from '../resolver';
import { resolveImage } from './image';
import { isCollectionOrOrderedCollection, isCollection, IPerson, isOrderedCollection } from '../type';
import { isCollectionOrOrderedCollection, isCollection, IPerson, isOrderedCollection, validActor } from '../type';
import { IDriveFile } from '../../../models/drive-file';
import Meta from '../../../models/meta';
import { fromHtml } from '../../../mfm/fromHtml';
Expand Down Expand Up @@ -38,7 +38,7 @@ function validatePerson(x: any, uri: string) {
return new Error('invalid person: object is null');
}

if (x.type != 'Person' && x.type != 'Service') {
if (!validActor.includes(x.type)) {
return new Error(`invalid person: object is not a person or service '${x.type}'`);
}

Expand Down
2 changes: 2 additions & 0 deletions src/remote/activitypub/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ interface IQuestionChoice {
_misskey_votes?: number;
}

export const validActor = ['Person', 'Service'];

export interface IPerson extends IObject {
type: 'Person';
name: string;
Expand Down
3 changes: 2 additions & 1 deletion src/server/api/endpoints/ap/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Resolver from '../../../../remote/activitypub/resolver';
import { ApiError } from '../../error';
import Instance from '../../../../models/instance';
import { extractDbHost } from '../../../../misc/convert-host';
import { validActor } from '../../../../remote/activitypub/type';

export const meta = {
tags: ['federation'],
Expand Down Expand Up @@ -95,7 +96,7 @@ async function fetchAny(uri: string) {
}

// それでもみつからなければ新規であるため登録
if (object.type === 'Person') {
if (validActor.includes(object.type)) {
const user = await createPerson(object.id);
return {
type: 'User',
Expand Down

0 comments on commit 818277a

Please sign in to comment.