Beispiel #1
0
        protected string GetNoteHistoryUrl(string guid)
        {
            var url = new GetNoteHistoryRequest()
            {
                Guid     = guid,
                Username = RainyTestServer.TEST_USER
            }.ToUrl("GET");

            return(testServer.ListenUrl + url);
        }
Beispiel #2
0
        public object Get(GetNoteHistoryRequest request)
        {
            string include_note_text = Request.GetParam ("include_text");
            bool include_text = false;
            if (!string.IsNullOrEmpty (include_note_text) && !bool.TryParse (include_note_text, out include_text))
                throw new InvalidRequestDtoException () {ErrorMessage = "unable to parse parameter include_text to boolean"};

            var resp = new NoteHistoryResponse () {
                CurrentRevision = -1,
                Versions = new NoteHistory[] {}
            };

            using (var db = connFactory.OpenDbConnection ()) {
                var revisions = db.First<DBUser> (u => u.Username == requestingUser.Username).Manifest.NoteRevisions;
                if (revisions.ContainsKey (request.Guid)) {
                    // note was not deleted in the meantime
                    resp.CurrentRevision = revisions[request.Guid];
                } else {
                    throw new Rainy.ErrorHandling.InvalidRequestDtoException ();
                }

                var archived_notes = db.Select<DBArchivedNote> (n => n.Username == requestingUser.Username && n.Guid == request.Guid);

                DBUser user = null;
                resp.Versions = archived_notes.Select (note => {
                    var history = new NoteHistory () { Revision = note.LastSyncRevision };

                    if (note.IsEncypted && include_text) {
                        if (user == null)
                            user = db.First<DBUser> (u => u.Username == requestingUser.Username);

                        note.Decrypt (user, requestingUser.EncryptionMasterKey);
                    } else if (!include_text) {
                        note.Text = "";
                    }

                    history.Note = ((DBNote) note).ToDTONote ();
                    return history;
                }).ToArray ();
            }
            return resp;
        }
Beispiel #3
0
 protected string GetNoteHistoryUrl(string guid)
 {
     var url = new GetNoteHistoryRequest () {
         Guid = guid,
         Username = RainyTestServer.TEST_USER
     }.ToUrl ("GET");
     return testServer.ListenUrl + url;
 }